fix(bridge): resume persisted session_id after restart when SDK transcript exists#325
Open
seoseo-ai wants to merge 2 commits into
Open
fix(bridge): resume persisted session_id after restart when SDK transcript exists#325seoseo-ai wants to merge 2 commits into
seoseo-ai wants to merge 2 commits into
Conversation
…K transcript exists
After a bridge restart the in-memory _runtime_active_sessions set is empty,
so _effective_session_id rejected every persisted session_id ("Ignoring
persisted session_id ... not active in current runtime") and each
conversation started blank — diagnosed as PATH1 memory loss (2026-07-08,
daegyo node, diag-memory.sh: PATH1 marker x1, PATH2 markers 0).
Fix: a persisted session_id not in the runtime set is now auto-resumed when
its SDK conversation JSONL transcript still exists under
~/.claude/projects/<project>/ (validated via resolve_conversation_file, so
corrupt/traversal ids cannot escape the directory). Stale ids without a
transcript are still ignored, preserving the original cross-process safety
intent. Off-switch: CCC_RESUME_PERSISTED_SESSIONS=false restores the old
never-resume behavior.
- new pure helper core/session_resume.py (+8 unit tests, all green)
- full suite: 476 tests, same 7 pre-existing env failures on clean main
(voice/path-scope, Termux env) — no regression from this change
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
After a bridge restart,
_effective_session_idrejected every persisted session_id because the in-memory_runtime_active_sessionsset starts empty — every conversation began blank (bot "memory loss").Why (evidence)
Diagnosed 2026-07-08 on daegyo node via controlled restart experiment: PATH1 CONFIRMED —
Ignoring persisted session_idmarker fired on the first post-restart message (10:37:37 KST); PATH2 (stale stream / reader crash) markers: 0.Fix
~/.claude/projects/<project>/(validated viaresolve_conversation_file— traversal-safe).Ignoring persisted session_idlog marker kept for diagnostics).CCC_RESUME_PERSISTED_SESSIONS=falserestores old behavior. Documented in bridge/CLAUDE.md env table.core/session_resume.pyper the extracted-helpers convention.Test plan
tests/test_session_resume.py— 8/8 green (flag parsing, transcript exists/missing, traversal rejection, dir-not-file)python -m unittest discover tests: 476 tests; same 7 pre-existing env failures reproduced on clean main (voice/path-scope, Termux env) — no regression🤖 Generated with Claude Code