fix(amazon-bedrock): return request.body from doGenerate and doStream#16969
Closed
xianjianlf2 wants to merge 1 commit into
Closed
fix(amazon-bedrock): return request.body from doGenerate and doStream#16969xianjianlf2 wants to merge 1 commit into
xianjianlf2 wants to merge 1 commit into
Conversation
…vercel#13927) `BedrockChatLanguageModel.doGenerate()` and `doStream()` never populated the `request` field (there was an explicit `// TODO request?`), so consumers relying on it for observability/tracing (e.g. Mastra) received `undefined` instead of the Converse API request payload. Return `request: { body: args }` from both methods, matching the behavior of other providers (`@ai-sdk/anthropic`, `@ai-sdk/google`, etc.). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
|
Marking as closed in favor of #17248 |
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.
Background
AmazonBedrockChatLanguageModel.doGenerate()anddoStream()never populated therequestfield of their result (there was an explicit// TODO request?indoStream). Consumers that rely onrequest.bodyfor observability/tracing — e.g. Mastra, which uses it to populate span inputs — receivedundefinedinstead of the Converse API request payload, resulting in empty tracing attributes.Other providers (
@ai-sdk/anthropic,@ai-sdk/google,@ai-sdk/cohere, …) already returnrequest: { body: args }, so this gap was specific to the Bedrock provider.Summary
request: { body: args }from bothdoGenerate()anddoStream()(whereargsis the Converse API command built bygetArgs()), matching the behavior of the other providers.// TODO request?marker.result.request?.bodycontains the request payload, and updated the affecteddoGenerateresult snapshots (purely additive — only the newrequestfield).Manual Verification
Verified with the provider's mock-server test harness (no live AWS credentials required):
should return the request bodytests assertresult.request?.bodyfor bothdoGenerateanddoStream. Their inline snapshots show the real Converse command (messages,system,additionalModelResponseFieldPaths, …) — i.e. the payload that was previouslyundefined.doGenerateresult snapshots confirmrequest.bodymatches the body actually sent to the mock server (server.calls[0].requestBodyJson).pnpm testinpackages/amazon-bedrock→ 132 passed.pnpm check(oxlint + oxfmt) clean, and@ai-sdk/amazon-bedrockbuilds with type declarations.Checklist
request.bodyis already part of theLanguageModelV4result contract, this only fixes the Bedrock provider to honor itpnpm changesetin the project root)Related Issues
Fixes #13927