Skip to content

Fix: skip records copied by Qwen Code /branch - #194

Open
aayank13 wants to merge 1 commit into
mainfrom
fix/qwen-branch-copies
Open

aayank13 wants to merge 1 commit into
mainfrom
fix/qwen-branch-copies

Conversation

@aayank13

Copy link
Copy Markdown
Owner

Fixes #159

/branch in Qwen Code writes a new session file that starts with a copy of the conversation so far, each copied record tagged with forkedFrom. The parser read those copies as if they were new work, so the branch replayed the parent's prompts, edits and passing checks and was extracted as a second session. Backfilling a session that fixed an off-by-one in paginate next to a branch of it that only asked a follow-up question gave "1 new procedure, 1 confirmed": the same fix was counted twice, once under each session id. If the copies keep the parent's sessionId, the branch also took the parent's id, because the builder keeps the first id it sees, and the two transcripts fought over one session's progress.

Records with forkedFrom now only contribute the session id and the working directory, never prompts, tool calls or timestamps, so a branch is learned from its own records only. A copied record's session id is ignored when it equals the forkedFrom session, which covers both cases: current Qwen Code rewrites the copies to the branch's id, so even a branch with nothing new yet gets its own (empty) trace instead of a parse error, and copies that kept the parent's id can no longer claim the branch.

The copies still take part in rebuilding the live chain, since the branch's first own record points at the last copied one, so nothing changes there.

I reproduced it end to end with a scratch TRODDEN_HOME and Qwen Code directory holding a parent transcript and a branch of it laid out the way forkSession writes one. Before the fix, trodden backfill --agent qwen extracted the fix task under both sessions and confirmed the procedure with the branch, and with the parent's id kept on the copies both transcripts were stored as the parent's session. After it, the fix is extracted once under the parent, the branch only has its own follow-up, each transcript keeps its own session, and a branch with no records of its own backfills cleanly. A new parser test covers the copied records being skipped, the empty branch, a branch with its own prompt, and copies that kept the parent's id; it fails without the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Qwen Code /branch copies are learned twice

1 participant