anomalyco / anomalyco/opencode
OpenCode Go: no prompt caching on deepseek-v4-flash and qwen3.8-max (glm-5.2 caches fine)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Summary
The OpenCode Go endpoint (https://opencode.ai/zen/go/v1/chat/completions) does not perform prompt caching for deepseek-v4-flash or qwen3.8-max, while glm-5.2 on the same endpoint does. Every request re-processes the full prefix from scratch, so Go sessions on DeepSeek/Qwen burn the $12/$30/$60 metered limits much faster than the Go docs' request estimates assume (those assume ~50-80k cached tokens per request).
Related: #41125 (same symptom for DeepSeek, reported earlier).
Reproduction (live, 2026-09-08, Go subscription key, x-opencode-session set consistently across calls)
Test 1 - deepseek-v4-flash, 3 byte-identical requests:
| call | prompt_cache_hit_tokens | prompt_tokens_details.cached_tokens | latency |
|---|---|---|---|
| 1 | 0 | 0 | 2.4s |
| 2 | (absent) | 0 | 1.1s |
| 3 | (absent) | 0 | 2.1s |
prompt_cache_miss_tokens = 96 on call 1 (full prompt re-processed). Cache never engages.
Test 2 - same pattern on other Go models:
| model | call 1 cached | call 2 cached |
|---|---|---|
| deepseek-v4-flash | 0 | 0 |
| qwen3.8-max | 0 | 0 |
| glm-5.2 | 10 | 25 |
Impact
- DeepSeek/Qwen turns on Go reprocess the whole prefix (system prompt + tools + history) every tool-loop iteration: higher latency and faster limit consumption.
- The Go pricing/docs assume caching works (per-model "Cached Read" rates and request estimates with ~70k cached tokens per request).
Expected
Repeated identical prompts should return prompt_tokens_details.cached_tokens > 0 after the first call, as glm-5.2 does on the same endpoint.
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.
Research direction
Start by tracing the OpenCode Go endpoint at https://opencode.ai/zen/go/v1/chat/completions and the model/provider handling for deepseek-v4-flash, qwen3.8-max, and glm-5.2. Compare the request and response paths for the models, then reproduce the three-call test with a consistent x-opencode-session. Done means repeated DeepSeek and Qwen requests report cached prompt tokens like glm-5.2.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100