Skip to content

fix(session): only keep Bedrock tool-result images for Anthropic and Nova models - #49444

Open
alohaninja wants to merge 2 commits into
anomalyco:devfrom
alohaninja:fix/bedrock-openai-toolresult-image
Open

alohaninja wants to merge 2 commits into
anomalyco:devfrom
alohaninja:fix/bedrock-openai-toolresult-image

Conversation

@alohaninja

@alohaninja alohaninja commented Sep 17, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #49443

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

supportsMediaInToolResult keeps images inside tool results for every Bedrock model. Bedrock Converse only accepts toolResult images for Anthropic and Amazon Nova models (API reference); 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.

image

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 toolResult and 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.ts in packages/opencode: added a table test for Claude (keeps), Nova with and without the us. prefix (keeps), GPT-6 Astra (hoists), Pixtral (hoists). Confirmed each case fails when the guard is removed or made over-broad.
  • Live against Bedrock us-east-1 with opencode run --pure and the read tool on a PNG: dev HEAD fails on global.openai.gpt-5.6-sol and gpt-6-astra; this branch answers "Red" on both, and us.anthropic.claude-sonnet-4-6 still answers "Red".
  • npx tsc --noEmit in packages/opencode (only the pre-existing dialog-move-session errors), oxlint on the two touched files: 0 errors.

Screenshots / recordings

Not a UI change.

pr49444-bedrock-toolresult-allowlist

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…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>
@github-actions

Copy link
Copy Markdown
Contributor

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.

@alohaninja

alohaninja commented Sep 17, 2026

Copy link
Copy Markdown
Author

Correct on both. #48070 covers Astra by ID. #49197 is the maintainer-side fix and covers more families with a denylist (moonshotai|nvidia|openai|qwen|xai).

The difference here is the shape of the guard. Bedrock documents toolResult.image as an allowlist — "only supported by Amazon Nova and Anthropic Claude 3 and 4 models" (API reference) — and testing against us-east-1 found two families the #49197 denylist misses: mistral.pixtral-large-2502-v1:0 / mistral.mistral-large-3-675b-instruct and google.gemma-3-27b-it both return the same 400. Full table in #49443.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bedrock: tool-result images rejected for all non-Anthropic/Nova models

1 participant