Skip to content

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

Merged
gr2m merged 2 commits intorelease-v6.0from
backport-pr-14765-to-release-v6.0
Apr 30, 2026
Merged

Backport: fix(amazon-bedrock): drop foreign-provider reasoning blocks instead of sending them unsigned#14882
gr2m merged 2 commits intorelease-v6.0from
backport-pr-14765-to-release-v6.0

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

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

…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>
@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
Comment thread packages/amazon-bedrock/src/convert-to-bedrock-chat-messages.test.ts Outdated
@gr2m gr2m closed this Apr 30, 2026
auto-merge was automatically disabled April 30, 2026 22:51

Pull request was closed

@gr2m gr2m reopened this Apr 30, 2026
Two new tests called the non-existent `convertToAmazonBedrockChatMessages`
and one used `providerOptions.amazonBedrock` (which the source does not
parse for signatures), so both failed at runtime.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@gr2m gr2m enabled auto-merge (squash) April 30, 2026 23:00
@gr2m gr2m merged commit 471670b into release-v6.0 Apr 30, 2026
17 checks passed
@gr2m gr2m deleted the backport-pr-14765-to-release-v6.0 branch April 30, 2026 23:04
github-actions Bot added a commit that referenced this pull request Apr 30, 2026
@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 Author

⚠️ Backport to release-v5.0 created but has conflicts: #14885

gr2m added a commit that referenced this pull request May 1, 2026
gr2m added a commit that referenced this pull request May 1, 2026
…ing blocks instead of sending them unsigned (#14885)

This is an automated backport of #14882 to the release-v5.0 branch.

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants