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

Specific session always generates API Error 400 on each request

Open ChristophRauch opened this issue 1 year ago • 5 comments

Bug Description In a specific session, regardless what I type into Claude Code, I always get the following error:

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

When I start a new session, the problem is not there, so it must have something to do with the session itself?

Environment Info

  • Platform: linux
  • Terminal: gnome-terminal
  • Version: 1.0.53
  • Feedback ID: 139b954b-54b2-4162-9e7c-1f2a9c81ec2f

Errors

[{"error":"Error: Invalid settings at /home/christoph/.claude/settings.json: [\n  {\n    \"code\": \"unrecognized_keys\",\n    \"keys\": [\n      \"additionalDirectories\",\n      \"automation\"\n    ],\n    \"path\": [],\n    \"message\": \"Unrecognized key(s) in object: 'additionalDirectories', 'automation'\"\n  }\n]\n    at GoA (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:640:4370)\n    at gN9 (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:640:6078)\n    at Lq (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:640:6383)\n    at wQ (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:640:6318)\n    at Zl0 (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:747:5081)\n    at file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:758:1146\n    at Q (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:542:14406)\n    at rF4 (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:2669:9917)\n    at file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:2686:1373","timestamp":"2025-07-16T15:15:47.941Z"},{"error":"Error: Invalid settings at /home/christoph/.claude/settings.json: [\n  {\n    \"code\": \"unrecognized_keys\",\n    \"keys\": [\n      \"additionalDirectories\",\n      \"automation\"\n    ],\n    \"path\": [],\n    \"message\": \"Unrecognized key(s) in object: 'additionalDirectories', 'automation'\"\n  }\n]\n    at GoA (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:640:4370)\n    at NJ (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:640:5278)\n    at lx1 (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:614:1519)\n    at HrA (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:614:1480)\n    at ao2 (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:2124:1245)\n    at mIA.<anonymous> (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:2674:615)\n    at async mIA.parseAsync (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:533:4184)\n    at async eF4 (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:2686:1216)\n    at async rF4 (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:2669:10051)","timestamp":"2025-07-16T15:15:47.976Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.5: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01Ljs9UTjCKiGmLm9ymZPGrq. Each `tool_use` block must have a corresponding `tool_result` block in the next message.\"}}\n    at eQ.generate (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1180:6428)\n    at k$.makeStatusError (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1197:2101)\n    at k$.makeRequest (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1197:5315)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async aB1.showErrors (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:2594:14107)\n    at async aB1 (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:2140:1658)\n    at async qBB (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:2594:13956)\n    at async file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:2594:9065\n    at async DIA (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:2594:1626)\n    at async Yp (file:///home/christoph/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:2594:9035)","timestamp":"2025-07-16T15:16:03.598Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.5: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01Ljs9UTjCKiGmLm9ymZPGrq. Each `tool_use` block must have a corresponding `tool_result` block in the next

Note: Error logs were truncated.

ChristophRauch avatar Jul 16 '25 15:07 ChristophRauch

he next message."}}

what is going on??? ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.208: tool_use ids were found without tool_result blocks immediately after: toolu_01LsN9eeWJqu83ZEn9MMz6kD. Each tool_use block must have a corresponding tool_result block in the next message."}}

what is going on??? ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.208: tool_use ids were found without tool_result blocks immediately after: toolu_01LsN9eeWJqu83ZEn9MMz6kD. Each tool_use block must have a corresponding tool_result block in the next message."}}

what is going on??? ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.208: tool_use ids were found without tool_result blocks immediately after: toolu_01LsN9eeWJqu83ZEn9MMz6kD. Each tool_use block must have a corresponding tool_result block in the next message."}}

what is going on??? ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.208: tool_use ids were found without tool_result blocks immediately after: toolu_01LsN9eeWJqu83ZEn9MMz6kD. Each tool_use block must have a corresponding tool_result block in the next message."}}

what is going on??? ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.208: tool_use ids were found without tool_result blocks immediately after: toolu_01LsN9eeWJqu83ZEn9MMz6kD. Each tool_use block must have a corresponding tool_result block in the next message."}}

what is going on??? ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.208: tool_use ids were found without tool_result blocks immediately after: toolu_01LsN9eeWJqu83ZEn9MMz6kD. Each tool_use block must have a corresponding tool_result block in the next message."}}

what is going on??? ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.208: tool_use ids were found without tool_result blocks immediately after: toolu_01LsN9eeWJqu83ZEn9MMz6kD. Each tool_use block must have a corresponding tool_result block in the next message."}}

what is going on??? ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.208: tool_use ids were found without tool_result blocks immediately after: toolu_01LsN9eeWJqu83ZEn9MMz6kD. Each tool_use block must have a corresponding tool_result block in the next message."}}

what is going on??? ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.208: tool_use ids were found without tool_result blocks immediately after: toolu_01LsN9eeWJqu83ZEn9MMz6kD. Each tool_use block must have a corresponding tool_result block in the next message."}}

what is going on??? ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.208: tool_use ids were found without tool_result blocks immediately after: toolu_01LsN9eeWJqu83ZEn9MMz6kD. Each tool_use block must have a corresponding tool_result block in the next message."}}

medproapp avatar Jul 16 '25 15:07 medproapp

I see the same issues

chadedodson avatar Jul 16 '25 17:07 chadedodson

@levpopov I still have the session open that produces the issue. Feel free to tell me if you need the session files (don't know where they lie around) to fix it.

ChristophRauch avatar Jul 16 '25 19:07 ChristophRauch

I can't seem to find the session any longer. Sorry. But I haven't seen the error since.

ChristophRauch avatar Jul 21 '25 07:07 ChristophRauch

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