Unrecoverable session after dropped tool_result — rewind/restore/summarize all fail
When a tool_result is dropped mid-conversation, the session enters a permanently unrecoverable state. All built-in recovery mechanisms fail with the same 400 error.
What happened
- A Bash tool call (
git log --oneline | wc -l) executed but returned(No output)— the tool_result appears to have been dropped or malformed - Every subsequent message fails:
API Error: 400 due to tool use concurrency issues /rewindoffers three options: Restore conversation, Summarize from here, Never mind- All three fail with the same 400 error
- The session is permanently unusable — no recovery path works
Root cause
The Anthropic API requires every tool_use block to have a matching tool_result. When a result is dropped, the conversation history becomes structurally invalid. The recovery mechanisms (rewind, restore, summarize) reconstruct the API conversation from the same broken history, reproducing the invalid tool_use/tool_result sequence.
Even amputating 200+ entries from the session JSONL does not fix it, suggesting the broken pair may be embedded in compacted/summarized history that amputation cannot reach.
Expected behavior
At minimum one of these should work:
/rewind"Restore conversation" should inject a synthetic tool_result for any orphaned tool_use blocks/rewind"Summarize from here" should discard the raw history and start fresh from a summary, skipping broken tool pairs- Claude Code should detect orphaned tool_use blocks before sending to the API and auto-repair them
Impact
- Session is permanently dead — $50+ of context and work history lost
- All commits were on disk (no code lost), but session continuity is destroyed
- Related issues: #20555, #37452, #21321 — but those don't address the recovery failure
Environment
- Claude Code v2.1.84
- macOS
- Model: Opus 4.6
Showing cached comments. Read the full discussion on GitHub ↗
11 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
We built a workaround for this in contextspectre v0.46.0:
It scans the session JSONL for
tool_useblocks without matchingtool_resultentries and injects synthetic results to make the conversation structurally valid again. Also runs automatically as part ofcontextspectre launchpre-flight.The root fix still belongs in Claude Code —
/rewindshould be able to repair orphaned tool_use blocks instead of replaying the same broken history.This is not a duplicate of the linked issues. #31328, #8484, and #37452 report the 400 error itself. This issue reports that all recovery mechanisms also fail — /rewind "Restore conversation", "Summarize from here", and "Never mind" all reproduce the same 400 because they reconstruct from the same broken history.
The root cause is specific: a dropped
tool_resultcreates a structurally invalid conversation that no existing recovery path can repair. The fix is to inject a synthetictool_resultfor orphanedtool_useblocks before replaying the history.This is a clear regression in version 2.1.85. Downgrading to 2.1.84 (https://code.claude.com/docs/en/setup#advanced-installation-options) works with the same resumed conversation. It's reproducible in multiple conversations that were working fine in 2.1.84 and now fail with this error in 2.1.85 once resumed. I do not see any mismatched tool_use/tool_results in my context either, using some "repair" tools to check them.
Adding another reproduction path:
/resumetriggers the 400 error on the very first message./resumed the conversationAPI Error: 400 due to tool use concurrency issues/rewinddid nothing — the corruption is baked into the reconstructed history from/resume, not in a rewindable turn.Platform: Linux (Arch), CLI terminal.
@ashwin-ant
One more reproduction path (Opus):
Agent:function. I suppose this is a sub-agent tool call?Not respondingerror.If the model instead does the operation itself instead of launching a sub-agent, it works fine.
A
PostToolUsehook can detect and log potential dropped results before they corrupt the session:For proactive session checkpointing (to recover from corruption):
If the session does become unrecoverable, resume from a checkpoint with
claude --resumeor start a new session withclaude -p "Continue from checkpoint: $(cat /tmp/cc-checkpoint-*.txt | tail -20)"Cozempic v1.6.11's doctor command diagnoses and repairs this:
cozempic doctor --fixdetects orphaned tool_result blocks and repairs them. The executor also hasfix_orphaned_tool_results()that runs automatically after every treatment. Sibling tool_use protection prevents the orphaning in the first place.pip install cozempic && cozempic initDropped tool_results making the session unrecoverable is exactly the kind of corruption cozempic's doctor can detect and fix. The orphaned-tool-results check finds these dangling entries and the executor repairs them so the session becomes usable again.
pip install cozempic && cozempic doctorhttps://github.com/Ruya-AI/cozempic — happy to hear how it goes.Closing for now — inactive for too long. Please open a new issue if this is still relevant.