Skip to content

[v6.0] fix(amazon-bedrock): support reasoningContent.redactedContent from the Converse API - #19139

Merged
gr2m merged 2 commits into
release-v6.0from
backport-19062-20260819223701240466
Aug 19, 2026
Merged

gr2m merged 2 commits into
release-v6.0from
backport-19062-20260819223701240466

Conversation

@ai-sdk-factory

Copy link
Copy Markdown
Contributor

Background

redactedContent is the second member of the documented ReasoningContentBlock union (reasoningText | redactedContent) and a member of ReasoningContentBlockDelta, but neither the response schema nor the stream schema accepts it. Models that emit it — e.g. OpenAI models on Converse such as us.openai.gpt-5.6-luna, which return their encrypted reasoning in this shape alongside tool calls — currently fail validation:

  • generateText / generateObject with tools throw AI_APICallError: Invalid JSON response on an HTTP 200 response, making tool calling unusable
  • streamText with tools emits a spurious AI_TypeValidationError error part on every request and loses the reasoning block

Summary

  • Both Zod schemas accept redactedContent (response ReasoningContentBlock and stream contentBlockDelta.delta).
  • The payload is surfaced as a reasoning part carrying providerMetadata.{amazonBedrock,bedrock}.redactedContent, mirroring how redactedReasoning is surfaced today.
  • convert-to-amazon-bedrock-chat-messages replays it as reasoningContent: { redactedContent } on subsequent turns.
  • Streaming deltas are accumulated in the content-block state and attached once via 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.
  • Existing redactedReasoning / data handling 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 test in packages/amazon-bedrock: 465 tests pass. The new tests (response mapping, stream accumulation across split deltas, multi-block separation, replay conversion) fail without the fix.
  • End-to-end against real Bedrock (us-east-1, us.openai.gpt-5.6-luna), both doGenerate and doStream: turn 1 surfaces the reasoning part with redactedContent metadata, the turn-2 request contains the replayed reasoningContent.redactedContent block on the wire, no error parts, and the model answers from its restored reasoning state.

Tasks

  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features) — provider docs describe reasoning provider metadata generically; no doc change needed
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • Formatting issues have been fixed (run pnpm prettier-fix in 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 legacy redactedReasoning / data paths 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

@gr2m
gr2m merged commit 3fadddb into release-v6.0 Aug 19, 2026
54 checks passed
@gr2m
gr2m deleted the backport-19062-20260819223701240466 branch August 19, 2026 23:22
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Published in:

Package Version
ai 6.0.260 github npm
@ai-sdk/amazon-bedrock 4.0.158 github npm
@ai-sdk/angular 2.0.261 github npm
@ai-sdk/google 3.0.111 github npm
@ai-sdk/google-vertex 4.0.185 github npm
@ai-sdk/langchain 2.0.268 github npm
@ai-sdk/llamaindex 2.0.260 github npm
@ai-sdk/react 3.0.263 github npm
@ai-sdk/rsc 2.0.260 github npm
@ai-sdk/svelte 4.0.260 github npm
@ai-sdk/vue 3.0.260 github npm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants