[BUG] `tool_use` ids were found without `tool_result` blocks after failed cancel
Status Fixed / completed
Maintainer reply ✓ Yes — bcherny
Workaround ✓ Mentioned in thread ↓
Activity 13 comments · opened Apr 9, 2025 · closed May 8, 2025
💡 Likely answer: A maintainer (bcherny, collaborator)
responded on this thread — see the highlighted reply below.
Environment
- Platform (select one):
- [X] Google Vertex AI
- Claude CLI version: 0.2.66 (Claude Code)
Bug Description
⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.8: `tool_use` ids were found without
> /compact
⎿ Error: Error during compaction: Error: API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.8:
`tool_use` ids were found without `tool_result` blocks immediately after: toolu_vrtx_015oxzdhxTvyks3Djx4FZE3h. Each `tool_use` block
must have a corresponding `tool_result` block in the next message."}}
Steps to Reproduce
Not sure I'll be able to reproduce it. It happened after I hit Escape to cancel what it was doing after an auto-compaction, but it failed to properly cancel it. While the activity was still ongoing, I could submit prompts and hit enter, but it would immediately return: ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.8: tool_use ids were found without
and continue running the previous activity.
I let it complete, then hit Escape to reject the proposed edit, and then tried to /compact, and got a more complete version of the same error, as show in the description section above.
Expected Behavior
When I hit escape, it cancels the ongoing activity.
13 Comments
The ignored cancellation attempt thing just happened again. I think it might be related to the handling of the Escape cancellation sequence during the
"status":"RESOURCE_EXHAUSTED"}}) · Retryingthat are so common on Vertex AI: when I try to cancel in the middle of a retry, it seems to take me back to the prompt without actually cancelling the retry-in-progress task.After the task finally completed, a /compact gives the same kind of error as before:
i face the same issue, any update?
claude code is persistently running into this when reading a specific file in my project, i have to tell it to use
catinstead of whatever "Read" usesupdate: I believe this might have to do with accessing files outside of the current startup path for claude code
when I ran into it the first time, it was always a file in a separate repo/parent directory
so i started a new session in that folder, and now it's causing the error on a file in the original path
I just got this same error. Claude code was stalled while attempting to List files in a directory outside the directory where I started claude code. I escaped and got this error when sending a new message:
What I have noticed since opening this issue is that if I hit escape to cancel something, I have to wait for the interrupted by user message to show up, which requires waiting for the 429 overloaded messages to resolve and the last LLM call to complete. If I try to send anything before that, it goes into a bad state. There are probably other conditions that can get it into that state as well, but that is the one that I've been able to reliably reproduce.
i think this happens after trying to access files outside the startup path
This should be feeling better in newer versions. Restart to update and feel free to open a new issue if you're still hitting this.
@bcherny still reproduces on
tool_useids were found withouttool_resultblocks immediately after: toolu_01GBbvmXsNhUCh31uLKymNFu. Eachtool_useblock must have a correspondingtool_resultblock in the next message."}}I am getting this error a lot after updating to claude updated to 1.0.51 . I have to scrollback though my session grabbing important pieces to summarise before exiting and restarting. I cannot summarise/compact or run any commands at all once I start receiving this error.
⎿ API Error: 400
{"type":"error","error":{"type":"invalid_request_error","message":"messages.12:
tool_useids were found without
tool_resultblocks immediately after:toolu_0122qAUB3h5BfydqHBc9cSHE, toolu_01ABr2wFGu1SCHk1RDJdrCCA,
toolu_01BRscC71F4kCnpYkccLCXgA, toolu_01VmZ3MkiGW59b33fnFrjp3f. Each
tool_useblock musthave a corresponding
tool_resultblock in the next message."}}⎿ API Error: 400
{"type":"error","error":{"type":"invalid_request_error","message":"messages.12:
tool_useids were found without
tool_resultblocks immediately after:toolu_0122qAUB3h5BfydqHBc9cSHE, toolu_01ABr2wFGu1SCHk1RDJdrCCA,
toolu_01BRscC71F4kCnpYkccLCXgA, toolu_01VmZ3MkiGW59b33fnFrjp3f. Each
tool_useblock musthave a corresponding
tool_resultblock in the next message."}}Claude CLI Diagnostic
Currently running: unknown (1.0.51)
Path: /usr/bin/node
Invoked: /home/raoul/.npm-global/bin/claude
Config install method: unknown
Auto-updates enabled: true
also getting the error:
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."}}
workaround temporarily, if you can lose the last couple of messages, is to use escape escape and then fork it from a previous message before it had this issue. Still happening in the latest but worked for me.
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.