anomalyco / anomalyco/opencode
OpenCode Go endpoint: no prompt caching on DeepSeek (cache_hit always 0 even on repeated identical prompts)
@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
- Send
POST https://opencode.ai/zen/go/v1/chat/completionswith modeldeepseek-v4-flashand a fixed prompt (e.g. "Explain in 2 lines what a PHP email-validation function does"). - Repeat the exact same request 3 times (a few seconds apart).
- Inspect
usagein 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.