Skip to content

DeepSeek prefix-cache misses on every new session — first turn wastes ~19.5k tokens #2532

Description

@daofazhiran

What version of Kimi Code is running?

0.31.1(复现于 0.31.0 和 0.31.1)

Which open platform/subscription were you using?

DeepSeek API via custom provider (OpenAI-compatible)(config.toml 配的api.deepseek.com,非 Kimi 订阅)

Which model were you using?

deepseek-v4-pro

What platform is your computer?

Darwin 25.5.0 arm64 arm

What issue are you seeing?

每个新 session 首轮 LLM 调用几乎全 cache miss(inputOther≈19.5k,cacheRead 仅 2,432)。system prompt 注入的 ISO 时间戳每次 session 变化,成为 DeepSeek 前缀缓存的分歧点,连带其后 ~16.8k token 的 tools 定义全部 miss。

What steps can reproduce the bug?

  1. config.toml 配 DeepSeek provider;
  2. 连续跑两个新 session(如 kimi -p "hi" × 2);
  3. 查第二个 session wire.jsonl 的 usage.record——首轮 inputCacheRead 只有 2,432,inputOther≈19.5k。

What is the expected behavior?

system prompt 前缀稳定时,新 session 首轮应命中缓存:实测删掉时间戳段后 cacheRead=20,608(99.6%),inputOther 从 ~19.5k 降到 88。

Additional information

验证数据:curl 用固定 system + 全部 24 个工具请求,第 2 次起命中 22,784/22,793(100%);
方案权衡(删除/后置/注入 user 消息,后置无效);

已有实现分支 daofazhiran/kimi-code 的 perf/system-prompt-prefix-cache

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions