fix(provider): drop Bedrock assistant messages left with only unsigned reasoning

Closed
NA
2mo ago
+136-0

Issue for this PR

Closes #45620

Type of change

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

What does this PR do?

When a thinking stream dies mid-turn on Bedrock, the saved reasoning part has no signature (it arrives at the end of the block, so it never came). On replay the AI SDK drops unsigned reasoning, so the assistant message goes out with empty content — or as a lone cachePoint once applyCaching has stamped the last two messages. Bedrock rejects both with a non-retryable 400 ("There is nothing available to cache" / "content field is empty") and the session is wedged until the message drifts out of the cache window.

The fix drops those messages in ProviderTransform.message — scoped to @ai-sdk/amazon-bedrock, before applyCaching so cache points land on messages that survive. It works because the converter was discarding their content anyway... the model sees an identical request, just without the guaranteed 400. Same shape as the #14586 filters.

The root-cause fix is upstream (vercel/ai#19852), but that's on the @ai-sdk/amazon-bedrock 5.x line and opencode vendors 4.0.x, so this covers the gap. When the vendored package catches up this becomes harmless belt-and-braces.

How did you verify your code works?

Five new cases in transform.test.ts — the two drop behaviours fail without the fix; signed reasoning, mixed content, and other providers are untouched. 416/416 passing. Also ran dev from source against a real poisoned session (isolated XDG dirs): the exact 400 before the change, normal completion after, on global.anthropic.claude-fable-5.

Screenshots / recordings

Not a UI change.

Checklist

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