Skip to content

Bedrock: assistant message with only a cachePoint still sent after unsigned reasoning is filtered → 400 "There is nothing available to cache" #19851

Closed

Description

@nabilfreeman

Description

#18456 fixed assistant messages going out empty after unsigned reasoning is dropped — but there's a sibling case that still bricks conversations.

If the filtered-out message carries a cachePoint provider option, the new guard sees [{ cachePoint }], length 1, and sends it anyway. Bedrock rejects it, non-retryable:

There is nothing available to cache. Please remove the invalid cache point and try again.

Same story as #18452 from there... the poisoned turn stays in history and every following request fails.

This happens in the wild: opencode stamps cache points on the last two messages, so any assistant turn aborted mid-thinking hits this (anomalyco/opencode#11210 has both error strings).

Reproduction

Same as #18452's repro, just add the provider option to the assistant message:

{
  role: 'assistant',
  content: [{ type: 'reasoning', text: 'Let me consider the options' }], // aborted turn, no signature
  providerOptions: { bedrock: { cachePoint: { type: 'default' } } },
},

The outgoing request contains an assistant message with content: [{"cachePoint":{"type":"default"}}]. I sent that exact payload to the live Converse API and it 400s with the message above.

Expected behavior

A message whose only remaining content is a cache point should be omitted, same as the empty case #18456 already handles. Dropping it is safe — I also checked that Converse accepts consecutive user messages, which is what's left behind.

Happy to PR, it's a one-line change to the #18456 guard.

AI SDK Version

  • @ai-sdk/amazon-bedrock current main (also verified on 5.0.43+)

Activity

  1. ai-sdk-factory commented on Aug 27, 2026

    @ai-sdk-factory
    Contributor

    Identify issue type

    Identified as Bug
    Confidence: High

    Rationale

    The issue describes a concrete failure in existing Amazon Bedrock provider behavior: filtering unsigned reasoning can leave a cachePoint-only assistant message that is invalid for Bedrock and breaks the conversation.

    Evidence

    • Unsigned assistant reasoning is filtered out, but its Bedrock cachePoint remains and causes the otherwise empty message to be sent.
    • The resulting Converse API payload returns a non-retryable 400: "There is nothing available to cache."
    • The reporter provides a concrete reproduction and states that subsequent requests continue failing because the invalid turn remains in history.
    • This is presented as an unhandled sibling case of a previously fixed empty-message bug.
  2. ai-sdk-factory commented on Aug 27, 2026

    @ai-sdk-factory
    Contributor

    Bug Reproduction - AI SDK 7

    Bug was reproduced.

    Branch: main
    PR: successful reproduction pull request

    Details

    • On @ai-sdk/amazon-bedrock 5.0.66, examples/ai-functions/src/reproduction/amazon-bedrock-cache-point-only-assistant.ts sent a cachePoint-only assistant message after filtering unsigned reasoning; two consecutive follow-up requests received Bedrock's non-retryable 400 instead of completing.
    • A direct Converse request with the malformed assistant message returned 400, while the equivalent request omitting that message and retaining consecutive user messages returned 200, locating the defect in AI SDK request construction.
    • packages/amazon-bedrock/src/convert-to-amazon-bedrock-chat-messages.test.ts now contains a regression test expecting the cachePoint-only assistant message to be omitted; it fails because the converter retains that message.
    • packages/amazon-bedrock/src/__fixtures__/amazon-bedrock-cache-point-only-assistant-error.json records the exact live Bedrock error response.

    Relevant Documentation

  3. added a commit that references this issue on Aug 27, 2026
    471c0f3
  4. ai-sdk-factory commented on Aug 27, 2026

    @ai-sdk-factory
    Contributor

    Bugfix - AI SDK 7

    Created bugfix and opened PR: #19858

    Root Cause

    The assistant-message guard checked only whether converted content was non-empty. Adding a cache point made the array non-empty after unsigned reasoning was filtered, so the invalid message remained; the failing regression test confirmed the exact malformed output.

    Summary

    The Bedrock converter now emits assistant messages only when at least one non-cache-point content block remains. Reproduction artifacts were removed and a patch changeset was added.

    Testing

    Added regression coverage verifying that unsigned reasoning with a cache point is omitted while surrounding user messages remain.

  5. nabilfreeman commented on Aug 27, 2026

    @nabilfreeman
    ContributorAuthor

    @ai-sdk-factory I thought my PR was already good? #19852

  6. added a commit that references this issue on Aug 27, 2026
    030b4e1
  7. ai-sdk-factory commented on Aug 27, 2026

    @ai-sdk-factory
    Contributor

    Bug Reproduction - AI SDK 6

    Bug was reproduced.

    Branch: release-v6.0
    PR: successful reproduction pull request

    Details

    • The live Bedrock reproduction in examples/ai-functions/src/reproduction/amazon-bedrock-cache-point-only-assistant.ts observed two consecutive HTTP 400 responses because the outgoing assistant message contained only {"cachePoint":{"type":"default"}}; both requests should complete after that empty assistant turn is omitted.
    • packages/amazon-bedrock/src/convert-to-bedrock-chat-messages.ts filters unsigned reasoning but retains the message-level cache point, and its non-empty-array guard consequently emits the invalid assistant message.
    • The regression test added to packages/amazon-bedrock/src/convert-to-bedrock-chat-messages.test.ts expects the cache-point-only assistant turn to be omitted while preserving both user inputs, but currently fails because all three turns are emitted.
    • packages/amazon-bedrock/src/__fixtures__/amazon-bedrock-cache-point-only-assistant-error.json records the exact live Bedrock validation response.

    Relevant Documentation

  8. ai-sdk-factory commented on Aug 27, 2026

    @ai-sdk-factory
    Contributor

    Bug Reproduction - AI SDK 5

    Bug was reproduced.

    Branch: release-v5.0
    PR: successful reproduction pull request

    Details

    • On release-v5 with @ai-sdk/amazon-bedrock 3.0.125, examples/ai-functions/src/reproduction/amazon-bedrock-cache-point-only-assistant.ts sent a cachePoint-only assistant message after filtering unsigned reasoning; two consecutive follow-up requests received Bedrock 400 responses stating "There is nothing available to cache."
    • The equivalent history with the filtered assistant turn omitted completed successfully, confirming the expected behavior and locating the defect in AI SDK request construction rather than credentials or model configuration.
    • packages/amazon-bedrock/src/convert-to-bedrock-chat-messages.test.ts adds a regression assertion that the assistant turn is omitted and surrounding user content is retained; it fails because the converter emits content: [{ cachePoint: { type: 'default' } }].
    • packages/amazon-bedrock/src/__fixtures__/amazon-bedrock-cache-point-only-assistant-error.json records the exact live Bedrock error response.
    • examples/ai-functions/package.json and pnpm-lock.yaml provide the workspace setup required to replay the live reproduction.

    Relevant Documentation

  9. ai-sdk-factory commented on Aug 27, 2026

    @ai-sdk-factory
    Contributor

    Backport to v6.0

    created: #19888 (fixed merge).

  10. github-actions commented on Aug 28, 2026

    @github-actions
    Contributor

    🚀 Published in:

    Package Version
    ai 7.0.84 github npm
    @ai-sdk/alibaba 2.0.38 github npm
    @ai-sdk/amazon-bedrock 5.0.67 github npm
    @ai-sdk/angular 3.0.84 github npm
    @ai-sdk/anthropic 4.0.45 github npm
    @ai-sdk/anthropic-aws 2.0.37 github npm
    @ai-sdk/assemblyai 3.0.33 github npm
    @ai-sdk/azure 4.0.53 github npm
    @ai-sdk/baseten 2.1.18 github npm
    @ai-sdk/black-forest-labs 2.0.34 github npm
    @ai-sdk/bytedance 2.0.36 github npm
    @ai-sdk/cartesia 3.0.28 github npm
    @ai-sdk/cerebras 3.0.40 github npm
    @ai-sdk/code-mode 1.0.41 github npm
    @ai-sdk/cohere 4.0.34 github npm
    @ai-sdk/deepgram 3.1.4 github npm
    @ai-sdk/deepinfra 3.0.40 github npm
    @ai-sdk/deepseek 3.0.36 github npm
    @ai-sdk/elevenlabs 3.0.34 github npm
    @ai-sdk/fal 3.0.34 github npm
    @ai-sdk/fireworks 3.0.43 github npm
    @ai-sdk/fish-audio 3.0.11 github npm
    @ai-sdk/gateway 4.0.68 github npm
    @ai-sdk/gladia 3.0.33 github npm
    @ai-sdk/gmicloud 3.0.11 github npm
    @ai-sdk/google 4.0.57 github npm
    @ai-sdk/google-vertex 5.0.69 github npm
    @ai-sdk/groq 4.0.34 github npm
    @ai-sdk/harness 1.0.93 github npm
    @ai-sdk/harness-acp 1.0.31 github npm
    @ai-sdk/harness-claude-code 1.0.97 github npm
    @ai-sdk/harness-cline 1.0.20 github npm
    @ai-sdk/harness-codex 1.0.95 github npm
    @ai-sdk/harness-cursor 1.0.6 github npm
    @ai-sdk/harness-deepagents 1.0.93 github npm
    @ai-sdk/harness-fx 1.0.6 github npm
    @ai-sdk/harness-grok-build 1.0.30 github npm
    @ai-sdk/harness-opencode 1.0.95 github npm
    @ai-sdk/harness-pi 1.0.95 github npm
    @ai-sdk/huggingface 2.0.40 github npm
    @ai-sdk/hume 3.0.33 github npm
    @ai-sdk/klingai 4.0.35 github npm
    @ai-sdk/langchain 3.0.84 github npm
    @ai-sdk/llamaindex 3.0.84 github npm
    @ai-sdk/lmnt 3.0.33 github npm
    @ai-sdk/luma 3.0.34 github npm
    @ai-sdk/mcp 2.0.40 github npm
    @ai-sdk/minimax 3.0.21 github npm
    @ai-sdk/mistral 4.0.36 github npm
    @ai-sdk/moonshotai 3.0.42 github npm
    @ai-sdk/open-responses 2.0.35 github npm
    @ai-sdk/openai 4.0.51 github npm
    @ai-sdk/openai-compatible 3.0.40 github npm
    @ai-sdk/otel 1.0.84 github npm
    @ai-sdk/perplexity 4.0.35 github npm
    @ai-sdk/policy-opa 1.0.84 github npm
    @ai-sdk/prodia 2.0.34 github npm
    @ai-sdk/provider-utils 5.0.33 github npm
    @ai-sdk/quiverai 2.0.33 github npm
    @ai-sdk/react 4.0.87 github npm
    @ai-sdk/replicate 3.0.34 github npm
    @ai-sdk/revai 3.0.33 github npm
    @ai-sdk/rsc 3.0.84 github npm
    @ai-sdk/sandbox-just-bash 1.0.93 github npm
    @ai-sdk/sandbox-vercel 1.0.93 github npm
    @ai-sdk/svelte 5.0.84 github npm
    @ai-sdk/togetherai 3.0.41 github npm
    @ai-sdk/tui 1.0.85 github npm
    @ai-sdk/valibot 3.0.33 github npm
    @ai-sdk/voyage 2.0.33 github npm
    @ai-sdk/vue 4.0.84 github npm
    @ai-sdk/workflow 2.0.14 github npm
    @ai-sdk/workflow-harness 1.0.93 github npm
    @ai-sdk/xai 4.0.49 github npm
    @ai-sdk/zai 3.0.2 github npm
  11. added a commit that references this issue on Aug 28, 2026
    ada21b6
  12. ai-sdk-factory commented on Aug 28, 2026

    @ai-sdk-factory
    Contributor

    Backport to v5.0

    created: #19940 (fixed merge).

  13. added a commit that references this issue on Aug 28, 2026
    07ef4be
  14. added
    discovery:auditDiscovered through source review, isolated tests, or exploratory probes; no production incident.
    on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions