[BUG] Repeated API Error 400
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other:
- Claude CLI version: 1.0.16
- Operating System: Ubuntu 22.04
- Terminal: bash in vscode
Bug Description
I am getting an API error -- no matter what I type. Here is the last thing I typed:
> I had just asked you to create extensive documentation, as this was a tricky
issue. Read the mathematical background and the test design / analysis framework
carefully, then write documentation on how we tuned, and also user documentation
on how to select # of banks, configure, etc.
⎿ API Error: 400
{"type":"error","error":{"type":"invalid_request_error","message":"messages.17:
`tool_use` ids were found without `tool_result` blocks immediately after:
toolu_015REhjCAk7wvjVLAxx4tABq. Each `tool_use` block must have a corresponding
`tool_result` block in the next message."}}
Steps to Reproduce
This happened in the middle of a session. When I stopped and restarted (without continue), I still got the same error after two interactions. However, in another window, I was able to restart, and now running for 5 minutes.
Expected Behavior
Actual Behavior
Additional Context
Same "API Error: 400" issue here for the past few hours - my session was stuck on this message:
{"type":"error","error":{"type":"invalid_request_error","message":"messages.24: `tool_use` ids were found without `tool_result` blocks immediately after:
toolu_01Pn2u37FXKwa9APpMnRdGmA. Each `tool_use` block must have a corresponding `tool_result` block in the next message."}}
I tried disabling MCP in case that was the issue, but that wasn't it.
My solution to bypass this error was to NOT use the "--continue" switch when calling Claude.
So I'm guessing it was related to the context/history of the (resumed) session.
Same issue here:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.23: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01HBZnK6MJEZ9phH3UhKGvyc. Each `tool_use` block must have a corresponding
`tool_result` block in the next message."}}
--continue doesnt work, will try with a new session
Happening here too.
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.