Skip to content

Anthropic 400: tool_use ids found without tool_result blocks (messagesToAnthropicFormat) #620

Description

@BuomEm

Client or integration

Codex App

Area

Provider adapter

Summary

Anthropic 400: tool_use ids were found without tool_result blocks immediately after

When using an Anthropic (Claude) backend, requests fail with:
messages.4: tool_use ids were found without tool_result blocks immediately after: call_4d252114da304363a52244af

Root cause in messagesToAnthropicFormat (line ~424): when an assistant message's text+thinking content is filtered to empty, if (content.length === 0) break skips the entire toolResult processing block. Tool_use blocks are collected but never paired with tool_result blocks — no synthetic [missing tool_result] is created.

Reproduction

  1. ocx start
  2. Configure Anthropic backend (claude-opus-4-6-thinking) via google-antigravity
  3. Use Codex for a session with multiple tool calls until conversation history is large
  4. Observe: messages.4: tool_use ids were found without tool_result blocks

Version

2.7.42

Operating system

Windows 11 24H2

Provider and model

google-antigravity / claude-opus-4-6-thinking

Logs or error output

Provider error 400: Antigravity invalid request: {"type":"error","error":{"type":"invalid_request_error","message":"messages.4: `tool_use` ids were found without `tool_result` blocks immediately after: call_4d252114da304363a52244af. Each `tool_use` block must have a corresponding `tool_result` block in the next message."}}

Screenshots and supporting files

No response

Redacted configuration

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions