Repository navigation
Fork from the saved session after a restart - #191
Merged
Merged
Conversation
A fork of a whole conversation served before an opencode restart replayed it as text, because the fork checkpoints are kept in memory. The parent's resume record is on disk, so the fork now starts from it with --resume <id> --fork-session. A fork from an earlier message still replays (h #g319).
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.
A fork of a whole conversation that an earlier opencode process served now starts from the parent's saved Claude session instead of replaying the thread as text (h #g319).
What happened
On 2026-11-15 the maintainer forked the director session through its last message. opencode had restarted three times since the parent's last turn, and the fork checkpoints (h #g305) live in memory, so the fork's first turn replayed 2,888 messages bounded to 180,000 characters and lost almost all of its context. The parent's resume record and transcript were on disk.
Change
findForkResumePoint(src/session-resume-store.ts) looks for a sibling key's record (forkSiblingSignature: only the affinity may differ), the same binary, not being written to, its transcript on disk, and a strict chain this history continues with nothing but the reply past it. Longest match wins.forkFromCheckpoint,resumeAfterRestartand the--fork-sessionprobe, and starts the fork asforkSessionsdoes:--resume <id> --fork-sessionheadless,forkOfon the interactive transport. The parent keeps its record and its conversation.usagenote made every fork miss.Checked
serve, scratch XDG dirs, Haiku 5.5): two turns, a server restart,POST /api/session/{id}/forkwith{}(boundarythrough, like the maintainer's). The fork spawned with--resume <parent> --fork-session, wrote 29 tokens to the prompt cache against 21,163 for the replayed fork, and answered with both codewords from before the restart.test/fork-from-checkpoint.test.ts: the fork after a simulated restart (with a noted reply), the parent continuing its own session, and the refusals (earlier message, gone transcript,forkFromCheckpoint: false,resumeAfterRestart: false). Controls with the branch off and with the filtered prompt both fail.npm run typecheck,npm test(2,325 pass),npm run build.Not covered
A fork from an earlier message after a restart still replays: the record keeps no checkpoint to cut at. Same snapshot caveat as
forkFromCheckpoint: the fork answers under the system prompt the parent first ran with.