Bug Report API Error: 400 `tool_use` ids were found without `tool_result` blocks immediately after...
Bug Description This happens randomly and persists forcing me to restart new Claude Code instance.
Refactor S3_manager according to best practices and @docs/refactoring.md ⎿ Read docs/refactoring.md (1605 lines) ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.5:
tool_useids were found withouttool_resultblocks immediately after: toolu_01FRvEykWmCgrgJ22mvBbKhV. Eachtool_useblock must have a correspondingtool_resultblock in the next message."}}
continue ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.5:
tool_useids were found withouttool_resultblocks immediately after: toolu_01FRvEykWmCgrgJ22mvBbKhV. Eachtool_useblock must have a correspondingtool_resultblock in the next message."}}
UPDATE documentation ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.5:
tool_useids were found withouttool_resultblocks immediately after: toolu_01FRvEykWmCgrgJ22mvBbKhV. Eachtool_useblock must have a correspondingtool_resultblock in the next message."}}
Environment Info
- Platform: macos
- Terminal: pycharm
- Version: 1.0.17
- Feedback ID: 39ad9130-c5ee-477f-bac9-ece2e0554c1e
Errors
[{"error":"AbortError: The operation was aborted\n at abortChildProcess (node:child_process:716:27)\n at onAbortListener (node:child_process:786:7)\n at process.processTicksAndRejections (node:internal/process/task_queues:85:11)","timestamp":"2025-06-10T07:36:15.666Z"},{"error":"MCPContentTooLargeError: MCP tool \"read_file\" response (30206 tokens) exceeds maximum allowed tokens (25000). Please use pagination, filtering, or limit parameters to reduce the response size.\n at is1 (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1376:7798)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async vX2 (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1376:12473)\n at async Object.call (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1376:8729)\n at async iZ5 (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1896:19166)\n at async WK1 (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1896:17752)\n at async cZ5 (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1896:16794)\n at async uZ5 (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1896:16423)\n at async NO (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1896:15452)\n at async NO (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1896:16278)","timestamp":"2025-06-10T07:40:15.927Z"},{"error":"MCPContentTooLargeError: MCP tool \"read_multiple_files\" response (26545 tokens) exceeds maximum allowed tokens (25000). Please use pagination, filtering, or limit parameters to reduce the response size.\n at is1 (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1376:7798)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async vX2 (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1376:12473)\n at async Object.call (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1376:8729)\n at async iZ5 (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1896:19166)\n at async WK1 (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1896:17752)\n at async cZ5 (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1896:16794)\n at async uZ5 (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1896:16423)\n at async NO (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1896:15452)\n at async NO (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1896:16278)","timestamp":"2025-06-10T07:55:01.437Z"},{"error":"MCPContentTooLargeError: MCP tool \"read_file\" response (28285 tokens) exceeds maximum allowed tokens (25000). Please use pagination, filtering, or limit parameters to reduce the response size.\n at is1 (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1376:7798)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async vX2 (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1376:12473)\n at async Object.call (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1376:8729)\n at async iZ5 (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1896:19166)\n at async WK1 (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1896:17752)\n at async cZ5 (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1896:16794)\n at async uZ5 (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1896:16423)\n at async NO (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1896:15452)\n at async NO (file:///Users/davidandrews/.nvm/versions/node/v23.10.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1896:16278)","timestamp":"2025-06-10T07:56:05.926Z"},{"error":"Error: Language not supported while highlighting code, falling back
Note: Error logs were truncated.
I also got this today, never had it before.
● Bash(just bump-patch)
⎿ Error: sh: line 1: jq: command not found
error: Recipe `get-version` failed on line 55 with exit code 127
error: Recipe `bump-patch` failed with exit code 127
● Let me fix the get-version command to not rely on jq:
⎿ Interrupted by user
⎿ Interrupted by user
⎿ Interrupted by user
> actually if we need jq then add it to our nix flake
⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.19: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_0162edssqab1kYwpztdNfXru. Each `tool_use` block must have a
corresponding `tool_result` block in the next message."}}
> actually if we need jq then add it to our nix flake
⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.19: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_0162edssqab1kYwpztdNfXru. Each `tool_use` block must have a
corresponding `tool_result` block in the next message."}}
same here just after I Interrupted it.
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.107: tool_use ids were found without tool_result blocks immediately after: toolu_01KmrrFZotoAEWYjC1yroyu6. Each tool_use block
must have a corresponding tool_result block in the next message."}}
Same. Has anyone found a way to recover from it other than restarting Claude Code?
I get this from time to time as well. You can hit double escape and go to the previous prompt (eliminating some context) and start there again.
We've resolve the root cause for this issue in 1.0.21 (claude update and claude --version). To recover a stuck session hit "esc" twice and rewind back to before the error.
Hello, I'm using version 1.0.24 but same error happened.
API Error: 400 {"type":"error","error":{"type":"
invalid_request_error","message":"messages.242:
`tool_use` ids were found without `tool_result`
blocks immediately after:
toolu_01WdYmA1KgSce5nbUcbTJZz9. Each `tool_use`
block must have a corresponding `tool_result`
block in the next message."}}
same here
Claude Code Status v1.0.25
Error: Error during compaction: Error: API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.27: tool_use ids were found without tool_result blocks immediately
after: toolu_01GCg6SKLPsVVW15sNuJ6jwa. Each tool_use block must have a corresponding tool_result block in the next message."}}
Getting this error with Claude Code v1.0.25 too:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.223: tool_use ids were found without tool_result blocks immediately after:
toolu_011zra4NRpA4xYVjvA4dof9t, toolu_012hVvD4ueHGNKsqDVMzZcMn, toolu_013N1NakAhCnQfVHqdb9d2qn, toolu_014iJS1MNuMPJx76oUTxbfWW, toolu_01AnA7aMdVE4zHxNpGKdKkkm,
toolu_01BCxWTT6ZjfgrK4kLZH3j7k, toolu_01C8R3r9LfjHrnmeg9mnytGx, toolu_01KrY5mzWPFJQq6V4Xeo7FR2, toolu_01P3Ssb9FFnoPmfstk2TnV9X, toolu_01TgLj2ktFpkR43rfoEh11Vv,
toolu_01X38MMqvXBuJkroJmjmv6na, toolu_01XxH41RgMndShaFJnyPoW4p. Each tool_use block must have a corresponding tool_result block in the next message."}}
Just got the "tool_use block must have a corresponding tool_result block in the next message" error on 1.0.29.
What account type are you using? Does quitting and claude --resume ing the conversation restore it? Do new conversations work? What was happening when the error occurred?
On Wed, Jun 18, 2025 at 10:13 PM Eric S. Rogstad @.***> wrote:
ESRogs left a comment (anthropics/claude-code#1894) https://github.com/anthropics/claude-code/issues/1894#issuecomment-2986632912
Just got the "tool_use block must have a corresponding tool_result block in the next message" error on 1.0.29.
— Reply to this email directly, view it on GitHub https://github.com/anthropics/claude-code/issues/1894#issuecomment-2986632912, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADSWQX3LEUA7MHF6OMFEYL3EJBGLAVCNFSM6AAAAAB677MV3OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSOBWGYZTEOJRGI . You are receiving this because you modified the open/close state.Message ID: @.***>
What account type are you using? Does quitting and claude --resume ing the conversation restore it? Do new conversations work? What was happening when the error occurred? …
i just got the same problem. max($100) account. --resume doesn't work but new conversations are fine.
I was using it just fine. Then I copy pasted a console output to ask something about it and now that conversation is bugged. 2x esc doesn't work. /compact doesn't work. Tried logout + login but its still broken.
Session File Investigation Report
I investigated session files that couldn't be resumed and found evidence directly related to this issue.
Findings
Tool Use/Result Mismatch:
Session file: 482cb242-01c9-4149-8c8a-b9b24fdc9844.jsonl
Tool use blocks: 47
Tool result blocks: 44
Missing: 3 tool_result blocks
Root Cause:
- User interruptions (
[Request interrupted by user for tool use]) left tool_use blocks without corresponding tool_result blocks - These orphaned tool_use blocks prevent session resumption with the exact error: "tool_use ids were found without tool_result blocks"
Impact:
- Sessions with mismatched counts cannot be resumed
- Users must start new sessions, losing context
This confirms the issue is caused by incomplete tool_use/tool_result pairs in session files, particularly after user interruptions.
This issue can also be caused by conflicting tool calls/overlapping functionality when one supersedes the other.
same in Claude Code Status v1.0.33 ... the double esc and going back up to 10 positions before the error ... and no way to recover ...
Hi guys, just received the same issue;
⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.1: tool_use
ids were found without tool_result blocks immediately after: toolu_01YDDsf7nQsBk9SSLHe41TUW. Each
tool_use block must have a corresponding tool_result block in the next message."}}
No way to reovery sessions and I lose all of my context.
^ This was using Claude Code on Debian WSL instance (Windows).
Could you resume the affected session and submit a report using /bug? That will really help us debug. Thanks
On Thu, Jun 26, 2025 at 6:40 AM spruik-co @.***> wrote:
spruik-co left a comment (anthropics/claude-code#1894) https://github.com/anthropics/claude-code/issues/1894#issuecomment-3008541295
Hi guys, just received the same issue;
⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.1: tool_use ids were found without tool_result blocks immediately after: toolu_01YDDsf7nQsBk9SSLHe41TUW. Each tool_use block must have a corresponding tool_result block in the next message."}}
No way to reovery sessions and I lose all of my context.
— Reply to this email directly, view it on GitHub https://github.com/anthropics/claude-code/issues/1894#issuecomment-3008541295, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADSWQXQM7UVJURQVMCXORT3FPZ4TAVCNFSM6AAAAAB677MV3OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTAMBYGU2DCMRZGU . You are receiving this because you modified the open/close state.Message ID: @.***>
Hi @igorkofman - I had to step back 3/4 messages in terms of context and was able to continue. I didn't have to shut Claude down. Messaging the same thing wouldn't clear the error.
/bug ⎿ Error submitting bug report
:)
Oh no! Try /bug again if it happens again. Are you on 1P or 3P?
On Thu, Jun 26, 2025 at 7:43 AM spruik-co @.***> wrote:
spruik-co left a comment (anthropics/claude-code#1894) https://github.com/anthropics/claude-code/issues/1894#issuecomment-3008746052
Hi @igorkofman https://github.com/igorkofman - I had to step back 3/4 messages in terms of context and was able to continue. I didn't have to shut Claude down. Messaging the same thing wouldn't clear the error.
/bug ⎿ Error submitting bug report
:)
— Reply to this email directly, view it on GitHub https://github.com/anthropics/claude-code/issues/1894#issuecomment-3008746052, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADSWQV7VB62RZAXPZGPU333FQBIBAVCNFSM6AAAAAB677MV3OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTAMBYG42DMMBVGI . You are receiving this because you were mentioned.Message ID: @.***>
I also was stuck this way today. Going back to a message before getting stuck (hit esc+esc) allowed me to continue.
Still running into this on 1.0.24. Can we change the logic so it stops hard failing on badly formatted messages in context?
Anyone have workarounds?
Someone please fix this.
⎿ API Error: Claude Code is unable to respond to this request, which appears to violate our Usage Policy (https://www.anthropic.com/legal/aup). Please double press esc to edit your last message
or start a new session for Claude Code to assist with a different task.
⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.223: tool_use ids were found without tool_result blocks immediately after:
toolu_vrtx_01QhEAXjsVvt3yhEWBT5NwE2. Each tool_use block must have a corresponding tool_result block in the next message."}}
just ran into this as well. was pushing claude hard to spin up as many agents as it could on a large project. mostly just using a google workspace MCP so tons of tool calls, not even on the coding yet. realllly need this to be fixed though because my claude-trace wasnt running for part of this conversation and i need access to that context.
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.77: tool_use ids were found without tool_result blocks immediately after: toolu_01iqwqSIs6FNbADrKQ9VpRj, toolu_01UeyEQwpjQVbsB3ttjekocp. Each tool_use block must have a corresponding tool_result block in the next message."}}
This usually happens when we interupt claude while thinking and then send directly another message but the interuption before didnt really "intreupt" and it was yet still thinking or doing. thats what I was noticing.
Getting the same exact thing, I can't just abandon the chat I have though
1.0.48 hit the same issue today.
esc-esc back a few steps with some new instructions seems to work around it. "note that we already implemented the task you were going to work on next, please proceed to task XYZ"
Ran into the same issue. No amount of escaping fixed it. Had to start a new thread.
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.4: tool_use ids were found without tool_result blocks immediately after: toolu_01PtJEAkLM3EvK7EhJ8QgZWC. Each tool_use block must have a corresponding tool_result block in the next message."}}
Same issue
15 July 2025
API Error: 400
{"type":"error","error":{"type":"invalid_request_error","message":"messages.6: `tool_use`
ids were found without `tool_result` blocks immediately after:
toolu_01WJjaQpXMi27SfHirJfLVpa. Each `tool_use` block must have a corresponding
`tool_result` block in the next message."}}
⎿ API Error (529 {"type":"error","error":{"type":"overloaded_error","message":"Overloaded"}}) · Retrying in 36 seconds… (attempt 9/10)
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.42: tool_use ids were found
without tool_result blocks immediately after: toolu_01T4rbEocUEcU3L1i8PmXfFF. Each tool_use block must have a corresponding
tool_result block in the next message."}}