Claude Code API Error 400 on tool_use: what to do

Claude Code's API Error 400 about tool use, an orphaned tool result or tool use concurrency means the saved conversation has a tool call and its result out of step, so every request carrying it is refused. Update Claude Code, run /rewind to before the broken turn, or start a new conversation from an export.

Contents

A Claude Code API Error 400 that names tool_use, tool_result or "tool use concurrency issues" means the saved conversation has a tool call and its result out of step. The API refuses any request that carries that history, so every new message fails the same way. Run /rewind, step back to before the broken turn, and carry on from there.

What the error says#

Anthropic's Claude Code error reference files these messages under one heading, "Tool use or thinking block mismatch":

text
API Error: 400 due to tool use concurrency issues. Run /rewind to recover the conversation.
API Error: 400 orphaned tool_result in conversation history. Run /rewind to recover the conversation.
API Error: 400 duplicate tool_use ID in conversation history. Run /rewind to recover the conversation.
API Error: 400 ... unexpected `tool_use_id` found in `tool_result` blocks
API Error: 400 ... thinking blocks ... cannot be modified

All of them, in the reference's words, mean "the sequence of tool_use, tool_result, and thinking blocks in history no longer matches what the API expects." The rule they break is in the API's tool-use docs: a tool result must come straight after the tool call it answers, with no message in between. Break that rule and the API answers "tool_use ids were found without tool_result blocks immediately after", the wording older Claude Code versions printed after --resume and /branch went wrong.

Why every message returns 400 now#

Claude Code sends the whole conversation with each request. Once a broken pair is in the history, your next message carries it again and gets the same refusal. Waiting an hour or sending the message again leaves that history as it is, because the request is wrong, not the service. The API calls a 400 an invalid_request_error, "an issue with the format or content of your request" (API errors).

Claude Code's changelog shows how pairs have got out of step before, each a bug since fixed: a tool that aborted mid-response left an unpaired tool_use in the transcript (2.1.218), --resume dropped the results of parallel tool calls (2.1.80), --resume failed on sessions made before v2.1.85 (2.1.86), and /branch made broken forks of sessions that held rewound turns (2.1.122). The error reference adds Opus 4.7 and Opus 4.8 on versions before v2.1.156, during normal tool use. For the "unexpected tool_use_id" form, 2.1.274 stopped the endless retries: Claude Code now repairs the transcript where it can, and otherwise ends the loop with a /rewind hint.

How it differs from 429, 529 and 500#

You see What it means Does waiting help?
400 naming tool_use, tool_result or thinking The conversation's history is malformed No
429 You or your organisation reached a rate or usage limit Yes, until it resets
529 Overloaded The API is temporarily overloaded, usually by traffic from all users Yes, usually minutes
500 Internal server error An unexpected failure inside the API Usually

A 429 has its own fixes in our 429 rate limit guide, and the 529 overloaded guide covers capacity. For 500s and outages, check whether Claude Code is down.

How to fix API Error 400 on tool_use#

  1. Check your version. Run claude --version. If you use Opus 4.7 or 4.8 on a version before v2.1.156, run claude update first: the error reference says /rewind doesn't clear the error there. The other causes above were bugs fixed in later releases, so update on any older version too. Then come back with claude --continue (resuming a session covers --resume and the picker).
  2. Rewind past the broken turn. Run /rewind, or press Esc twice with the prompt empty. Pick the prompt that started the broken turn, usually the one you interrupted or the one Claude was on when it crashed, which can be earlier than the first message that failed. Choose Restore conversation: your files stay as they are, while Restore code and conversation also reverts the file edits Claude made after that point (undoing Claude Code's changes has the Git side). The prompt you picked comes back into the input. Send it, or any prompt, before you quit, because the checkpointing docs say rewound messages can return if you exit before your next prompt.
  3. If rewinding fails, start a new conversation. Run /export broken-session.txt to save the conversation as plain text, then /clear for a conversation with empty context, and ask Claude to read the file before going on. The old session stays in /resume.

Skip /branch here. Per the sessions docs, it copies the conversation history up to the point you run it, broken turn included.

How Shuriken handles it#

Shuriken runs Claude Code chats on your own computers, and it reads these tool-use 400s as a problem in the chat, not the account. It doesn't retry the turn and doesn't move the chat to another of your accounts, because another account would send the same history and get the same answer. Shuriken doesn't patch Claude Code's saved history either, so the way out is the one above, as menu items.

Revert the chat and files to here, in the menu on one of your messages, takes the Claude Code session and the agent's file changes back to before that message, like /rewind's Restore code and conversation, and puts your message back in the composer. Or open Fork chat from here under a reply from before the break and pick Fork as a new chat. That opens a new chat with the conversation up to that reply attached as text, so your first message there starts a fresh Claude Code session without any raw tool blocks, broken or not. The original chat stays as it was. We wrote up forking from a reply and merging back separately.

If you'd like that fork one click away, download Shuriken.

Sources

  1. Error reference: Tool use or thinking block mismatch (Claude Code docs) (accessed 24 October 2026)
  2. Checkpointing: Rewind and summarize (Claude Code docs) (accessed 24 October 2026)
  3. Manage sessions: Branch a session, Export and locate session data (Claude Code docs) (accessed 24 October 2026)
  4. Commands: /clear, /export, /rewind (Claude Code docs) (accessed 24 October 2026)
  5. Claude Code changelog (accessed 24 October 2026)
  6. Handle tool calls: formatting requirements (Claude API docs) (accessed 24 October 2026)
  7. Claude API errors: HTTP errors (Claude API docs) (accessed 24 October 2026)

Frequently asked questions

Why does every message fail after API Error 400 tool_use?

Claude Code sends the whole conversation with each request, so the broken tool call goes out again with every new message and gets the same 400. Waiting or resending doesn't change the history; /rewind does.

Does /branch fix a session with orphaned tool_result errors?

No. /branch copies the conversation history up to the point you run it, so the broken turn comes along. Rewind first, or start a new conversation with /clear.

Will switching to another Claude account or API key fix it?

No. This 400 is about the content of the request, and another account sends the same history. Unlike a 429, it isn't a limit.

Do I lose my code changes when I run /rewind?

Not unless you ask for it. Restore conversation rewinds only the chat and keeps your files as they are; Restore code and conversation also reverts the file edits Claude made after that point.

Which Claude Code version fixed the tool use concurrency error?

There isn't one fix. Anthropic's error reference says versions before v2.1.156 can trigger it with Opus 4.7 or 4.8, and the changelog lists several other causes fixed in later releases, so run claude update.

Free tools