Skip to content

Error 400 with Tool Use: Number of toolResult blocks exceeds toolUse blocks #5

@BillWang-dev

Description

@BillWang-dev

When attempting to use the Tool Use (Function Calling) feature via anthropic-proxy (with the backend model anthropic/claude-3.5-haiku routed through OpenRouter, where the error message indicates the actual provider is Amazon Bedrock), the API returns a 400 error. The error message states that the number of toolResult blocks in the request's messages exceeds the number of toolUse blocks from the model's previous turn.

Error Message:

  ⎿  Invalid tool parameters
  ⎿  API Error: 400 {"error":"{\"error\":{\"message\":\"Provider returned 
     error\",\"code\":400,\"metadata\":{\"raw\":\"{\\\"message\\\":\\\"The number of 
     toolResult blocks at messages.4.content exceeds the number of toolUse blocks of 
     previous turn.\\\"}\",\"provider_name\":\"Amazon 
     Bedrock\"}},\"user_id\":\"user_2m17fqmm2tL3UEVCpAlvfXvsXx5\"}"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions