fix(provider): filter empty text content blocks for Bedrock#15777
fix(provider): filter empty text content blocks for Bedrock#15777zerone0x wants to merge 1 commit intoanomalyco:devfrom
Conversation
AWS Bedrock rejects messages containing empty text content blocks with 'ValidationException: messages: text content blocks must be non-empty'. The empty-content filter in normalizeMessages() was only applied to the @ai-sdk/anthropic provider. Extend it to also cover @ai-sdk/amazon-bedrock which has the same API constraint. Fixes anomalyco#15715
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: I found a potentially related PR: Related PR:
This appears to be addressing the exact same issue as the current PR #15777. Both are about filtering empty content blocks for the Bedrock provider. You should verify whether #14586 was already merged or closed, and if so, whether the current PR (#15777) is based on or supersedes it. |
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
Summary
Fixes #15715
Fixes #13811
Problem
AWS Bedrock rejects API requests that contain empty text content blocks with:
Root Cause
normalizeMessages()intransform.tsalready filters out empty text/reasoning content blocks — but the guard only applied to@ai-sdk/anthropic. AWS Bedrock (@ai-sdk/amazon-bedrock) has the same constraint on the API level, so it was silently passing empty blocks through.Fix
Extend the existing empty-content filter to cover
@ai-sdk/amazon-bedrockas well:Tests
Added a new
describeblock mirroring the Anthropic empty-content filtering tests for Bedrock, covering: