claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[Bug] API Error: 400 Each `tool_use` block must have a corresponding `tool_result` block in the next message.

Open AgentiLoop opened this issue 1 year ago • 6 comments

Bug Description

some PDFs are still being importe as Grayscale and not with proper image.. it is brinng in only 1 channel. you may have to get all 3-4 chanensl (RGB+Alpha) and map them correctlty. see iamge '/Users/toddbruss/Library/Mobile Documents/com~apple~CloudDocs/Documents/GitHub/UFOEmoji2020/UFO Emoji/UFO Emoji/Assets.xcassets/GameGold/gold.imageset/gold.pdf' ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.2: tool_use ids were found without tool_result blocks immediately after: toolu_01P8CUYNvjiJH6QxQuaye4qF. Each tool_use block must have a corresponding tool_result block in the next message."},"request_id":"req_011CTmSMQ3wnysHjGDeUxS7U"}

Environment Info

  • Platform: darwin
  • Terminal: Apple_Terminal
  • Version: 2.0.5
  • Feedback ID: d6279eab-730f-4248-b407-d2ccb13a6eab

Errors

[{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.2: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01P8CUYNvjiJH6QxQuaye4qF. Each `tool_use` block must have a corresponding `tool_result` block in the next message.\"},\"request_id\":\"req_011CTmSLSgfmhiJiYCPD1L4w\"}\n    at B4.generate (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:895:18688)\n    at yP.makeStatusError (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1034:2131)\n    at yP.makeRequest (file:///opt/homebrew/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:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:39804)\n    at async dG1 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:27733)\n    at async E2B (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:39958)\n    at async file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:34180\n    at async ZH0 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:9568)\n    at async r11 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:34150)","timestamp":"2025-10-04T03:20:16.758Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.2: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01P8CUYNvjiJH6QxQuaye4qF. Each `tool_use` block must have a corresponding `tool_result` block in the next message.\"},\"request_id\":\"req_011CTmSMQ3wnysHjGDeUxS7U\"}\n    at B4.generate (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:895:18688)\n    at yP.makeStatusError (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1034:2131)\n    at yP.makeRequest (file:///opt/homebrew/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:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:39804)\n    at async dG1 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:27733)\n    at async E2B (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:39958)\n    at async file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:34180\n    at async ZH0 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:9568)\n    at async r11 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1120:34150)","timestamp":"2025-10-04T03:20:29.580Z"}]

AgentiLoop avatar Oct 04 '25 03:10 AgentiLoop

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/8565
  2. https://github.com/anthropics/claude-code/issues/8817
  3. https://github.com/anthropics/claude-code/issues/8004

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

github-actions[bot] avatar Oct 04 '25 03:10 github-actions[bot]

This is a disaster and an emergency. It's preventing me from doing real work. Occuring in pretty much every session I'm running, sooner or later.

I have PostToolUse hooks active - I wonder if that's the culprit?

The PostToolUse output is being sent as USER MESSAGES back to CLAUDE as if I am sending new messages FOR EVERY NEW TOOL USE.

For me it often gets into a state of uninterruptable looping based on subsequent tool uses triggering "user messages" which simply contain PostToolUse hook outputs. Insanity.

UNACCEPTABLE.

Please somebody from the Claude Code team - reach out if you want help debugging this.

Collection of other similar bug reports: #8187 #8077 #8201 #8303 #8325 #8425 #8507 #8612 #8652 #8670 #8746 #8763 #8783 #8790 #8817 #8818 #8821 #8847 #8867 (my report) #8887 #8893 #8894 #8895 #8897 #8903

semikolon avatar Oct 04 '25 15:10 semikolon

This is a major issue with hooks, bricking conversations and rendering CC unusable. It needs to be prioritized. https://github.com/anthropics/claude-code/issues/8004#issuecomment-3362572965

victor-bluera avatar Oct 09 '25 17:10 victor-bluera

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.

github-actions[bot] avatar Dec 07 '25 10:12 github-actions[bot]

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.

github-actions[bot] avatar Jan 10 '26 10:01 github-actions[bot]

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.

github-actions[bot] avatar Jan 18 '26 14:01 github-actions[bot]