[BUG] API Error: 400. Each `tool_use` block must have a corresponding `tool_result` block in the next
Resolved 💬 18 comments Opened Sep 22, 2025 by Emasoft Closed Jan 30, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
After a while that I use Claude Code I get this error that prevents my message to be received and processes by Claude:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.78: `tool_use` ids were found without `tool_result` blocks
immediately after: toolu_015XCpRzgdbqwkNnYnDw8fCz. Each `tool_use` block must have a corresponding `tool_result` block in the next
message."},"request_id":"req_011CTNtey7CgGB1ZQZ1ykx4V"}
Claude is stuck with this error even if I do the following:
- I exit Claude Code and resume
- I press esc twice and
rewindto the previous statement - I uninstall all hooks and mcp
The only way to solve the issue is to use the /clear command, but this erases my chat history with hours of work.
The issue happens randomly but often, sometimes even 2 commands after the /compact execution.
What Should Happen?
Claude Code should accept my messages.
Error Messages/Logs
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.78: `tool_use` ids were found without `tool_result` blocks
immediately after: toolu_015XCpRzgdbqwkNnYnDw8fCz. Each `tool_use` block must have a corresponding `tool_result` block in the next
message."},"request_id":"req_011CTNtey7CgGB1ZQZ1ykx4V"}
Steps to Reproduce
Cannot find a pattern yet. It happens randomly but often.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
1.0.120
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
_No response_
18 Comments
Getting similar:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.227:
tool_useids werefound without
tool_resultblocks immediately after: toolu_01NMZHiv9T448pvCZFDiaLUH. Eachtool_useblock musthave a corresponding
tool_resultblock in the next message."},"request_id":"req_011CTPY1zNW6yij4WkeqJEDJ"}I've been having this error for several days now, practically in every session:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.137:
tool_useids were found withouttool_resultblocks immediately after: toolu_01SU9yXafXLVeMDEgtRkae2w. Eachtool_useblock must have a correspondingtool_resultblock in the next message."},"request_id":"req_011CTPYz16iUecMKw8j2Nwt6"}I'm having the same issue
I had the same issue but got Claude to troubleshoot and fix itself. here's the summary on how it self healed:
⏺ 🎯 Root Cause & Fix Summary
The Problem:
Claude's conversation state had broken message flow structure, not just orphaned tool_use blocks as initially thought.
Root Cause Discovery:
Conversation Flow Problem:
The Fix:
Surgical Structure Repair - Removed the malformed section (lines 925-942) while preserving 92.4% of conversation history (924/999 lines).
Key Insight:
The error message tool_use ids were found without tool_result blocks immediately after was literal - Claude requires tool_result blocks in the
immediately following message, not just somewhere later in the conversation.
Why This Worked:
Result: Claude can now continue normally with full conversation context preserved! ✅
My observation is that this occurs when the conversation is interrupted. Sometimes the interruption doesn't "take" and Claude 'forks' - one fork will continue running despite the interruption, and the other fork will be interrupted.
Then, the messages from the two threads get interspersed and everything grinds to a halt.
I have used /bug to report this at least once.
<details>
<summary>
I have tried reordering the lines using this script that Claude wrote me, but it didn't seem to fix the problem adequately.
</summary>
</details>
I found that deleting the specific tool use calls worked to a point, but sometimes it would cause the conversation history to get corrupted to the point where it would be blanked out.
I found that rewinding to before the first problematic tool call worked.
Moving the tool use result message back up to sit with the tool use message did not seem to be sufficient. I wonder whether it's because I didn't re-map the
parentUuids as well – the tool use result had aparentUuidreflecting its actual order in the jsonl file rather than where it "should" have been up above...I am also losing hours of work due to this.
This kind of worked: https://gist.github.com/awesomo4000/e4dcee5675a725a2ec8f44ce6d02b4a0
I can reproduce this fairly consistently by replying to Claude between the last message and when my PreStop hook finishes. It appears that the PreStop hook starts a thread and my message before its response starts another, and the threads become interleaved.
Horribly annoying this issue. Hours of contexts lost. The only thing that I have found that works is to clear the history.
I can also reproduce this by sending a message at any point between Stop hook execution and when execution actually stops.
I can stop it from happening by pressing
Escbefore sending a message. Once it starts, I have to ctrl-C out of Claude Code and thenEsc-Escback to before I sent the message that triggered the bug.Nothing is working for me. This error crops up every few calls. It obviously only happens when tool-use (search, etc.) is being done. Is there no fix to this? Pretty big and annoying bug.
Remains in 2.0, though it is less frequent.
Symptoms are similar - happens after Stop hook and I see two parallel threads running.
I do notice that whereas in 1.x I could trigger it only by sending a message after the Stop hook triggers, it seems to happen with no user input whatsoever in 2.0.
Rewinding the conversation to the last Stop hook reliably recovers for me.
Since 2.0, sending any instruction back to Claude Code in a hook now always triggers a
Missing Tool Result Blockerror and bricks the conversation.It can be reproduced consistently in the Stop hook.
(./claude/settings.json)
(./claude/script.py)
Same issue - filed it as separate bug:
Bug Description
Claude Code is very brittle in conjunction with tool calls. In case a tool request does not return, or a new message is submitted before the tool returns, it is out of sync.
Claude is then not responsive again. also / commands are not available anymore. So it's not even possible to /compact or write out the chat summary. Only option is to exit and start fresh. But this means, that all the prior context is gone. -c does not work as continuation includes the entire history and this also means that the errors persist.
This is not a rare issue. It happens (in longer conversations) EVERY time. Really, really annoying. I use claude with hooks (stop hook, pre-tool use, post-tool use, etc.)
around 20 agents, around 12 custom commands and several mcp servers. Use claude context for context indexation, sequential thinking and other relevant mcp tools.
I would want to either be able to a) make Claude reset the tool chain (unblock by removing the tool_use ids that did not return), or allow to compact. What is mandatory: It cannot be, that such an issue breaks follow-up prompts or commands. Literally NOTHING than exiting works anymore after this. So no possibility to clear, compact, write out, etc.
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_01Qou6gYEL7GyAd9VFp5LqoU. Each tool_use block must have a corresponding tool_result block in the next message."},"request_id":"req_011CTjmWkHa93MQMtijMNVtp"}
Environment Info
Platform: darwin
Terminal: iTerm.app
Version: 2.0.5
Feedback ID: 5ff09ed8-15f3-44d0-b727-c25aef312fcb
Errors
[{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.80:
tool_useids were found withouttool_resultblocks immediately after: toolu_01JkHyGazjoUvLzBW426G5pk. Eachtool_useblock must have a correspondingtool_resultblock in the next message.\"},\"request_id\":\"req_011CTjkswJpHzgrj2dXpeK9A\"}\n at B4.generate (file:///Users/simonscheurer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:895:18688)\n at yP.makeStatusError (file:///Users/simonscheurer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1034:2131)\n at yP.makeRequest (file:///Users/simonscheurer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1034:5344)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async E2B.dG1.model (file:///Users/simonscheurer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:39804)\n at async dG1 (file:///Users/simonscheurer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:27733)\n at async E2B (file:///Users/simonscheurer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:39958)\n at async file:///Users/simonscheurer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:34180\n at async ZH0 (file:///Users/simonscheurer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:9568)\n at async r11 (file:///Users/simonscheurer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:34150)","timestamp":"2025-10-03T06:02:15.416Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.80:tool_useids were found withouttool_resultblocks immediately after: toolu_01JkHyGazjoUvLzBW426G5pk. Eachtool_useblock must have a correspondingtool_resultblock in the next message.\"},\"request_id\":\"req_011CTjkt2GUEcLR4m8sfsgWX\"}\n at B4.generate (file:///Users/simonscheurer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:895:18688)\n at yP.makeStatusError (file:///Users/simonscheurer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1034:2131)\n at yP.makeRequest (file:///Users/simonscheurer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1034:5344)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async E2B.dG1.model (file:///Users/simonscheurer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:39804)\n at async dG1 (file:///Users/simonscheurer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:27733)\n at async E2B (file:///Users/simonscheurer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:39958)\n at async file:///Users/simonscheurer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:34180\n at async ZH0 (file:///Users/simonscheurer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:9568)\n at async r11 (file:///Users/simonscheurer/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:34150)","timestamp":"2025-10-03T06:02:16.898Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.107: `tool_useNote: Error logs were truncated.
fyi - Also referenced in many other issues including the ones listed here
https://github.com/anthropics/claude-code/issues/8894#issuecomment-3368364011
Been working with Stop hooks (that conditionally block claude from stopping with a message that essentially says "are you sure you're done? check the following to be sure..." that until today has been working REALLY well - no errors, catches things I want it to do that it forgets, etc. Today ran into this issue for the first time.
For me, after reading this thread, I decided to do a /compact to see if that did what I needed, and it seemed to work. Of course /compact has its own tradeoffs, but in case this helps others get unblocked, I thought I'd mention it here.
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.