Repository navigation
fix(provider): port upstream Bedrock tool-result image hoisting (anomalyco/opencode#50272) - #1715
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…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>
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
25 of 71 tasks
Contributor
🤖 Code Review — OpenCodeReview (Gemini) — No Issues FoundNo supported files changed. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #1713
Type of change
What does this PR do?
User-visible failure: on Amazon Bedrock, when a tool like
readreturns 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 withThis 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,supportsMediaInToolResultsnow returns true for@ai-sdk/amazon-bedrockonly when the model id containsanthropic.,nova,llama4orllama-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 bypreserves 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?
bedrock tool-result imagestests intest/session/message-v2.test.ts: images stay in the tool result forus.anthropic.claude-sonnet-4-6,amazon.nova-pro-v1:0andus.meta.llama4-maverick-17b-instruct-v1:0, and are hoisted into a user message foropenai.gpt-oss-120b-1:0andmistral.pixtral-large-2502-v1:0. The hoist cases fail without the fix.bun test test/session test/providerinpackages/opencode: everything passes except 2 tests intool-result-bigint.test.ts/session.test.ts(scratch store), which also fail on cleanorigin/main.bun typecheck(turbo, 13/13) passes.bun run script/upstream/analyze.ts --markers --base origin/main --strictpasses. Sinceupstream/devis 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
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.