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

Invalid Tool Result Block: Missing Corresponding Tool Result for Tool Use ID

Open dsvua opened this issue 7 months ago • 3 comments

Bug Description ⎿  API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.41: tool_use ids were found without tool_result blocks immediately after: toolu_01UH1ch5PqbZyt6xYL3iSz93. Each tool_use block must have a corresponding tool_result block in the next message."}}

Environment Info

  • Platform: linux
  • Terminal: gnome-terminal
  • Version: 1.0.24
  • Feedback ID: 6844dcc1-15a0-4ec8-936d-d6dd00345dbd

Errors

[{"error":"Error: Request was aborted.\n    at mo._createMessage (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1335:6810)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","timestamp":"2025-06-16T14:25:40.110Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.41: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01UH1ch5PqbZyt6xYL3iSz93. Each `tool_use` block must have a corresponding `tool_result` block in the next message.\"}}\n    at h6.generate (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1329:12578)\n    at Lw.makeStatusError (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1344:2082)\n    at Lw.makeRequest (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1344:5257)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async ME2.K11.showErrors (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:22008)\n    at async K11 (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:12203)\n    at async ME2 (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:21854)\n    at async file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:17103\n    at async yt1 (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:5151)\n    at async Fu (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:17073)","timestamp":"2025-06-16T16:43:08.896Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.41: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01UH1ch5PqbZyt6xYL3iSz93. Each `tool_use` block must have a corresponding `tool_result` block in the next message.\"}}\n    at h6.generate (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1329:12578)\n    at Lw.makeStatusError (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1344:2082)\n    at Lw.makeRequest (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1344:5257)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async ME2.K11.showErrors (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:22008)\n    at async K11 (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:12203)\n    at async ME2 (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:21854)\n    at async file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:17103\n    at async yt1 (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:5151)\n    at async Fu (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:17073)","timestamp":"2025-06-16T16:43:23.568Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.41: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01UH1ch5PqbZyt6xYL3iSz93. Each `tool_use` block must have a corresponding `tool_result` block in the next message.\"}}\n    at h6.generate (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1329:12578)\n    at Lw.makeStatusError (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1344:2082)\n    at Lw.makeRequest (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1344:5257)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async ME2.K11.showErrors (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:22008)\n    at async K11 (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:12203)\n    at async ME2 (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:21854)\n    at async file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:17103\n    at async yt1 (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:5151)\n    at async Fu (file:///usr/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:17073)","timestamp":"2025-06-16T16:43:29.301Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.41: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01UH1ch5PqbZyt6xYL3iSz93. Each `tool_use` block must h

Note: Error logs were truncated.

dsvua avatar Jun 16 '25 16:06 dsvua

Strange, this got fixed a few days ago: https://github.com/anthropics/claude-code/issues/1968

But I just had the same error too:

● Bash(grep -n "process_status" src/main/java/be/elevenways/mcp/procman/Main.java)
  ⎿  97:            new Tool("process_status", "Get status of a specific process", createSchema(Map.of(
  ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.139: `tool_use` ids were found
    without `tool_result` blocks immediately after: toolu_01FT2ewJJJqwCStkTWqk2RBY. Each `tool_use` block must have a
    corresponding `tool_result` block in the next message."}}

> Try again
  ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.139: `tool_use` ids were found
    without `tool_result` blocks immediately after: toolu_01FT2ewJJJqwCStkTWqk2RBY. Each `tool_use` block must have a
    corresponding `tool_result` block in the next message."}}

Now what? Why does this break the entire conversation?

skerit avatar Jun 16 '25 17:06 skerit

Same for me, 1.0.24. Removing all MCP setup (Context7 + Playwright in headless) has made it go away as a temporary workaround.

digitalmagnets avatar Jun 16 '25 18:06 digitalmagnets

Seems to be fixed in 1.0.25 hopefully!

Edit: No, it's still happening.

digitalmagnets avatar Jun 17 '25 10:06 digitalmagnets

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 Aug 11 '25 14:08 github-actions[bot]