DSH Plugins Marketplace

DSH Plugins

Plugins

/

Tools & Capabilities

/

dsh-cache-doctor

d

dsh-cache-doctor

Manifest valid

Explains DeepSeek prompt cache misses in a right-sidebar tab. It observes system-prompt/assemble and llm/stream, compares each request with the previous one in the same session, and names the first pa

UI (client)hasBundlePatch

dsh-cache-doctor · 缓存医生

English | 中文

DeepSeek Harness(dsh)右侧栏插件:找出 DeepSeek 提示词缓存为什么没命中,点名是哪个插件、哪一段系统提示词弄坏了缓存,并算出因此多花了多少钱。

为什么需要它

DeepSeek 会缓存提示词的前缀:这次请求和上一次请求开头相同的部分,按"缓存命中"计费。命中的输入只要未命中价格的几十分之一:deepseek-flash 命中每百万 token 0.02 元,未命中 1 元,差 50 倍。

Agent 每一步都会把整段对话重新发一遍,所以正常情况下绝大部分输入都能命中缓存。但只要系统提示词靠前的地方有一处内容每次都变,比如某个插件往里面写了当前时间、随机数、实时状态,这一处后面的所有内容就全都命中不了。你的账单悄悄涨了几倍,却不知道是谁干的。

缓存医生就是来查这个的。

缓存医生在 dsh 右侧栏里

截图来自测试环境:装了一个故意把当前时间写进系统提示词的插件(test/fixtures/clock-breaker.mjs),模型换成了本地的 DeepSeek 替身。缓存医生点名了这个插件的分段,并标出了每次变化的那几个字。

它会告诉你什么

  • 今日缓存命中率,以及缓存帮你省了多少钱、可避免的多花了多少钱、今天一共花了多少。
  • 病因:每个弄坏缓存的原因一张卡片,写明发生了几次、多花了多少钱、最近一次是什么时候。如果是系统提示词的问题,会列出是哪一段,并把上一次和这一次的内容并排显示,变化的字会标出来,再附上怎么处理的建议。
  • 最近的请求:每次模型请求一根柱子,绿色是命中,红色是本可以命中却没命中,灰色是新内容。
  • 近 7 天:每天的命中率、花费和可避免的花费。
病因什么意思算不算可避免
系统提示词某一段每次都在变多半是某个插件把时间之类的内容写进了系统提示词算
系统提示词中途多了 / 少了一段会话中途启用、停用了插件,或者有插件时有时无地加内容算
工具列表在会话中途变了中途开关 MCP 服务器,或者插件动态注册工具算
之前的对话内容被改写了有插件在发送前修改了历史消息算
缓存过期提示词没变,但 DeepSeek 已经清掉了这段缓存(很久没请求时会这样)算,但通常不用处理
上下文压缩对话太长时 dsh 自己压缩上下文,压缩后第一次本来就命中不了不算,属于正常现象

怎么判断的

插件只旁观两个钩子,不修改任何请求:

  • system-prompt/assemble:记下每次组装出的系统提示词由哪些命名分段组成(比如 tool:bash、某插件:now)。
  • llm/stream:每次模型调用结束后,读取这次请求的内容和用量(包括缓存命中数)。

对每次请求,把它拆成"系统提示词 → 工具定义 → 一条条消息",和同一会话的上一次请求逐段比较,找到第一个不一样的地方:

  • 如果只是在末尾追加了新消息,前面的部分本应全部命中;实际没命中,就算作缓存过期。
  • 如果中间某处变了,就看变化落在哪一段,把这一段记为病因。

"可避免的未命中"是这样算的:假如前缀没变,这次最多能命中上一次请求的全部长度(按 DeepSeek 的 64 token 缓存单位取整);实际命中数比它少的部分就是可避免的。少于 256 token 的零头不计。新会话的第一次请求,会和同一模型上一次请求的系统提示词、工具定义比较。

价格

内置 DeepSeek 官方价格(2026-11-19 在 api-docs.deepseek.com 核对),单位是元 / 百万 token,空闲时段:

模型缓存命中输入缓存未命中输入输出
deepseek-flash0.0214
deepseek-v4-pro0.154.513.5

工作日 9–12 点、14–18 点(北京时间)是高峰时段,价格翻倍。法定节假日没有单独处理,节假日的工作日也按高峰算(只会算高,不会算低)。DeepSeek 调价后,可以在配置里改价格。

安装

需要 dsh ≥ 0.2.0,在 0.2.2-rc.1 上实测过。

