Skip to content

API Error 400: tool_use blocks without corresponding tool_result blocks #5662

@InfoCodeStreamly

Description

@InfoCodeStreamly

Environment

  • Platform (select one):
    • Anthropic API
    • AWS Bedrock
    • Google Vertex AI
    • Other:
  • 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."}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:apiarea:corebugSomething isn't workingduplicateThis issue or pull request already existsplatform:macosIssue specifically occurs on macOS

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions