[BUG] `/resume` writes entries to wrong JSONL file — single-process, no concurrency required
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
After using /resume to switch between sessions within the TUI, new messages are appended to the previously active session's JSONL file instead of the newly resumed session's file. The entries carry the correct sessionId but land in the wrong file, corrupting the target session and orphaning the new conversation data. Depending on the exact sequence of resumes, this can result in some or all conversation history from one or both of the sessions to become inaccessible (to both Claude and the user) without manually repairing the jsonl files.
This is a single-process, single-terminal bug. No concurrent sessions, /compact, /rename, nor /fork required -- though those do seem to accentuate or compound the issue.
What Should Happen?
After /resume switches to a different session, all new entries should be written to that session's own JSONL file; chat history for both sessions should be preserved and should not cross-contaminate.
Error Messages/Logs
Condensed view of a contaminated file after the repro (7a0de4b4 is the victim, 8eb76498 is the resumed session whose entries land in the wrong file):
line type sessionId uuid parentUuid
1 file-history-snapshot None None None # own snapshot
2 user 7a0de4b4 920291fa... None # own message
3 assistant 7a0de4b4 9f5dcfbe... 920291fa... # own message
4 file-history-snapshot None None None # own snapshot
5 user 7a0de4b4 38a1f5b4... 9f5dcfbe... # own message
6 assistant 7a0de4b4 1c7008af... 38a1f5b4... # own message
7 file-history-snapshot None None None # references 8eb76498's message!
8 file-history-snapshot None None None # references 8eb76498's message!
9 user 8eb76498 1217cf63... c8f268f1... # WRONG FILE
10 assistant 8eb76498 693d0391... 1217cf63... # WRONG FILE
Lines 9-10 have sessionId=8eb76498 but are in 7a0de4b4's file. The parentUuid on line 9 (c8f268f1) only exists in 8eb76498's own file, creating a broken chain.
The file-history-snapshot entries at lines 7-8 have messageId fields referencing UUIDs from 8eb76498's session — the write target shifted to the wrong file at the snapshot level before the first message entry.
Full logs (note an additional cancelled /resume created more "stub" conversations with a single "file-history-snapshot" line):
dgealow@Dans-new-P4-MacBook -Users-dgealow-sandbox-5 % ls -ahltr
total 48
drwx------ 17 dgealow staff 544B Mar 4 13:23 ..
-rw------- 1 dgealow staff 1.5K Mar 4 13:23 8eb76498-ba4f-47f8-83b4-a9602ae9907b.jsonl
-rw------- 1 dgealow staff 236B Mar 4 13:24 4c78bf72-9250-4593-ac90-e6bd17c44f20.jsonl
-rw------- 1 dgealow staff 5.9K Mar 4 13:52 7a0de4b4-d171-48a3-ba55-ab417b1ce741.jsonl
-rw------- 1 dgealow staff 236B Mar 4 13:57 ab22a1a7-4793-4d8a-8829-4d46abd436da.jsonl
drwx------ 7 dgealow staff 224B Mar 4 13:57 .
-rw------- 1 dgealow staff 236B Mar 4 13:57 1ec7ad3f-06e1-4149-b65b-931eaf62f820.jsonl
dgealow@Dans-new-P4-MacBook -Users-dgealow-sandbox-5 % cat 8eb76498-ba4f-47f8-83b4-a9602ae9907b.jsonl
{"type":"file-history-snapshot","messageId":"f644e7de-2d0e-45f4-b645-a00223ed788c","snapshot":{"messageId":"f644e7de-2d0e-45f4-b645-a00223ed788c","trackedFileBackups":{},"timestamp":"2026-03-04T18:23:31.335Z"},"isSnapshotUpdate":false}
{"parentUuid":null,"isSidechain":false,"userType":"external","cwd":"/Users/dgealow/sandbox_5","sessionId":"8eb76498-ba4f-47f8-83b4-a9602ae9907b","version":"2.1.68","gitBranch":"HEAD","type":"user","message":{"role":"user","content":"hello claude"},"uuid":"f644e7de-2d0e-45f4-b645-a00223ed788c","timestamp":"2026-03-04T18:23:31.334Z","permissionMode":"default"}
{"parentUuid":"f644e7de-2d0e-45f4-b645-a00223ed788c","isSidechain":false,"userType":"external","cwd":"/Users/dgealow/sandbox_5","sessionId":"8eb76498-ba4f-47f8-83b4-a9602ae9907b","version":"2.1.68","gitBranch":"HEAD","message":{"model":"claude-opus-4-6","id":"msg_01DofLVGN4CmyzqgmwuQWc8y","type":"message","role":"assistant","content":[{"type":"text","text":"\n\nHello! How can I help you today?"}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":3,"cache_creation_input_tokens":15036,"cache_read_input_tokens":10426,"output_tokens":13,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":15036,"ephemeral_5m_input_tokens":0},"inference_geo":"","iterations":[],"speed":"standard"}},"requestId":"req_011CYiWMfSDSDFKJRqsLYYL1","type":"assistant","uuid":"c8f268f1-9c4c-48b7-b5fc-c53c17df8ba6","timestamp":"2026-03-04T18:23:33.868Z"}
dgealow@Dans-new-P4-MacBook -Users-dgealow-sandbox-5 % cat 4c78bf72-9250-4593-ac90-e6bd17c44f20.jsonl
{"type":"file-history-snapshot","messageId":"920291fa-8cd9-405b-939c-b5ecdfe14656","snapshot":{"messageId":"920291fa-8cd9-405b-939c-b5ecdfe14656","trackedFileBackups":{},"timestamp":"2026-03-04T18:24:06.871Z"},"isSnapshotUpdate":false}
dgealow@Dans-new-P4-MacBook -Users-dgealow-sandbox-5 % cat 7a0de4b4-d171-48a3-ba55-ab417b1ce741.jsonl
{"type":"file-history-snapshot","messageId":"920291fa-8cd9-405b-939c-b5ecdfe14656","snapshot":{"messageId":"920291fa-8cd9-405b-939c-b5ecdfe14656","trackedFileBackups":{},"timestamp":"2026-03-04T18:24:06.871Z"},"isSnapshotUpdate":false}
{"parentUuid":null,"isSidechain":false,"userType":"external","cwd":"/Users/dgealow/sandbox_5","sessionId":"7a0de4b4-d171-48a3-ba55-ab417b1ce741","version":"2.1.68","gitBranch":"HEAD","type":"user","message":{"role":"user","content":"HI CLAUDE!!!"},"uuid":"920291fa-8cd9-405b-939c-b5ecdfe14656","timestamp":"2026-03-04T18:24:06.870Z","permissionMode":"default"}
{"parentUuid":"920291fa-8cd9-405b-939c-b5ecdfe14656","isSidechain":false,"userType":"external","cwd":"/Users/dgealow/sandbox_5","sessionId":"7a0de4b4-d171-48a3-ba55-ab417b1ce741","version":"2.1.68","gitBranch":"HEAD","message":{"model":"claude-opus-4-6","id":"msg_01RZfVsPhhpyz81dzMga6HGZ","type":"message","role":"assistant","content":[{"type":"text","text":"HI! How can I help you today?"}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":3,"cache_creation_input_tokens":14422,"cache_read_input_tokens":10426,"output_tokens":13,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":14422,"ephemeral_5m_input_tokens":0},"inference_geo":"","iterations":[],"speed":"standard"}},"requestId":"req_011CYiWQHN15CerPoJeiGrwG","type":"assistant","uuid":"9f5dcfbe-7f40-4343-8aa4-6f7987a26ef4","timestamp":"2026-03-04T18:24:09.340Z"}
{"type":"file-history-snapshot","messageId":"38a1f5b4-1844-4e5b-83a7-e8e3b939c267","snapshot":{"messageId":"38a1f5b4-1844-4e5b-83a7-e8e3b939c267","trackedFileBackups":{},"timestamp":"2026-03-04T18:24:46.218Z"},"isSnapshotUpdate":false}
{"parentUuid":"9f5dcfbe-7f40-4343-8aa4-6f7987a26ef4","isSidechain":false,"userType":"external","cwd":"/Users/dgealow/sandbox_5","sessionId":"7a0de4b4-d171-48a3-ba55-ab417b1ce741","version":"2.1.68","gitBranch":"HEAD","type":"user","message":{"role":"user","content":"JUST CHATTING"},"uuid":"38a1f5b4-1844-4e5b-83a7-e8e3b939c267","timestamp":"2026-03-04T18:24:46.217Z","permissionMode":"default"}
{"parentUuid":"38a1f5b4-1844-4e5b-83a7-e8e3b939c267","isSidechain":false,"userType":"external","cwd":"/Users/dgealow/sandbox_5","sessionId":"7a0de4b4-d171-48a3-ba55-ab417b1ce741","version":"2.1.68","gitBranch":"HEAD","message":{"model":"claude-opus-4-6","id":"msg_017yb4FJ9T7ht9yT41PofYvH","type":"message","role":"assistant","content":[{"type":"text","text":"\n\nNice! Well, I'm here whenever you need anything. Feel free to throw a coding task my way or just say hi anytime."}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":3,"cache_creation_input_tokens":15061,"cache_read_input_tokens":10426,"output_tokens":32,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":15061,"ephemeral_5m_input_tokens":0},"inference_geo":"","iterations":[],"speed":"standard"}},"requestId":"req_011CYiWTBxeF38WtCuvYpcxW","type":"assistant","uuid":"1c7008af-994a-4d0b-a809-050d7fe4e1e6","timestamp":"2026-03-04T18:24:49.963Z"}
{"type":"file-history-snapshot","messageId":"f644e7de-2d0e-45f4-b645-a00223ed788c","snapshot":{"messageId":"f644e7de-2d0e-45f4-b645-a00223ed788c","trackedFileBackups":{},"timestamp":"2026-03-04T18:23:31.335Z"},"isSnapshotUpdate":false}
{"type":"file-history-snapshot","messageId":"1217cf63-72a8-428b-aa63-f8c8798416ec","snapshot":{"messageId":"1217cf63-72a8-428b-aa63-f8c8798416ec","trackedFileBackups":{},"timestamp":"2026-03-04T18:25:13.161Z"},"isSnapshotUpdate":false}
{"parentUuid":"c8f268f1-9c4c-48b7-b5fc-c53c17df8ba6","isSidechain":false,"userType":"external","cwd":"/Users/dgealow/sandbox_5","sessionId":"8eb76498-ba4f-47f8-83b4-a9602ae9907b","version":"2.1.68","gitBranch":"HEAD","type":"user","message":{"role":"user","content":"just chatting"},"uuid":"1217cf63-72a8-428b-aa63-f8c8798416ec","timestamp":"2026-03-04T18:25:13.160Z","permissionMode":"default"}
{"parentUuid":"1217cf63-72a8-428b-aa63-f8c8798416ec","isSidechain":false,"userType":"external","cwd":"/Users/dgealow/sandbox_5","sessionId":"8eb76498-ba4f-47f8-83b4-a9602ae9907b","version":"2.1.68","gitBranch":"HEAD","message":{"model":"claude-opus-4-6","id":"msg_01SDgQga5UknRYjLFJ87Fd94","type":"message","role":"assistant","content":[{"type":"text","text":"\n\nHey, nice to chat! I'm here if you need anything — coding, debugging, exploring a codebase, or just bouncing ideas around. What's on your mind?"}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":3,"cache_creation_input_tokens":14243,"cache_read_input_tokens":10426,"output_tokens":41,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":14243,"ephemeral_5m_input_tokens":0},"inference_geo":"","iterations":[],"speed":"standard"}},"requestId":"req_011CYiWVB2Pg8gFUQ17eEg6y","type":"assistant","uuid":"693d0391-afba-40e1-bb70-e2136c1c6560","timestamp":"2026-03-04T18:25:16.932Z"}
{"parentUuid":"693d0391-afba-40e1-bb70-e2136c1c6560","isSidechain":false,"userType":"external","cwd":"/Users/dgealow/sandbox_5","sessionId":"8eb76498-ba4f-47f8-83b4-a9602ae9907b","version":"2.1.68","gitBranch":"HEAD","type":"system","subtype":"local_command","content":"<command-name>/resume</command-name>\n <command-message>resume</command-message>\n <command-args></command-args>","level":"info","timestamp":"2026-03-04T18:52:23.718Z","uuid":"2bad721b-93de-4d64-9ef3-f2b0652740e2","isMeta":false}
{"parentUuid":"2bad721b-93de-4d64-9ef3-f2b0652740e2","isSidechain":false,"userType":"external","cwd":"/Users/dgealow/sandbox_5","sessionId":"8eb76498-ba4f-47f8-83b4-a9602ae9907b","version":"2.1.68","gitBranch":"HEAD","type":"system","subtype":"local_command","content":"<local-command-stdout>Resume cancelled</local-command-stdout>","level":"info","timestamp":"2026-03-04T18:52:23.718Z","uuid":"39910fb4-aa45-4592-9419-e2c3890299b4","isMeta":false}
dgealow@Dans-new-P4-MacBook -Users-dgealow-sandbox-5 % cat ab22a1a7-4793-4d8a-8829-4d46abd436da.jsonl
{"type":"file-history-snapshot","messageId":"f644e7de-2d0e-45f4-b645-a00223ed788c","snapshot":{"messageId":"f644e7de-2d0e-45f4-b645-a00223ed788c","trackedFileBackups":{},"timestamp":"2026-03-04T18:23:31.335Z"},"isSnapshotUpdate":false}
dgealow@Dans-new-P4-MacBook -Users-dgealow-sandbox-5 % cat 1ec7ad3f-06e1-4149-b65b-931eaf62f820.jsonl
{"type":"file-history-snapshot","messageId":"1217cf63-72a8-428b-aa63-f8c8798416ec","snapshot":{"messageId":"1217cf63-72a8-428b-aa63-f8c8798416ec","trackedFileBackups":{},"timestamp":"2026-03-04T18:25:13.161Z"},"isSnapshotUpdate":false}
Steps to Reproduce
- Create a fresh project directory
- Run
claude, send at least one message, exit - Run
claudeagain (new session), send at least one message, exit - Run
claude --resume, pick either session - Send a message (goes to the correct file)
/resumeand pick the other session- Send a message — it goes to the wrong file
Observed Behavior
After step 6-7:
- The message sent in step 7 appears in the step-4 session's JSONL file, not the resumed session's file
- The entry has the correct
sessionId(the resumed session) but is appended to the wrong file file-history-snapshotentries referencing the resumed session's messages leak into the wrong file before the message entries do — snapshots are the first thing to contaminate--resume(step 4) creates a stub.jsonlfile containing a singlefile-history-snapshotas a side effect
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.68 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Relationship to Existing Issues
- #26964 (canonical cross-session contamination): Same symptom, but that issue describes concurrent multi-process contamination. This repro is single-process, sequential, and requires only
/resume. - #27202 (
/renameapplies title to wrong session): A downstream consequence — once entries are in the wrong file, the title scanner picks up the wrongcustom-title. - #29342 (session transcript writes to wrong JSONL file): Closed as dup of #26964. Describes the same write-target confusion but couldn't identify the trigger.
This may share a root cause with #26964 (the file write target / file descriptor not being updated), but the trigger mechanism is distinct and much easier to reproduce.
Diagnosis/workaround tools
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