Skip to main content
All posts
Guide

How DeepSeek Harness Hits 99% Cache Hit Rates (Explained)

DeepSeek Harness cache hit rate explained: how DeepSeek context caching (prefix KV cache) plus dsh's append-only sessions push real hit rates to 97-99%.

DeepSeek Harness (dsh) isn't cheap because of a pricing trick — it's cheap because two things stack: DeepSeek's own API-level context caching (a prefix-matched KV cache, billed at a fraction of normal input price on a hit) and dsh's session architecture, which happens to be almost perfectly shaped to feed that cache. Neither one alone explains the numbers Reddit keeps posting; together they explain why agent sessions in particular — not chatbots, not one-off completions — are where the savings compound the hardest.

What DeepSeek context caching actually is

Every request to an LLM API starts with a prefill step: the model processes the entire input prompt (system prompt, conversation history, tool schemas, everything) before it generates a single output token. Prefill is compute-heavy, and for a long-running agent session the same tokens — the system prompt, the first 40 messages of history — get reprocessed on every single turn, because each new turn just appends one more user message or tool result to an ever-growing prompt.

DeepSeek's context caching (officially documented at api-docs.deepseek.com/guides/kv_cache) exploits exactly that redundancy. On each request, DeepSeek's API checks how much of the new prompt's prefix — a byte-for-byte match starting from token zero — was already computed and cached from a previous request. Whatever matches is billed at the cached input price instead of the full input price; only the new tail of the prompt (and the output) get billed and computed at normal rates. There's no configuration flag to turn this on — it's automatic, and it's a property of the API, not of dsh itself.

The catch is the word "prefix." Cache hits require the exact same tokens in the exact same order from the start of the prompt. Insert, remove, or reorder anything upstream of a given point, and everything after that point is a cache miss.

Why dsh agent sessions hit 97-99%

That "exact same prefix" requirement is where dsh's architecture becomes relevant, not incidental. A multi-turn agent session is naturally an append-only prefix: each turn just adds the model's previous response, the tool calls it made, and the new user input onto the end of the existing conversation. If nothing upstream changes, every single previous turn is a guaranteed cache hit, and only the newly appended tail needs fresh compute.

dsh's session storage backs this up structurally rather than by accident: sessions are event-sourced logs (see the session-persistence-jsonl / session-persistence-sqlite packages) where history is immutable once written, and the system prompt for a given session stays fixed unless you deliberately change agent mode. That combination — an unchanging system prompt plus a strictly append-only history — is close to the ideal input shape for prefix caching.

The numbers on Reddit back this up, with the usual caveats that they're self-reported and unverified:

  • On the dsh launch thread (r/LocalLLaMA), several commenters reported roughly 97% cache hit rates running DeepSeek through harness setups in the dsh family — one via the third-party harness reasonix rather than dsh itself — with one person noting a full one-shot SPA build cost them $0.06 total. (reddit.com/r/LocalLLaMA/comments/1vnb66j)
  • A separate long-session user on r/DeepSeek reported cache hits climbing to 99% after roughly 61.5 million cumulative input tokens in a single dsh session — a large enough sample that the number is unlikely to be a fluke, though it's still one person's report, not an audited benchmark. (reddit.com/r/DeepSeek/comments/1vnpt5n)
  • On another r/DeepSeek thread, "100% cache hit" turned into a running joke ("you thought your message was unique, but someone already sent it" / "DeepSeek invented time travel") before a detailed community explainer walked through prefill and prefix matching and linked DeepSeek's own KV cache docs — a sign that plenty of users notice the effect long before they understand the mechanism. (reddit.com/r/DeepSeek/comments/1vnfz2l)

None of this is dsh doing anything special to the API — it's dsh not accidentally sabotaging a caching mechanism that rewards long, stable, append-only prompts.

What breaks the cache

The flip side is that anything which mutates the prompt's shared prefix — instead of appending past its end — forces a full or partial re-prefill on the next request. In practice:

ActionEffect on cache
Sending a new message in the same sessionNo effect — this is the append-only case the cache is built for
Switching agent mode (e.g. minimal ↔ standard ↔ PTC)Changes the system prompt and tool schemas, invalidating the cached prefix from that point
Changing model or provider mid-sessionCache is per-model; switching providers starts fresh
A plugin injecting dynamic content into the prompt (timestamps, live counters, randomized ordering)Breaks the exact-match requirement on every turn where it fires, even if the rest of history is unchanged
Forking a sessionThe shared history up to the fork point stays byte-identical, so it should still hit cache normally; divergence only affects turns after the fork
Whether tool-call outputs count toward the cached prefixGenuinely unclear — DeepSeek's docs don't spell this out explicitly, and it's an open question in community threads rather than a documented behavior; treat it as unverified either way

