Skip to content

DeepSeek provider: prompt_cache_miss_tokens not mapped to cache.write #35974

Description

@22xuan

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_tokenscache.read, but prompt_cache_miss_tokens is never recorded, resulting in cache.write: 0 for every single message.

Steps to reproduce

  1. Use deepseek provider (any model)
  2. Make multiple requests in the same session (multi-turn conversation)
  3. Check stats: opencode stats --models
  4. 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)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions