Skip to content

DigitalOcean Anthropic models (Claude Fable, etc.) never hit prompt cache in v2 #51557

Closed

Description

@Xowap

Description

In OpenCode v2, DigitalOcean models (cataloged with "npm": "@ai-sdk/openai-compatible") are routed through @opencode/ai/providers/openai-compatible.

Because openai-compatible-chat is not in RESPECTS_INLINE_HINTS in packages/ai/src/cache-policy.ts, and OpenAIChat.protocol does not pass cacheControl by default, requests are sent to DigitalOcean's /v1/chat/completions with plain text messages and no cache_control breakpoints.

While open-source models on DigitalOcean (like DeepSeek V4.1 Flash) perform automatic KV-cache prefix matching on raw prompts, Anthropic models served through DigitalOcean (Claude Fable 5.1, Claude Fable 5, Sonnet, Opus, Haiku) strictly require explicit cache_control: { type: "ephemeral" } markers to activate prompt caching.

Without cache_control, every single turn and tool step in an agent session resends the entire conversation transcript without cache markers, meaning 100% of input tokens are invoiced at the full rate ($10.00 / 1M on Fable instead of $0.25 / 1M cache read rate).

In OpenCode v1, applyCaching() in packages/opencode/src/provider/transform.ts checked if the model ID contained "anthropic" or "claude" and attached openaiCompatible.cache_control, which worked.

OpenCode version

v2

Steps to reproduce

  1. Configure DigitalOcean provider with an API access key.
  2. Select anthropic-claude-fable-5.1 or another Anthropic model on DigitalOcean.
  3. Run a session with several tool turns.
  4. Observe token usage on DigitalOcean or in response metadata: cache_read_input_tokens is 0 on all steps and all input tokens are billed at full price.

Activity

  1. github-actions commented on Sep 26, 2026

    @github-actions
    Contributor

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

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