Skip to content

Comments

fix: filter empty content blocks for Bedrock provider#14586

Open
Tom-Ryder wants to merge 1 commit intoanomalyco:devfrom
Tom-Ryder:fix/bedrock-empty-content
Open

fix: filter empty content blocks for Bedrock provider#14586
Tom-Ryder wants to merge 1 commit intoanomalyco:devfrom
Tom-Ryder:fix/bedrock-empty-content

Conversation

@Tom-Ryder
Copy link

@Tom-Ryder Tom-Ryder commented Feb 21, 2026

Issue for this PR

Closes #11210

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

normalizeMessages() filters empty text/reasoning parts for @ai-sdk/anthropic but not @ai-sdk/amazon-bedrock. The Bedrock Converse API has the same constraint — empty content arrays cause "content field is empty" and invalid cache point errors that permanently break the session. Extended the existing guard to also cover Bedrock.

Note: this fixes the empty content filtering side of #11210. The separate Bedrock ConverseAPI tool call issues flagged in the thread will need a follow-up.

How did you verify your code works?

  • bun turbo typecheck passes
  • Added 6 tests mirroring the existing anthropic empty content filtering suite, all pass
  • Existing tests unchanged and passing

Screenshots / recordings

N/A — backend logic change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found related PRs but no direct duplicates of PR #14586:

Related PRs:

  1. PR fix(provider): trim whitespace and filter empty content in transformations #7086 - "fix(provider): trim whitespace and filter empty content in transformations"

    • Addresses similar empty content filtering but appears to be from an earlier iteration
  2. PR fix: expand Anthropic detection and strip whitespace-only text blocks #12634 - "fix: expand Anthropic detection and strip whitespace-only text blocks"

    • Related to the anthropic filtering mentioned in your PR description
  3. PR fix: strip incompatible thinking blocks when switching to Claude (improved) #11882 - "fix: strip incompatible thinking blocks when switching to Claude (improved)"

    • Part of the broader content filtering effort for different providers

These are related to content filtering improvements, but none appear to be addressing the exact same issue (filtering empty content blocks for Bedrock specifically with the normalizeMessages() function).

No duplicate PRs found

@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

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.

Kimi K2 via AWS BEDROCK stops execution

1 participant