feat(bridge): inject recent conversation history when session resets#319
Merged
Merged
Conversation
When a Claude Code session expires or the bridge restarts, the next user message previously arrived in a blank new session — losing all context (e.g. user answering '2' to a numbered-option prompt got "what does 2 mean?" back). Fix: before calling process_message(), capture the stale session_id and read the last 6 exchanges via get_recent_messages(). If the effective_sid is None (new session) but a prior session exists, the exchanges are prepended to the user message as a clearly-labelled context block so Claude can interpret short replies in context. Falls back silently on read errors so existing behaviour is unchanged when no history is available. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
a94204a to
6015104
Compare
jinon86
approved these changes
Jul 7, 2026
jinon86
left a comment
Contributor
There was a problem hiding this comment.
LGTM — history injection logic is clean and well-scoped. Silent fallback on read errors ensures no regression for existing flows. All CI green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
effective_sid == None+stale_session_id존재 조건에서get_recent_messages()로 최근 6교환 읽기[이전 대화 맥락 — 세션 전환으로 자동 주입됨]블록으로 메시지 앞에 삽입Motivation
사용자가 "1/2/3 중 선택" 프롬프트에 "2"로 답했을 때, 세션이 끊긴 경우 대교가 맥락을 잃고 "'2'가 무엇인지 모르겠다"고 응답하는 문제 수정. JSONL 히스토리 파일(
~/.claude/projects/)과 기존get_recent_messages()헬퍼를 활용.Test plan
History injection:로그)🤖 Generated with Claude Code