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

[Bug] Anthropic API Error: Tool Use Concurrency Failure

Open AgentiLoop opened this issue 1 year ago • 19 comments

Bug Description ▗ ▗ ▖ ▖ Claude Code v2.0.9 Sonnet 4.5 · Claude Max ▘▘ ▝▝ /Users/toddbruss/Documents/GitHub/logos

opening a pages pdf puts text off the page towards the top. can I give you the PDF to inspect and figure out why and fix the PDF Parser?

⏺ I can help you investigate why text is appearing off the page when opening a Pages PDF. Please provide the PDF file path so I can inspect it.

Once you give me the PDF path, I'll:

  1. Read the PDF to examine its structure
  2. Find and analyze the PDF parser code in the codebase
  3. Identify why text positioning is incorrect
  4. Fix the parser to handle Pages PDFs correctly
  5. Build and test using xcf

What's the path to the PDF file?

"/Users/toddbruss/Documents/test1.pdf"

⏺ Read(~/Documents/test1.pdf) ⎿  Read PDF (7.9KB)

⏺ Search(pattern: "**/PDFParser*.swift") ⎿  Found 1 file (ctrl+o to expand)

⏺ Search(pattern: "**/PDF.swift") ⎿  Found 20 files (ctrl+o to expand) ⎿ API Error: 400 due to tool use concurrency issues. Run /rewind to recover the conversation.

Environment Info

  • Platform: darwin
  • Terminal: Apple_Terminal
  • Version: 2.0.9
  • Feedback ID: 0f63fad7-e5bc-4bea-987a-6ae79e166c30

Errors

