You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 70eba96
Browse filesBrowse the repository at this point in the historyBrowse files
* fix(anthropic): keep tool_result blocks contiguous by grouping image blocks separately
When a turn issued multiple tool_use blocks and tool results carried image
blocks (read_file on images, screenshots, feedback images),
presentAssistantMessage pushed each tool_result followed immediately by its
images, yielding tool_result/image interleaving in userMessageContent.
Task.ts then consumed the array verbatim, and the Anthropic API rejected the
request with a 400: "tool_use ids were found without tool_result blocks
immediately after" (#1307).
pushToolResultToUserContent is the single choke point every tool_result push
flows through, so it now maintains the invariant: when a new tool_result is
appended, image blocks already accumulated are moved after it. The resulting
user message is tool_results first (in tool_use order), then images, then
other blocks — matching the shape the issue expects. A single tool result
with images and image-free messages are unchanged.
* fix(anthropic): keep all tool_result blocks ahead of other user-message content
* test(anthropic): bind the real tool_result grouping and cover mixed interleave
Addresses edelauna's two review asks on #1705.
1. presentAssistantMessage-images.spec.ts bound a hand-copied partition of
Task.pushToolResultToUserContent, so the #1307 tests were tautological:
deleting the grouping from Task.ts still passed them. The mock now binds
the real Task.prototype.pushToolResultToUserContent via vi.importActual.
Verified: removing the partition from Task.ts fails both #1307 tests.
2. Task.spec.ts only covered "images after the first result". Added the
mixed interleave [image, text, r1, text, r2] -> [r1, r2, image, text,
text2], which fails under an image-only grouping and only passes with the
full tool_result-first partition.
Also carries main's new policySnapshot argument at the 2 integration call
sites, and drops this spec's no-explicit-any suppressions from 16 to 14.
* refactor(task): drop redundant guard in pushToolResultToUserContent
---------
Co-authored-by: Zoo (VP) <zoo@emebala.dev>
Co-authored-by: Elliott de Launay <edelauna@gmail.com>
0 commit comments