Repository navigation
Description
Preflight Checklist
- I have searched existing issues and this hasn't been reported yet
- This is a single bug report (please file separate reports for different bugs)
- I am using the latest version of Claude Code
Environment
- Claude Code 2.1.283 (reproduced with the CLI); first hit in the VS Code extension 2.1.280 → 2.1.282
- VS Code 1.134.0, Linux (Arch)
Summary
Nothing prevents two processes from resuming the same session at once. Each one appends
to the same ~/.claude/projects/<project>/<session>.jsonl, so the conversation forks
into two branches under one parent. The next resume follows the branch written last and
drops the other one from the conversation without any warning. The records are still in
the file, so the work can be recovered by hand, but the UI shows the session cut back to
the fork point.
Steps to reproduce
The attached repro.sh does this with claude -p in a temporary directory, using Haiku
and a few turns:
- Create a session, then resume it in process A with a multi-step turn (three
echo
tool calls). - Two seconds later, while A is mid-turn, resume the same session in process B with a
turn that finishes after A's. - After both exit, resume the session a third time and ask what it has seen.
Actual
A said: A-DONE
B said: B-DONE
C sees: B1
B2
fork under attachment f2b6e34d:
[{"type": "thinking", ... <- A's branch
[{"type": "text", "text": "No response requested."}] <- B's branch
Both A and B report success. The third resume sees only B's work, and A's A1 A2 A3 are
gone from its conversation.
In an earlier run of the same scenario, B loaded the session while A had a tool_use
waiting for its result. B wrote a result of its own for that call, [Tool call interrupted: the session ended], as a sibling of A's real result. So B does not just
branch: it also treats A's live turn as dead.
Expected
At least one of the following:
- Refuse, or warn, when resuming a session that another live process is writing
(a lock file or heartbeat next to the transcript), with an option to open it read-only
or to fork it into a new session ID. - In the VS Code extension, focus the tab or window that already has the session open
instead of starting a second process. Today this check only covers tabs in the same
window. - When a transcript has two branches that were written at the same time, do not pick one
silently: say so on resume, or offer the branches to choose from.
How it was hit in practice
In the VS Code extension, a session was open and running in one tab. The same session
was then opened again from a list of all sessions (a third-party session-list extension,
which calls claude-vscode.editor.open with the session ID). Eleven seconds after the
first process's last record, a second process resumed with Continue from where you left off. Over the next four hours the second process wrote about 320 records on its branch.
The first process's branch held 27. After the extension updated to 2.1.282, the session
reopened on the 27-record branch. The session then looked trimmed back to the morning
fork, with four hours of work gone. It was recovered by hand from the .jsonl file.
A scan of about 170 local transcripts found three more forks with branches written in
overlapping periods. One of them came from a terminal claude process writing to a
session that was open in VS Code at the same time, so the problem does not need the
third-party extension.
Attachment
repro.sh: self-contained. It needsclaudeon PATH andpython3, and makes about
four short Haiku calls.
Claude Model
Opus 5.5
Is this a regression?
Probably not.
Last Working Version
No response
Claude Code Version
2.1.283 (Claude Code)
Platform
Anthropic API
Operating System
Other Linux
Terminal/Shell
Other
Additional Information
No response
Activity
matiasbourgeois commentedon Oct 4, 2026
Same root cause, hit today from the VS Code extension (2.1.283, Windows 11, Remote Control on), with two side effects that made it worse than a forked transcript:
What happened
claude.exeprocess kept running headless and kept writing to the.jsonl.artifact-watch-lifecyclenotice "Another live session of this same conversation is running", so the harness knew.Side effects
.jsonlfrom a third session and talk to it over cross-session messages.Prompt is too long. The conversation was very long; the second process loaded it whole and never auto-compacted. ThePrompt is too longline also got written into the shared transcript, interleaved with the live process's turn.C:\Users\BOURGE~1\...), and the prompt went to the closed tab, where nobody could answer it. The publish failed and the artifact stayed empty, with no visible error anywhere.Expected
Prompt is too longon every message.adapter: one Host per Session
ZioFabry commentedon Oct 26, 2026
Still reproducible on 2.1.310 (Linux,
claude -p, model haiku), with a minimal repro:claude -p --session-id <uuid> "Reply only: ROOT"claude -p --resume <uuid> "Remember the codeword MANGO. First write the numbers from 1 to 3000, one per line, then write MANGO-SAVED."and, a few seconds later,claude -p --resume <uuid> "Remember the codeword PEAR. Reply only: PEAR-SAVED". PEAR finishes first, MANGO last.claude -p --resume <uuid> "Which codewords did I ask you to remember? List all of them, or NONE."→ MANGO only. PEAR's turn is silently gone.In a second run the call that started first but finished last won; the result follows the last writer, not the start order. No warning at step 2 or 3.
Real-world impact: a supervisor that relaunched sessions after a container restart resumed a session that a stale second process had kept appending to (thousands of repeated local-command lines). The resume picked the stale branch, and after auto-compaction on that branch the active one was no longer reachable by any
--resume.Asks: refuse or warn when resuming a session held by a live process (offer
--fork-session, as the VS Code extension's "still open somewhere else" notice does; see #69364), and pick the leaf by an explicit pointer or the latest user turn rather than the last line written.asunghong commentedon Nov 2, 2026
Still reproducible on 2.1.316 (macOS arm64) with two interactive terminals, no
-p.claude --resumeopened X with no warning. As far as I can tell, the existing refusal ("is running in the background") only applies when the other process is a background session, so two interactive terminals are never stopped. This is the gap described in --continue / --resume doesn't check the existing live-session registry before re-opening a session already running in another process #69364..jsonlgrew two branches, with thousands of rows on each side of the fork.--resume X. A had written last, by 39 seconds, so B came back on A's branch. B's day of work dropped out of the conversation with no warning. The rows were still in the file.--resume Xalso opened A's branch and added another small branch to it. I found no interactive way to choose a branch;--resume-session-atis for print mode.How often: 4 of my 58 remaining transcripts have two branches written in the same period (counting only branches with 20 or more user and assistant rows). The oldest is from September.
What recovered the lost branch: writing a new
<uuid>.jsonlwith every row except the other branch's subtree, keeping side rows because they hold parallel tool calls, and withsessionIdrewritten.--resume <uuid>then continued from the last row of the lost branch.One note for a fix: with several config dirs sharing
projects/, eachCLAUDE_CONFIG_DIRhas its ownsessions/registry, so a check needs to look across them.