Failed requests fork a new conversation branch per retry, leaving dead tips in the transcript
What happened
When an API request fails mid-session, Claude Code appends the retry as a new sibling branch off the same parent node rather than retrying in place. Each subsequent retry forks again, so a session that fails repeatedly accumulates many dead branches.
During a period of repeated ECONNRESET failures I ended up with sessions containing 8, 10, 12, 13, and in one case 20 leaf tips, where a healthy session has 1.
Why it matters
- It looks like transcript corruption but isn't. I audited the affected
.jsonlfiles: every line was valid JSON, everytool_usehad a matchingtool_result, there were no duplicate UUIDs and no danglingparentUuidpointers. The files were structurally perfect. The only anomaly was the branch fan-out, which made them appear damaged and sent me down a long debugging path.
- It compounds the original failure. Each fork appends more records to a file that is already too large to send, so every retry makes the next attempt marginally worse.
--resumecan land on a dead branch. In one session the recorded resume leaf pointed at asystem/local_commandrecord for a cancelled resume, i.e. the tail of a branch that had never succeeded.
Reproduction
- Grow a session large enough that requests start failing (or otherwise induce a transport failure).
- Retry a few times from the same point.
- Inspect the session
.jsonl: group records byparentUuidand count nodes with no message-type descendants.
Each retry adds a leaf rather than replacing one.
Note on scope
This is not universal. Some sessions that failed several times retried linearly and still show a single tip, so the forking appears conditional — possibly on whether the failure occurs before or after the user message is committed. I did not isolate the trigger.
Expected
A failed request should retry in place, or the dead branch should be pruned, so the transcript keeps one live tip.
Environment
- Claude Code 2.1.220
- macOS (darwin 25.1.0)
- Model: Opus, 1M context