Repository navigation
[v6.0] fix(amazon-bedrock): support reasoningContent.redactedContent from the Converse API - #19139
Merged
Merged
Conversation
Co-authored-by: Gregor Martynus <[email protected]>
gr2m
approved these changes
Aug 19, 2026
Contributor
|
🚀 Published in:
|
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
redactedContentis the second member of the documentedReasoningContentBlockunion (reasoningText | redactedContent) and a member ofReasoningContentBlockDelta, but neither the response schema nor the stream schema accepts it. Models that emit it — e.g. OpenAI models on Converse such asus.openai.gpt-5.6-luna, which return their encrypted reasoning in this shape alongside tool calls — currently fail validation:generateText/generateObjectwith tools throwAI_APICallError: Invalid JSON responseon an HTTP 200 response, making tool calling unusablestreamTextwith tools emits a spuriousAI_TypeValidationErrorerror part on every request and loses the reasoning blockSummary
redactedContent(responseReasoningContentBlockand streamcontentBlockDelta.delta).reasoningpart carryingproviderMetadata.{amazonBedrock,bedrock}.redactedContent, mirroring howredactedReasoningis surfaced today.convert-to-amazon-bedrock-chat-messagesreplays it asreasoningContent: { redactedContent }on subsequent turns.reasoning-end: a reasoning part's merged provider metadata is last-write-wins, so per-delta metadata would drop earlier chunks if the payload ever arrives split.redactedReasoning/datahandling is left untouched.Surfacing + replay (rather than accept-and-drop) matters because the encrypted payload restores the model's reasoning state across tool-use turns. Verified against the raw Converse API with a two-turn tool conversation: replaying the block verbatim yields a correct answer from restored state (22 output tokens); stripping it forces the model to re-reason from scratch (509 output tokens) and it loses its earlier conclusion. Replaying via the legacy
redactedReasoning: { data }shape is silently ignored by the current API, so a dedicated replay path for the documented shape is required.Verification
pnpm testinpackages/amazon-bedrock: 465 tests pass. The new tests (response mapping, stream accumulation across split deltas, multi-block separation, replay conversion) fail without the fix.us-east-1,us.openai.gpt-5.6-luna), bothdoGenerateanddoStream: turn 1 surfaces the reasoning part withredactedContentmetadata, the turn-2 request contains the replayedreasoningContent.redactedContentblock on the wire, no error parts, and the model answers from its restored reasoning state.Tasks
pnpm changesetin the project root)pnpm prettier-fixin the project root)Future Work
Anthropic models' redacted reasoning on the current Converse API is also documented as
redactedContent; this change covers them as well, while keeping the legacyredactedReasoning/datapaths for compatibility.Related Issues
Closes #19062 (full reproduction and multi-turn replay measurements). Related: #19024 (closed; streaming variant of this validation error), #14720 (precedent for OpenAI-on-Converse reasoning handling).
Closes #19115
Backport of #19058