Skip to content

Tool response images break Anthropic tool_result grouping on OpenAI-compatible providers #7400

@katzdave

Description

@katzdave

Initial report from @spencrmartin using Opus 4.6 on databricks.

When multiple tool calls return images, the OpenAI-compatible format layers (databricks, openai)
split each image into a separate user message since role: "tool" only supports strings. This
interleaves user image messages between tool messages, violating Anthropic's requirement that all
tool_result blocks appear consecutively after the assistant message.

assistant: tool_calls=[A, B, C]
tool: A
user: A's image ← breaks consecutive tool group
tool: B
user: B's image
tool: C

Error: tool_use ids were found without tool_result blocks immediately after

Affects any provider proxying to Anthropic via OpenAI-compatible API (Databricks,
OpenRouter→Claude, etc.).

Confirmed from diagnostic bundle: 4 tool_calls in one assistant message, 3 responses from
image_processor containing image data.

A proposed fix (#7393) exists that reorders the formatted messages to defer image messages until after the
tool group, but needs careful review — it modifies the message array after formatting which could
have unintended side effects.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions