Skip to content

Bedrock: forked chat's first turn fails with 400 'nothing available to cache' #45855

Description

@jangraviren

Description

Forking a chat and sending the first message fails on Claude-on-Bedrock with:

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

applyCaching() in packages/opencode/src/provider/transform.ts always stamps a Bedrock cachePoint, even when the prompt is below Bedrock's minimum cacheable size (~1024 tokens for Claude). A freshly-forked session's first turn is under that minimum, so Bedrock rejects the whole request instead of just running without a cache hit. The Anthropic API ignores an undersized cache_control; Bedrock hard-errors.

Steps to reproduce

  1. Use a Claude model via @ai-sdk/amazon-bedrock.
  2. Fork a chat (creates a new, short session).
  3. Send a short first message.
  4. Request fails with HTTP 400 "nothing available to cache".

OpenCode version

1.18.24

Operating System

macOS

Activity

  1. github-actions commented on Aug 28, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. Haarris commented on Oct 6, 2026

    @Haarris

    I don't think prompt size is the cause here. AWS documents that an undersized checkpoint is not an error: "If you add a cache checkpoint before the total prompt prefix meets the minimum number of tokens, your inference still succeeds, but your prefix isn't cached." Also a fork isn't a short prompt. Session.fork copies all earlier messages and parts (session.ts, around line 691), and the system prompt alone is over 1024 tokens.

    In this repo, "nothing available to cache" has come from a cachePoint landing on a message that ends up with no cacheable content. #45620 (unsigned reasoning dropped on replay, leaving a lone cachePoint) and #17300 (PDF/document parts) were both that. applyCaching() in transform.ts still stamps the last two non-system messages without checking what is left in them.

    Could you capture the outgoing Converse body for the failing turn? I'd expect one of the last two messages to contain only a cachePoint, or a cachePoint plus a document block. Skipping the cachePoint when a message has no text, image or tool content would fix the real cause.

  3. opencode-agent commented on Oct 6, 2026

    @opencode-agent
    Contributor

    Thanks for the report. OpenCode 2 has a rewritten Amazon Bedrock integration that places each cache point directly after the content it caches (text, tool definitions, or tool results). It never adds one after a reasoning block or leaves one on a message with nothing cacheable. We tested forked sessions with Claude on Bedrock in V2, including a session whose last turn was interrupted mid-thinking, and couldn't reproduce this error, so we're closing this issue in favor of V2.

    Updating to V2

    V1 and V2 both install the opencode command and aren't installed side by side. If you installed V1 with a package manager (Homebrew, npm, etc.), remove it first. The curl installer replaces the V1 binary.

    # curl
    curl -fsSL https://opencode.ai/v2/install | bash
    
    # Homebrew
    brew install anomalyco/tap/opencode-v2
    
    # npm
    npm install -g @opencode/cli

    Other install methods (Bun, pnpm, Yarn, AUR, standalone binaries, Desktop) are listed at https://opencode.ai/v2/docs/.

    Your existing opencode.json config, agents, commands and skills should keep working as is, and your amazon-bedrock credentials don't need to change. Plugins and server API integrations do need porting. See the migration guide: https://opencode.ai/v2/docs/migrate-v1/

    If you still hit There is nothing available to cache on V2, please open a new issue with the V2 version and the failing request from the logs (~/.local/share/opencode/log/opencode.log, with credentials redacted).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions