Files
g3/crates
Dhanji R. Prasanna fcb839e5fd fix: nest images inside tool_result content for Anthropic API compliance
read_image tool results placed images as top-level Image content blocks
alongside ToolResult blocks in user messages. The Anthropic API rejects
this combination, reporting orphaned tool_use IDs even though the
tool_result was present — the malformed message structure prevented
the API from recognizing it as a valid tool result.

Added ToolResultContent enum (Text | Blocks) with custom serde so that
when images are attached to a tool result, they are nested inside the
tool_result content array as structured blocks, matching the Anthropic
API's expected format for multi-modal tool results.

Regular tool results (no images) continue to use simple string content.
Regular user messages (not tool results) continue to use top-level
Image blocks.

4 new tests covering image nesting, string fallback, regular user
messages, and orphan detection with structured content.
2026-02-13 10:50:52 +11:00
..