The practical takeaway is the one already circulating informally: keep your system prompt and plugin set stable for the life of a session, and avoid anything that injects non-deterministic content into early context.

How to check your own cache hit rate

You don't need to guess — dsh's Web UI surfaces the cache hit rate per session directly. It's been there for a while, but the display itself had a rough edge: earlier builds rounded 99.x% figures in a way that lost precision at exactly the range where most long agent sessions land. The v0.1.1-rc.1 release (2026-08-21) specifically improved the display precision for 99.x% cache hit rates, alongside a Bubblewrap sandbox fix and the new DeepSeek-V4-Flash-Vision-Exp model adapter. If you're still on an older 0.1.0-rc.x build, see the upgrade guide for what else changed before you bump the version.

A practical checklist for cutting costs

None of these are official DeepSeek recommendations — they're patterns reported by the community, credited where the source is known:

  1. Watch for time-of-day pricing swings. The author of the dsh-token-anxiety plugin — which tracks per-task cost against peak/valley pricing windows — reported on Reddit that "peak vs valley hours make a HUGE difference" for effective cost. This is a community-reported observation, not something we've independently verified against DeepSeek's pricing page. (reddit.com/r/DeepSeek/comments/1vph1ig)
  2. Reserve Pro for hard problems, use Flash for everything else. Same source: route routine tasks to a cheaper/faster model tier and save the larger model for problems that actually need it.
  3. Go easy on subagents. The same Reddit post specifically warns not to spawn subagents "unless you can strictly control" them — each subagent typically starts its own context, which means its own prefill, undercutting the parent session's accumulated cache advantage. See DeepSeek Harness Subagents for how delegation works before you lean on it heavily.
  4. Keep system prompts and installed plugins lean. A separate, well-upvoted r/LocalLLaMA thread makes the case at length: harnesses with bloated system prompts pay a bigger prefill cost on every single turn, cache or no cache, and a leaner plugin set means less to invalidate when something does change. Browse Usage & Billing plugins if cost tracking itself is what you're after, or the full plugin catalog for everything else.

You can install the token-tracking plugin the same way as any other:

dsh plugin --profile web add github:mov-eax-eax/dsh-token-anxiety

Is dsh free because of this?

Caching lowers your effective per-token cost dramatically, but it doesn't make dsh free — you still need API credits from whichever provider you're using, and dsh itself is free/MIT-licensed software regardless of caching. See Is DeepSeek Harness Free? for the full breakdown, and Which Harness Runs DeepSeek V4 Best? if you're comparing total cost across harnesses rather than just cache behavior within dsh.

FAQ

What is DeepSeek context caching, in one sentence?

It's DeepSeek's API automatically reusing the computed KV cache for any prefix of your prompt that exactly matches a previous request, billing the matched portion at a lower cached-input rate.

Why do dsh sessions specifically get such high hit rates?

Because dsh sessions are append-only event logs with a stable system prompt per mode — the conversation only ever grows at the end, which is the exact shape prefix caching rewards.

Does the 97-99% number apply to every dsh session?

No — it's what's been self-reported for long, stable sessions with a consistent agent mode and plugin set. A session that frequently switches modes, models, or injects dynamic content into early context will see lower hit rates.

Do tool call outputs count toward the cached prefix?

It's not clearly documented either way, and the community hasn't settled it — treat any specific claim about tool-output caching as unverified until DeepSeek's docs address it directly.

Do I need to configure anything to get caching?

No — context caching is automatic on DeepSeek's API side. The only thing you control is whether your prompt shape (system prompt, plugin set, mode) stays stable enough to keep hitting it.

Next steps

Check your own cache hit rate in the dsh Web UI after upgrading to v0.1.1-rc.1 for the improved 99.x% display precision. If subagents are part of your workflow, read DeepSeek Harness Subagents before you scale up delegation and dilute your cache. For a broader cost comparison across harnesses (not just cache mechanics), see Which Harness Runs DeepSeek V4 Best?, and browse cost-tracking plugins under Usage & Billing or the full plugin catalog.