FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(provider): drop Bedrock assistant messages left with only unsigned reasoning by nabilfreeman · Pull Request #45621 · anomalyco/opencode · GitHub

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

Closed
nabilfreeman wants to merge 1 commit into
anomalyco:devfrom
nabilfreeman:fix/bedrock-unsigned-reasoning-only-messages
Closed

fix(provider): drop Bedrock assistant messages left with only unsigned reasoning#45621
nabilfreeman wants to merge 1 commit into
anomalyco:devfrom
nabilfreeman:fix/bedrock-unsigned-reasoning-only-messages

Conversation

nabilfreeman commented Aug 27, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

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

…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.
github-actions Bot added contributor needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Aug 27, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Copy link
Copy Markdown
Contributor

Closed in favor of #45769

neriousy closed this Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bedrock: aborted thinking turn bricks the session — "There is nothing available to cache" / "content field is empty"

2 participants


Back | FazBrowse Home | New Git URL