Repository navigation
fix(ai): merge Bedrock tool result messages - #41780
Merged
Merged
Conversation
kitlangton
marked this pull request as ready for review
August 11, 2026 17:03
24 of 30 tasks
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
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.
What
Merge adjacent canonical user and tool-result content when lowering requests for Bedrock Converse. This keeps every result for a parallel assistant tool-use response in the single immediately following Bedrock
usermessage required by the provider.Closes #41445
Before / After
Before: One assistant response with two parallel tool calls lowered as
assistant(toolUse x2),user(toolResult 1),user(toolResult 2). A live request against Amazon Nova Micro returned HTTP 400:Expected toolResult blocks at messages.2.content for the following Ids: weather_london.After: The same canonical history lowers as
assistant(toolUse x2),user(toolResult 1, toolResult 2). The recorded live request returned HTTP 200 and the model continued with the requested answer,Paris is sunny; London is rainy.How
packages/ai/src/protocols/bedrock-converse.tsappends lowered canonical user and tool content to an immediately preceding Bedrock user message.packages/ai/test/provider/bedrock-converse.test.tscovers the lowered wire shape and replays a real Bedrock continuation after two parallel tool results.packages/ai/test/fixtures/recordings/bedrock-converse/continues-after-parallel-tool-results.jsoncontains the redacted HTTP 200 Bedrock exchange.Scope
This only changes Bedrock Converse message lowering. It does not change canonical message construction or lowering for other providers.
Testing
964f7f4254: Bedrock HTTP 400 identifying the missing second tool result inmessages.2.content.RECORD=true RECORDED_TEST="continues after parallel tool results" bun run test test/provider/bedrock-converse.test.ts: Bedrock HTTP 200 and exact final answer.bun run test test/provider/bedrock-converse.test.ts: 44 pass, 0 fail.bun typecheckfrompackages/ai: passes.git diff --check: pass.bun turbo typecheck --concurrency=3: 33 tasks pass.