Skip to content

Backport: fix(amazon-bedrock): preserve empty text blocks when reasoning content is present#14189

Merged
vercel-ai-sdk[bot] merged 1 commit intorelease-v6.0from
backport-pr-14175-to-release-v6.0
Apr 7, 2026
Merged

Backport: fix(amazon-bedrock): preserve empty text blocks when reasoning content is present#14189
vercel-ai-sdk[bot] merged 1 commit intorelease-v6.0from
backport-pr-14175-to-release-v6.0

Conversation

@vercel-ai-sdk
Copy link
Copy Markdown
Contributor

@vercel-ai-sdk vercel-ai-sdk bot commented Apr 7, 2026

This is an automated backport of #14175 to the release-v6.0 branch. FYI @aayush-kapoor

…t is present (#14175)

## Background

#14071 

bedrock's claude models can return assistant messages with empty text
blocks sandwiched between reasoning blocks. their API strictly validates
that when you replay assistant messages in conversation history, the
content blocks must appear in the exact same order.

AI SDK was dropping those empty text blocks

## Summary

- Added a `hasReasoningBlocks` check so that empty text blocks are only
skipped when the message does not contain reasoning blocks. When
reasoning blocks are present, empty text blocks are preserved to
maintain correct indices.
- changed `if (part.text)` to `if (part.text != null)` : the old check
silently dropped empty text blocks from the response before they ever
entered the SDK's message history

## Manual Verification

na

## Checklist

- [x] Tests have been added / updated (for bug fixes / features)
- [ ] Documentation has been added / updated (for bug fixes / features)
- [x] A _patch_ changeset for relevant packages has been added (for bug
fixes / features - run `pnpm changeset` in the project root)
- [x] I have reviewed this pull request (self-review)

## Related Issues

fixes #14071
@vercel-ai-sdk vercel-ai-sdk bot enabled auto-merge (squash) April 7, 2026 14:56
@tigent tigent bot added ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label bug Something isn't working as documented provider/amazon-bedrock Issues related to the @ai-sdk/amazon-bedrock provider labels Apr 7, 2026
@vercel-ai-sdk vercel-ai-sdk bot merged commit ac80bc7 into release-v6.0 Apr 7, 2026
25 checks passed
@vercel-ai-sdk vercel-ai-sdk bot deleted the backport-pr-14175-to-release-v6.0 branch April 7, 2026 15:03
@vercel-ai-sdk
Copy link
Copy Markdown
Contributor Author

vercel-ai-sdk bot commented Apr 7, 2026

🚀 Published in:

Package Version
@ai-sdk/amazon-bedrock 4.0.91

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

Labels

ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label bug Something isn't working as documented provider/amazon-bedrock Issues related to the @ai-sdk/amazon-bedrock provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant