API Error 400: tool_use blocks without corresponding tool_result blocks

Resolved 💬 5 comments Opened Aug 13, 2025 by InfoCodeStreamly Closed Sep 18, 2025

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.77 (Claude Code)
  • Operating System: macOS (Darwin 24.6.0)
  • Terminal: Terminal App

## Bug Description
Frequent API Error 400 with message "tool_use ids were found without tool_result blocks immediately after". This prevents normal operation and requires retrying commands.

## Steps to Reproduce

  1. Use Claude Code CLI for any task involving tool calls
  2. Error occurs randomly during tool execution
  3. Specific error: messages.129: tool_use ids were found without tool_result blocks immediately after: toolu_01JX7gsswzmXeYhXg6F8wGRy

## Expected Behavior
Tool calls should complete successfully with proper tool_use/tool_result pairing.

## Actual Behavior
API returns 400 error indicating missing tool_result blocks, interrupting workflow. Issue has become frequent over the past couple of days.

## Additional Context

  • Node.js version: v24.2.0 (getting npm warnings about engine compatibility)
  • Just updated Claude Code CLI via npm update -g @anthropic/claude-code
  • Retrying the same command usually works on second attempt
  • Error seems to happen with various tool types, not specific to one tool

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

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