[{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.4: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01GyUYWVRTSP9SPmZgF1iQqC, toolu_01VWXumSZ82UXnVe5xCHXc1T. Each `tool_use` block must have a corresponding `tool_result` block in the next message.\"},\"request_id\":\"req_011CTtQthxdEh62MNQTc7ocT\"}\n    at l9.generate (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:878:18710)\n    at hP.makeStatusError (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1023:2117)\n    at hP.makeRequest (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1023:5330)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async _W1.model (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3189:18601)\n    at async _W1 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2520:2114)\n    at async tTB (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3189:18755)\n    at async file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3189:12983\n    at async qT0 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3189:4228)\n    at async x11 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3189:12953)","timestamp":"2025-10-07T19:45:30.414Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.4: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01GyUYWVRTSP9SPmZgF1iQqC, toolu_01VWXumSZ82UXnVe5xCHXc1T. Each `tool_use` block must have a corresponding `tool_result` block in the next message.\"},\"request_id\":\"req_011CTtQvADDSxwujUmxXDBB7\"}\n    at l9.generate (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:878:18710)\n    at hP.makeStatusError (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1023:2117)\n    at hP.makeRequest (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1023:5330)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async _W1.model (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3189:18601)\n    at async _W1 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:2520:2114)\n    at async tTB (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3189:18755)\n    at async file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3189:12983\n    at async qT0 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3189:4228)\n    at async x11 (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:3189:12953)","timestamp":"2025-10-07T19:45:50.047Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.4: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_015pSerNvjZ85B7XXBwcMCcz, toolu_01HMKR74P4A4oWjrtXqV4mrF. Each `tool_use` block must have a corresponding `tool_result` block in the next message.\"},\"request_id\":\"req_011CTtQyhnqrCiTMDWByBnRX\"}\n    at l9.generate (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:878:18710)\n    at hP.makeStatusError (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:1023:2117)\n    at hP.makeRequest (file:///opt/homebrew/lib/node_m

Note: Error logs were truncated.

AgentiLoop avatar Oct 07 '25 19:10 AgentiLoop

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/8763
  2. https://github.com/anthropics/claude-code/issues/8187
  3. https://github.com/anthropics/claude-code/issues/6836

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 07 '25 19:10 github-actions[bot]

This has suddenly started happening VERY often, and repeatedly - appears to be related to 2.0.10.

Previously it was only happening with a Stop hook, and I hadn't seen it in ~a week after enabling the Stop hook. In the last couple of hours my instance has upgraded itself to 2.0.10 and I have two conversations where this is happening repeatedly, even after I rewind and start again, it will run for a few minutes and then get stuck once more.

werdnum avatar Oct 07 '25 22:10 werdnum

Today is the first time I encountered it. The only fix was switch to Opus. Unfortunately, Opus access runs out in less than an hour of use and weekly limits get reached much quicker as well. So if it’s a Sonnet 4.5 bug, and you are out of Opus access, you can get stuck.Access for the past week has been up and down like a yoyo. I was on the most expensive plan, but due to the API errors I went to the middle plan and contemplating going to the Pro plan, the least expensive plan, and use it less. Why? From a customer perspective, when you are paying premium, you should get premium access and service. If pro users are using the same servers as Ultra/Max or whatever it’s called, it lops everyone together and everyone gets the same poor service when things go sideways. Each tier should be on their own tier. On Oct 7, 2025, at 6:57 PM, Andrew Garrett @.***> wrote:werdnum left a comment (anthropics/claude-code#9103) This has suddenly started happening VERY often, and repeatedly - appears to be related to 2.0.10. Previously it was only happening with a Stop hook, and I hadn't seen it in ~a week after enabling the Stop hook. In the last couple of hours my instance has upgraded itself to 2.0.10 and I have two conversations where this is happening repeatedly, even after I rewind and start again, it will run for a few minutes and then get stuck once more.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

AgentiLoop avatar Oct 07 '25 23:10 AgentiLoop

I've had this 6-8 times today having never seen it before. It's either a sonnet 4.5 issue or a recent regression, I think.

sminnee avatar Oct 08 '25 07:10 sminnee

In the claude code VSCode extension you cannot /rewind as the command doesnt seem to exist, leaving you with the only option to start a new conversation without holding the context of what failed, which is terrible...

jsoriase avatar Oct 08 '25 09:10 jsoriase

This happens a lot to me too now.

villesau avatar Oct 08 '25 11:10 villesau

Duplicate of https://github.com/anthropics/claude-code/issues/8763

ap1969 avatar Oct 08 '25 13:10 ap1969

API Error: 400 due to tool use concurrency issues. Run /rewind to recover the conversation.

Encountered it too often.

nthtrung09it avatar Oct 08 '25 15:10 nthtrung09it

https://github.com/anthropics/claude-code/issues/8763#issuecomment-3391509893

semikolon avatar Oct 10 '25 18:10 semikolon

API Error: 400 due to tool use concurrency issues. Run /rewind to recover the conversation.

Same

that-guy-scott avatar Oct 15 '25 13:10 that-guy-scott

first time paid a year subscription coming from gpt. I got instantly hit with below error API Error: 400 due to tool use concurrency issues. Run /rewind to recover the conversation.

pasza01 avatar Oct 16 '25 20:10 pasza01

This also seems to happen with the vscode plugin, as well as with the CLI.

villesau avatar Oct 17 '25 11:10 villesau

Btw, I've noticed that with the latest claude code versions just writing resume seems to help.

villesau avatar Oct 17 '25 13:10 villesau

as my experiences:

Root Cause: Spawned process stdout/stderr corruption

Problem: Hook spawns external process → reads output → process still running when hook writes JSON response → process stderr/stdout interleaves with hook JSON → malformed JSON → API 400

Fix: Always await full process exit before hook writes JSON output

yemreak avatar Oct 19 '25 12:10 yemreak

The PostToolUse issue seems to be blessedly gone (I haven't re-enabled Stop hooks yet, so idk if that's fixed), however there is currently a case where you get it from PreToolUse if your hook returns JSON {"decision": "deny"} – you can work around it by changing the hook to exit(2) instead.

Generally it seems like Anthropic's strategy here is to play whack-a-mole and fix each case 'properly', but I will say that it would be nice if CC could detect and recover from this condition by stripping out the relevant tool calls, turning them into strings, repairing the transcript or whatever needs to be done such that this is no longer fatal.

werdnum avatar Oct 19 '25 23:10 werdnum

For many things now I use /exitClaude —forked-session —resume Then pick the first item.  Helps me recover from most blunders. I like CC but also feel like we are paying good money to beta test. Cursor.ai is more solid even though is do prefer not having an IDE and use XCode’s with my own MCP server, XCF.ai See Claude help for exact syntax Sent from my iPhoneOn Oct 19, 2025, at 7:57 PM, Andrew Garrett @.***> wrote:werdnum left a comment (anthropics/claude-code#9103) The PostToolUse issue seems to be blessedly gone (I haven't re-enabled Stop hooks yet, so idk if that's fixed), however there is currently a case where you get it from PreToolUse if your hook returns JSON {"decision": "deny"} – you can work around it by changing the hook to exit(2) instead. Generally it seems like Anthropic's strategy here is to play whack-a-mole and fix each case 'properly', but I will say that it would be nice if CC could detect and recover from this condition by stripping out the relevant tool calls, turning them into strings, repairing the transcript or whatever needs to be done such that this is no longer fatal.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

AgentiLoop avatar Oct 20 '25 00:10 AgentiLoop

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 09 '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 17 '26 14:01 github-actions[bot]