Visitar URL original
fix(provider): port upstream Bedrock tool-result image hoisting (anomalyco/opencode#50272) by devin-ai-integration[bot] · Pull Request #1715 · AltimateAI/altimate-code · GitHub
Skip to content

fix(provider): port upstream Bedrock tool-result image hoisting (anomalyco/opencode#50272) - #1715

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1794419496-bedrock-tool-images
Open

devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1794419496-bedrock-tool-images

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #1713

Type of change

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

What does this PR do?

User-visible failure: on Amazon Bedrock, when a tool like read returns an image, the fork always left the image inside the tool result. Bedrock Converse only accepts tool-result images for Claude, Nova and Llama 4. Any other Bedrock model (e.g. openai.gpt-oss-*, Mistral Pixtral) fails the next turn with This model doesn't support the image field for user messages. The image stays in history, so every retry fails the same way.

Port of upstream anomalyco/opencode#50272 (fixes upstream #48069 / #49443). In MessageV2.toModelMessagesEffect, supportsMediaInToolResults now returns true for @ai-sdk/amazon-bedrock only when the model id contains anthropic., nova, llama4 or llama-4. Other Bedrock models fall through to the existing hoist path, which sends the media as a separate user message after the tool result (SYNTHETIC_ATTACHMENT_PROMPT). Claude, Nova and Llama 4 work exactly as before, including the existing PDF-in-tool-result behavior covered by preserves bedrock pdf tool-result media in tool output.

Difference from upstream: upstream had already moved this check to per-attachment and image-only. The fork still uses a per-model boolean, so I ported only the model-id gate. The change is wrapped in altimate_change start — upstream_fix: markers.

How did you verify your code works?

  • New bedrock tool-result images tests in test/session/message-v2.test.ts: images stay in the tool result for us.anthropic.claude-sonnet-4-6, amazon.nova-pro-v1:0 and us.meta.llama4-maverick-17b-instruct-v1:0, and are hoisted into a user message for openai.gpt-oss-120b-1:0 and mistral.pixtral-large-2502-v1:0. The hoist cases fail without the fix.
  • bun test test/session test/provider in packages/opencode: everything passes except 2 tests in tool-result-bigint.test.ts / session.test.ts (scratch store), which also fail on clean origin/main.
  • bun typecheck (turbo, 13/13) passes.
  • bun run script/upstream/analyze.ts --markers --base origin/main --strict passes. Since upstream/dev is now on the v2 layout, I also re-ran it against a v1.17.9 mirror: 1 shared file checked, properly marked.

Cost side effects

None. No new model calls, queries or resources.

Screenshots / recordings

N/A, no UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
  • I checked for cost side effects (model calls, queries or cloud resources that grow with user data) and described them, or wrote "none"

Tracked in #1478.

Written by Devin


Summary by cubic

Fixes Bedrock tool-result images being rejected on models that don't support media in tool results.

Bedrock Converse only accepts tool-result media for Claude, Nova, and Llama 4. Images now stay in the tool result for those models and are hoisted into a synthetic user message for all other Bedrock models, so the next turn no longer fails with This model doesn't support the image field for user messages.

Written for commit 4b75014. Summary will update on new commits.

View guided diff Turn on auto-fix

…alyco/opencode#50272)

Bedrock Converse only accepts media in tool results for Claude, Nova and
Llama 4; hoist tool-result media into a user message for other Bedrock
models.

Closes #1713

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Nov 11, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b01a7cb3-a281-4bfc-b58e-a826901d0d8b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@dev-punia-altimate

Copy link
Copy Markdown
Contributor

🤖 Code Review — OpenCodeReview (Gemini) — No Issues Found

No supported files changed.

This branch has not been deployed

No deployments
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 break non-Claude/Nova/Llama 4 models ("doesn't support the image field")

1 participant