Claude Code · Requests and models
API Error: 400 due to tool use concurrency issues
“API Error: 400 due to tool use concurrency issues” means the conversation history got out of order. Rewind to a checkpoint and update Claude Code to recover.
Message
The exact error
API Error: 400 due to tool use concurrency issues. Run /rewind to recover the conversation.Also appears as:
- Orphaned result
- API Error: 400 orphaned tool_result in conversation history. Run /rewind to recover the conversation.
- Duplicate ID
- API Error: 400 duplicate tool_use ID in conversation history. Run /rewind to recover the conversation.
- Raw API wording
- API Error: 400 ... unexpected `tool_use_id` found in `tool_result` blocks
- Thinking blocks
- API Error: 400 ... thinking blocks ... cannot be modified
Meaning
What does “400 due to tool use concurrency issues” mean?
Every time Claude calls a tool, the conversation records a tool_use block, and the next message must carry the matching tool_result with the same ID. Thinking blocks must also come back exactly as the model wrote them. The API checks that pairing on every request. When a result is missing, duplicated, out of order or attached to an ID that doesn’t exist, the API rejects the whole request with a 400, and because the broken history is re-sent each turn, every later message fails the same way. Anthropic’s error reference groups all these wordings as one error: the sequence of tool_use, tool_result and thinking blocks no longer matches what the API expects.
Causes
Why does the conversation history break?
- A bug in older Claude Code versions: on Opus 4.7 and 4.8, versions before v2.1.156 could trigger it during normal tool use
- A history in which a tool call lost its result, gained a second one or points at an ID that doesn’t exist; in one public GitHub report (#37452) a long session’s history broke when compaction rebuilt it, and neither
/rewindnor/compactcould recover it - Thinking blocks that were changed before being sent back, which the API refuses
- Possibly a proxy or gateway in
ANTHROPIC_BASE_URLthat rewrites tool or thinking blocks (worth ruling out if you use one)
Fix
How do I recover the conversation?
Update Claude Code first
If you use Opus 4.7 or Opus 4.8, run
claude updatebefore anything else. Anthropic notes that versions before v2.1.156 can cause this error during normal tool use, and that/rewinddoesn’t clear it on those versions.Terminal claude update claude --versionRewind to before the broken turn
Run
/rewind, or press Esc twice with an empty prompt, and pick the message before the error. Choose Restore conversation to keep the files as they are now, or Restore code and conversation to undo Claude’s edits too. The prompt you picked comes back in the input box so you can resend it.If rewinding doesn’t help, start a clean conversation
Run
/clear. The old conversation stays on disk and in/resume, but resuming it brings back the broken history. Ask Claude for a short summary of where you were before you clear, or keep the plan in CLAUDE.md, which is loaded again in the new conversation.Check any gateway or proxy
If
ANTHROPIC_BASE_URLpoints at a gateway or router, try once without it. A gateway must pass tool and thinking blocks through unchanged, in order.
Explained
Will /rewind undo my code changes?
Only if you ask it to. The rewind menu offers Restore conversation, which steps the conversation back while keeping your current files, and Restore code and conversation, which also reverts Claude’s edits. Checkpoints cover edits made through Claude’s file tools only: changes made by shell commands, such as rm or mv, aren’t tracked and aren’t undone.
Heavy parallel work makes the history longer and more complex, which is one reason to hand noisy jobs to a subagent: it returns one summary instead of dozens of tool exchanges. The token usage guide covers other ways to keep sessions short.
FAQ
Questions people ask
Why does /rewind do nothing when the error tells me to run it?
Yes, /rewind is a built-in command on current versions, and pressing Esc twice with an empty prompt opens the same menu. Some older versions printed the hint before the command existed. Update with claude update; if the menu still doesn’t open, run /clear to start a new conversation.
Why does the error repeat on every message?
Claude Code sends the whole conversation history with each request, so the broken tool_use and tool_result pair is re-sent every time and the API rejects it again. Retrying or rephrasing can’t help. Step back past the broken turn with /rewind, or start a new conversation with /clear.
Is this error caused by running tools in parallel?
Not by itself. Claude Code runs tool calls in parallel by design, and the API accepts that. The error appears only when the recorded history no longer pairs each call with its result, which older versions could produce. Updating Claude Code fixes the known bugs; rewinding fixes a history that is already broken.
Do I lose my work if I run /clear?
No. Files on disk stay as they are, and the old conversation is kept and listed in /resume. You lose only the conversation’s context in the new session, so ask Claude to summarise the current plan first and paste that summary into your next message.
Related
Related errors
Keep exploring