anomalyco / anomalyco/opencode

OpenCode Go endpoint: no prompt caching on DeepSeek (cache_hit always 0 even on repeated identical prompts)

Open
#41,125 3 comments 1 reaction 1 assignee View on GitHub

@fwang is already working on this.

Since Aug 7, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

The OpenCode Go subscription endpoint (https://opencode.ai/zen/go/v1/chat/completions) does not perform prompt caching on DeepSeek models. Every request returns prompt_cache_hit_tokens: 0, even when the exact same prompt is sent repeatedly, so the full prompt is re-processed from scratch on each call. This adds significant per-turn latency on real coding sessions, where large instruction files (AGENTS.md/CLAUDE.md/CONVENTIONS.md + memory) are re-sent on every tool loop.

The OpenAI-compatible /v1 API exposes prompt_cache_hit_tokens / prompt_cache_miss_tokens and prompt_tokens_details.cached_tokens in the usage object, but cache is never hit.

Plugins

None (default). Custom provider block in opencode.json pointing at the Go subscription:

"opencode-go": {
  "npm": "@ai-sdk/openai-compatible",
  "options": {
    "baseURL": "https://opencode.ai/zen/go/v1",
    "apiKey": "..."
  },
  "models": {
    "deepseek-v4-flash": {},
    "deepseek-v4-pro": {}
  }
}

OpenCode version

1.18.15

Steps to reproduce

  1. Send POST https://opencode.ai/zen/go/v1/chat/completions with model deepseek-v4-flash and a fixed prompt (e.g. "Explain in 2 lines what a PHP email-validation function does").
  2. Repeat the exact same request 3 times (a few seconds apart).
  3. Inspect usage in each response.

Result (all 3 identical calls):

"usage":{"prompt_tokens":101,"completion_tokens":100,"total_tokens":201,"prompt_cache_hit_tokens":0,"prompt_cache_miss_tokens":101,"prompt_tokens_details":{"cached_tokens":0}}

Expected: on call #2 and #3 the prefix should be cache-hit (DeepSeek's API does support automatic prompt caching, with hits reported via prompt_tokens_details.cached_tokens). Instead cache is never engaged.

Impact: full prompt re-processing on every turn → higher latency and token cost on long coding sessions, and no benefit from DeepSeek's automatic prefix caching.

OS / Terminal

Linux (Kubuntu) / bash + curl

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.