| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
…d reasoning
When a thinking stream dies mid-turn on Bedrock, the persisted reasoning
part has no signature (it arrives at the end of the block). On replay the
@ai-sdk/amazon-bedrock converter drops unsigned reasoning, so the assistant
message reaches Bedrock with empty content — or, once applyCaching stamps
the last two messages, as a lone cachePoint block. Both are non-retryable
400s ('The content field in the Message object is empty' / 'There is
nothing available to cache') that repeat until the message leaves the
last-2 cache window, wedging the session.
Drop such messages in ProviderTransform.message, scoped to
@ai-sdk/amazon-bedrock, before applyCaching so cache points land on
messages that survive. The converter discards their content anyway, so the
model sees an identical request. Same shape as the empty-content filters
from anomalyco#14586.
The root-cause fix is upstream (vercel/ai#19852), but it lands on the
@ai-sdk/amazon-bedrock 5.x line while opencode vendors 4.0.x, so this
covers the gap.
Verified end-to-end against a real poisoned session on dev: the exact 400
without this change, normal completion with it. Unit tests cover the drop,
signed-reasoning and mixed-content keeps, cache point placement, and
other-provider scoping.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Issue for this PR
Closes #45620
Type of change
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