Skip to content

fix(amazon-bedrock): drop foreign-provider reasoning blocks instead of sending them unsigned#14765

Merged
dancer merged 1 commit intovercel:mainfrom
thestonechat:fix-bedrock-foreign-reasoning
Apr 30, 2026
Merged

fix(amazon-bedrock): drop foreign-provider reasoning blocks instead of sending them unsigned#14765
dancer merged 1 commit intovercel:mainfrom
thestonechat:fix-bedrock-foreign-reasoning

Conversation

@thestonechat
Copy link
Copy Markdown
Contributor

Background

When a conversation contains reasoning blocks signed by a different provider
(e.g. Anthropic-signed reasoning replayed through Bedrock during cross-provider
fallback), the converter pushes the reasoning text without a signature, and
Bedrock's converse API rejects the request with:

messages.N.content.M.thinking.signature: Field required

@ai-sdk/anthropic already handles the symmetric case gracefully — it drops
unrecognized reasoning metadata and emits a warning.

Fix

In the case 'reasoning' branch of convertToBedrockChatMessages, only fall
through to the unsigned-reasoning push when providerOptions is empty or
contains exclusively the bedrock key. Foreign-provider metadata (e.g.
anthropic) causes the block to be dropped instead.

This preserves the existing prefill behavior introduced in #13972 while
fixing the cross-provider replay case.

Repro

A conversation that has assistant turns with providerOptions.anthropic
on its reasoning parts, sent through bedrock(...).doStream(...), currently
reproduces the validation error. The added test covers this.

After gh pr create runs, it'll print the PR URL. CI will run automatically; the CLA bot will comment with a sign link if you
haven't signed before.

@tigerabrodi
Copy link
Copy Markdown

good stuff.

Comment thread packages/amazon-bedrock/src/convert-to-amazon-bedrock-chat-messages.ts Outdated
@dancer dancer disabled auto-merge April 30, 2026 21:40
@dancer dancer force-pushed the fix-bedrock-foreign-reasoning branch from 149e6e6 to 96307a7 Compare April 30, 2026 21:42
@dancer dancer merged commit ef05c24 into vercel:main Apr 30, 2026
18 checks passed
@gr2m gr2m added the backport Admins only: add this label to a pull request in order to backport it to the prior version label Apr 30, 2026
github-actions Bot added a commit that referenced this pull request Apr 30, 2026
…f sending them unsigned (#14765)

## Background

When a conversation contains reasoning blocks signed by a different
provider
(e.g. Anthropic-signed reasoning replayed through Bedrock during
cross-provider
fallback), the converter pushes the reasoning text without a signature,
and
  Bedrock's converse API rejects the request with:

    messages.N.content.M.thinking.signature: Field required

`@ai-sdk/anthropic` already handles the symmetric case gracefully — it
drops
  unrecognized reasoning metadata and emits a warning.

  ## Fix

In the `case 'reasoning'` branch of `convertToBedrockChatMessages`, only
fall
through to the unsigned-reasoning push when `providerOptions` is empty
or
contains exclusively the `bedrock` key. Foreign-provider metadata (e.g.
  `anthropic`) causes the block to be dropped instead.

This preserves the existing prefill behavior introduced in #13972 while
  fixing the cross-provider replay case.

  ## Repro

A conversation that has assistant turns with `providerOptions.anthropic`
on its reasoning parts, sent through `bedrock(...).doStream(...)`,
currently
  reproduces the validation error. The added test covers this.

After gh pr create runs, it'll print the PR URL. CI will run
automatically; the CLA bot will comment with a sign link if you
  haven't signed before.

Co-authored-by: asdf <asdfsdf>
@github-actions github-actions Bot removed the backport Admins only: add this label to a pull request in order to backport it to the prior version label Apr 30, 2026
@github-actions
Copy link
Copy Markdown
Contributor

✅ Backport PR created: #14882

gr2m added a commit that referenced this pull request Apr 30, 2026
…f sending them unsigned (#14882)

This is an automated backport of #14765 to the release-v6.0 branch. FYI
@thestonechat

---------

Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants