fix(session): only keep Bedrock tool-result images for Anthropic and Nova models - #49444
alohaninja wants to merge 2 commits into
Conversation
…Nova models Bedrock Converse only accepts images inside toolResult for Anthropic and Amazon Nova models; every other provider on Bedrock returns 400 "This model doesn't support the image field for user messages" and the session is stuck because the image stays in history. Hoist tool-result images into a user message for all other Bedrock model IDs, which is the path already used for Bedrock PDFs. Co-Authored-By: claude-fable-5-1 <noreply@anthropic.com>
|
The following comment was made by an LLM, it may be inaccurate: Found several related PRs: Most Relevant:
These are not duplicates of PR #49444, but they're part of the same effort to fix Bedrock tool-result image handling across different model families. PR #49444 builds on the foundation of PR #48070 to create a more comprehensive solution using an allowlist for Anthropic and Nova models. |
|
Correct on both. #48070 covers Astra by ID. #49197 is the maintainer-side fix and covers more families with a denylist ( The difference here is the shape of the guard. Bedrock documents If #49197 lands first I'm happy to close this; I've left the Mistral/Gemma data on that PR so it can be folded in either way. |
Co-Authored-By: claude-fable-5-1 <noreply@anthropic.com>
Issue for this PR
Closes #49443
Type of change
What does this PR do?
supportsMediaInToolResultkeeps images inside tool results for every Bedrock model. Bedrock Converse only acceptstoolResultimages for Anthropic and Amazon Nova models (API reference); every other provider on Bedrock returns 400This model doesn't support the image field for user messages, and the session is stuck because the image stays in history.This changes the Bedrock branch to an allowlist on the model ID: Anthropic and Nova keep images in the tool result, everything else takes the existing hoist path that moves the image into a user message after the tool result. That path already exists for Bedrock PDFs and works on every model I tested (table in the linked issue: 4 OpenAI, 2 Mistral, Qwen, Gemma, Kimi, Grok all fail in
toolResultand succeed at user level).Related to #48069 / #48070, which fix GPT-6 Astra by ID. This covers the same Astra case plus the other providers.
How did you verify your code works?
bun test test/session/message-v2.test.tsinpackages/opencode: added a table test for Claude (keeps), Nova with and without theus.prefix (keeps), GPT-6 Astra (hoists), Pixtral (hoists). Confirmed each case fails when the guard is removed or made over-broad.opencode run --pureand thereadtool on a PNG:devHEAD fails onglobal.openai.gpt-5.6-solandgpt-6-astra; this branch answers "Red" on both, andus.anthropic.claude-sonnet-4-6still answers "Red".npx tsc --noEmitinpackages/opencode(only the pre-existingdialog-move-sessionerrors),oxlinton the two touched files: 0 errors.Screenshots / recordings
Not a UI change.
Checklist