SIGN IN SIGN UP

fix(anthropic): keep parallel image tool_results contiguous

When the assistant issues several parallel read calls that return images,
each tool result is stored as its own user message of the form
[tool_result, image, "[Attached image ...]" label text]. After merging
the consecutive user messages, the sibling label text blocks were wedged
between the tool_results. Anthropic rejects this with a 400:
"tool_use ids were found without tool_result blocks immediately after",
because every tool_result for a parallel tool-call turn must be contiguous
in the next user message.

Fold the attached-image label text into the preceding image-bearing
tool_result's content blocks so all tool_results stay contiguous.

Adds a regression test.
J
jeremy committed
8879abec647ed1b84fa13493ea2fef5dc65443a7
Parent: c175c31