Skip to content

AI_APICallError: tool_use blocks found without corresponding tool_result blocks #2720

@sahilchouksey

Description

@sahilchouksey

Description

Getting an AI_APICallError when tool_use blocks are not immediately followed by tool_result blocks.

Error Message

AI_APICallError: messages.69: `tool_use` ids were found without `tool_result` blocks immediately after: toolu_01X6jLG6TqrVeBTSEqq4ozEN. Each `tool_use` block must have a corresponding `tool_result` block in the next message.

Expected Behavior

The system should handle tool_use blocks properly and ensure each tool_use has a corresponding tool_result.

Additional Context

  • This appears to be a message formatting/validation issue
  • The error references a specific tool_use ID: toolu_01X6jLG6TqrVeBTSEqq4ozEN
  • Message index 69 suggests this occurs in longer conversations

Steps to Reproduce

This error occurred during normal usage when the AI made tool calls but the tool results weren't properly matched.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions