Skip to content

bug(bedrock): cachePoint on messages with document blocks causes "nothing available to cache" error #17300

Closed as not planned

Description

@mq-canva

Description

Description

When a user message contains a PDF file attachment, Bedrock returns:

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

This happens because applyCaching in ProviderTransform adds cachePoint to the last 2 non-system messages unconditionally.

Bedrock's DocumentBlock content (PDFs, CSVs, etc.) does not count toward cacheable tokens, so when a cachePoint lands on a message whose primary content is a document, Bedrock rejects the request with a 400 ValidationException.

Images work because ImageBlock content IS counted as cacheable.

Error

{
  "name": "APIError",
  "data": {
    "message": "There is nothing available to cache. Please remove the invalid cache point and try again.",
    "statusCode": 400,
    "responseBody": "{\"message\":\"There is nothing available to cache. Please remove the invalid cache point and try again.\"}"
  }
}

Endpoint: .../model/global.anthropic.claude-opus-4-6-v1/converse-stream

Steps to reproduce

  1. Use any Bedrock Claude model
  2. Send a message with a PDF file attached
  3. Request fails with the above ValidationException

Root cause

packages/opencode/src/provider/transform.ts → applyCaching():

The function applies { bedrock: { cachePoint: { type: "default" } } } to the last 2 non-system messages regardless of content. Bedrock does not count DocumentBlock content as cacheable, so the cache point is invalid when it lands on a message whose content is primarily a document.

Proposed fix

Skip cachePoint for messages containing non-image file parts when targeting Bedrock:

for (const msg of unique([...system, ...final])) {
  if (
    model.providerID.includes("bedrock") &&
    Array.isArray(msg.content) &&
    msg.content.some(
      (part: any) =>
        part.type === "file" &&
        part.mediaType &&
        !part.mediaType.startsWith("image/")
    )
  ) {
    continue
  }
  // ... existing cache logic
}

Environment

  • Provider: Amazon Bedrock (converse-stream)
  • Model: global.anthropic.claude-opus-4-6-v1
  • Region: ap-southeast-2 (global inference profile)

Plugins

No response

OpenCode version

1.2.21

Steps to reproduce

  1. Configure a Bedrock Claude model (e.g. global.anthropic.claude-opus-4-6-v1)
  2. Send a message with a PDF file attached (via the API parts array with type: "file", mime: "application/pdf", and a data: URL)
  3. Request fails with ValidationException: "There is nothing available to cache. Please remove the invalid cache point and try again." (400)

Screenshot and/or share link

No response

Operating System

Linux (Ubuntu 22.04, kernel 6.8.0, x86_64, AWS)

Terminal

xterm-256color

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 13, 2026
  2. mq-canva commented on Mar 14, 2026

    @mq-canva
    Author

    Additional testing notes:

    Tested PDF upload across multiple models:

    • Claude Opus 4.6 (Global) / Claude Sonnet 4.6 (Global) — fails with the cache error described above. Since Bedrock officially added PDF support for Claude in June 2025, this confirms the failure is the cachePoint bug in OpenCode, not a model capability limitation.
    • GPT-5.4 — works fine
    • GPT-5.3 Codex — works fine
    • GPT-5.2 — fails with "does not support pdf input" — this is a separate model capability issue, unrelated to this bug

    The Claude/Bedrock failure is confirmed to be specific to the OpenCode ↔ Bedrock path. GPT-5.4 and GPT-5.3 Codex handle PDFs correctly via OpenCode with no changes needed.

  3. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  4. github-actions commented on Jul 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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