Problem
The DeepSeek API returns two cache fields in every response:
prompt_cache_hit_tokens — tokens served from disk KV cache
prompt_cache_miss_tokens — tokens that missed the cache
opencode correctly maps prompt_cache_hit_tokens → cache.read, but prompt_cache_miss_tokens is never recorded, resulting in cache.write: 0 for every single message.
Steps to reproduce
- Use
deepseek provider (any model)
- Make multiple requests in the same session (multi-turn conversation)
- Check stats:
opencode stats --models
- Check per-message data:
opencode db "SELECT json_extract(data, '$.tokens.cache.read'), json_extract(data, '$.tokens.cache.write') FROM message WHERE json_extract(data, '$.role')='assistant'" --format tsv
Expected
cache.write should equal prompt_cache_miss_tokens from the DeepSeek API response, enabling calculation of cache hit rate as hit / (hit + miss).
Actual
cache.write is always 0 for every message. Cache read (hit) works fine.
Impact
Cannot calculate cache hit rate. The opencode stats display shows Cache Write: 0 which is misleading.
Environment
- opencode v1.17.15
- deepseek/deepseek-v4-pro, deepseek/deepseek-v4-flash
- Linux (WSL2 Ubuntu 22.04)
Problem
The DeepSeek API returns two cache fields in every response:
prompt_cache_hit_tokens— tokens served from disk KV cacheprompt_cache_miss_tokens— tokens that missed the cacheopencode correctly maps
prompt_cache_hit_tokens→cache.read, butprompt_cache_miss_tokensis never recorded, resulting incache.write: 0for every single message.Steps to reproduce
deepseekprovider (any model)opencode stats --modelsopencode db "SELECT json_extract(data, '$.tokens.cache.read'), json_extract(data, '$.tokens.cache.write') FROM message WHERE json_extract(data, '$.role')='assistant'" --format tsvExpected
cache.writeshould equalprompt_cache_miss_tokensfrom the DeepSeek API response, enabling calculation of cache hit rate ashit / (hit + miss).Actual
cache.writeis always 0 for every message. Cache read (hit) works fine.Impact
Cannot calculate cache hit rate. The
opencode statsdisplay shows Cache Write: 0 which is misleading.Environment