Repository navigation
Carry a moved session into its new directory - #189
Merged
Merged
Conversation
opencode 2 moves a session between directories (session_move into a lane's worktree), and the cwd is the first segment of the session key, so the next turn replayed the whole thread, where a guard hook could refuse it by size. Measured on Claude Code 2.1.322: --resume from another directory keeps the conversation and the model sees the new directory, but without a copy the CLI keeps appending under the old directory's name. The sibling lookup now lets the cwd differ, the transcript is copied under the new directory before the resume, and a step answering the call that moved the session finishes on the old directory's child (h #g317).
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 session opencode moved to another working directory replayed its whole thread as text on the next turn (h #g317).
What happened
On 2026-11-14 a lane's Code Mode
executemoved its session into a fresh worktree (session_move). The session's directory is the spawn's cwd and the first segment of the session key, so the next step landed on a key nothing had answered and replayed the history into a new Claude session. agent-guard refused that replay by size ("the prompt exceeds the assignment-probe scan cap"), which v0.73.4 now reports asprompt blocked(h #g314). This PR removes the replay itself.Measured (Claude Code 2.1.322, Haiku 5.5, two scratch repos)
--resume <id>from another directory continues the conversation, and the model reports the NEW directory: the environment block is not snapshotted.Change
modelSiblingSignaturelets the cwd differ, like the model, effort, spawn settings and account. The shareddefaultaffinity keeps its directory.findSiblingResumePointchecks the transcript under the sibling's own cwd and returnssiblingCwd. The caller copies it withcarryTranscriptToAccount's newsourceCwds(same never-overwrite and longest-copy rules), stops the old key's child, and transfers the session.conversationIdentityignores the cwd, so the step answering the call that moved the session finishes on the child parked in it, in the old directory (h #g271's routing). The next turn carries.resumeAfterRestart: falsestill replays a move, as it does a model change.Live check (opencode 2.2.6, scratch
serve, this build)Session in repo A answered a codeword,
POST /api/session/{id}/moveto repo B, next turn: spawned in repo B with--resumeof the same Claude session, answered with the codeword and repo B as its directory, transcript copied (original untouched). Cache on that turn: 38,958 read, 18,292 written, because opencode's forwarded system prompt carries the directory too.Checks
npm run typecheck,npm test(2322 pass),npm run buildtest/session-move.test.ts: realdoStreamturns in two directories of one opencode session, with a fake CLI that resumes only a transcript under its own directory (so the copy is proven). Carried in process and after a restart, another session never carried,resumeAfterRestart: falsereplays. The two carry tests fail with the signature change switched off.test/effort-sessions.test.ts: a step answering a call parked in the old directory finishes on that child (without the routing it never reaches it).test/account-transcript.test.ts:sourceCwds, including moving back.Not measured live: the mid-turn move through Code Mode, and the interactive transport.