dsh plugin --profile web add github:qinghuidaqzp/dsh-cache-doctor

装好后重启 dsh,在右侧栏的引导页里点 缓存医生。

配置

- id: cache-doctor
  config:
    peakPricing: true
    minTokens: 256
    prices:                                      # 留空用内置价格
      - match: flash
        label: deepseek-flash
        hit: 0.02
        miss: 1
        output: 4
键默认值说明
stateFiledsh 主目录下的 cache-doctor/stats.json统计保存到哪里;留空则只存在内存里
peakPricingtrue是否按峰谷价计算
minTokens256少于这么多 token 的未命中不计入"可避免"
prices[]自定义价格,按顺序用 match(正则)匹配模型 id;空闲时段价格

隐私

所有数据都留在你的电脑上,插件不联网。统计文件里保存的是 token 数、金额、分段名,以及病因卡片用到的那一小段系统提示词原文(变化位置附近一百来个字)。不保存你的对话内容。

局限

  • "可避免"的数量是按上一次请求的长度估算的,DeepSeek 的缓存也只是尽力而为,所以这是一个很接近、但不精确的数字。
  • 只分析 dsh 里的模型请求。用其他客户端调用同一个 API Key 的部分看不到。
  • 界面只在 Web 界面(包括桌面版)里显示;dsh headless 也会照常记录统计。

给插件作者

不想被缓存医生点名的话:

  • 系统提示词分段(ctx.systemPrompt.section)里只放不变的内容。
  • 当前时间、实时状态这类会变的内容,用 ctx.systemPrompt.context() 注入:dsh 会把它作为一条消息追加到对话末尾,不会破坏前面的缓存。
  • 不要在会话中途增减工具定义。

开发

npm install
npm test

test/mockseek.mjs 是一个本地的 DeepSeek 替身,按 DeepSeek 的规则模拟前缀缓存,不需要 API Key。test/fixtures/clock-breaker.mjs 是一个故意把当前时间写进系统提示词的插件。端到端测试用真实的 dsh 跑两轮对话,确认能点名这个插件,去掉它之后不误报:

DSH_BIN=$(which dsh) node test/integration/run.mjs

许可证

MIT

Comments

Loading…

Similar plugins

dsh-deepseek-usage

by The-five-stooges

Shows the DeepSeek account balance as a row in the sidebar footer with a refresh button, and opens a popover with the balance card, daily token and estimated-cost charts over a 7/30-day window, a per-

Tools & CapabilitiesManifest valid

★ 0

MIT

JavaScript

Sep 18, 2026

dsh plugin --profile web add dsh-deepseek-usage

Sidebar row with today's tokens and estimated spend for DeepSeek Harness; the dialog adds 24h, 7-day, 30-day, 12-month and per-year charts, a contributions heatmap, per-request peak/off-peak pricing f

Tools & CapabilitiesTerminal & ClientsManifest valid

★ 0

MIT

JavaScript

dsh plugin --profile web add dsh-usage-badge

DeepSeek account balance and model cost tracking with official peak/off-peak pricing, three-tier token billing (cache miss, cache hit, output), per-model and per-session breakdowns, a composer summary

Tools & CapabilitiesTerminal & ClientsModels & ProvidersManifest valid

★ 0

dsh plugin --profile web add dsh-balance-and-cost

by Billwu18

Live prompt-cache telemetry for the current session in the DSH right sidebar: a register bank, a dot-matrix hit rate and a reactor-core history board.

Tools & CapabilitiesDevelopment & InfrastructureTerminal & ClientsManifest valid

★ 0

MIT

JavaScript

Sep 26, 2026

dsh plugin --profile web add dsh-cache-hit-monitor

by yunhenk

The missing receipt for DeepSeek prefix caching: replays local DSH sessions, prices every call at official peak/off-peak rates, and produces an HTML receipt plus a shareable card.

Tools & CapabilitiesManifest valid

★ 0

MIT

JavaScript

Nov 3, 2026

dsh plugin --profile web add dsh-cacheback

by dougen

Shows a card in the sidebar footer with the DeepSeek account balance (read from the official /user/balance endpoint with the API key DSH already stores) and the unit prices of the active model — input

Tools & CapabilitiesDevelopment & InfrastructureManifest valid

★ 10

↓ 2.1k/wk

NOASSERTION

JavaScript

Nov 18, 2026

dsh plugin --profile web add @dougen/dsh-deepseek-usage