Skip to content
Agentic Control Plane

Cache Hit Rate Formula: Three Versions in the Wild, and Why a Wrong One Costs You Work

David Crowe David Crowe · · 2 min read
cost engineering agents
Share X HN LinkedIn

Prompt-cache reads are cheap. On Anthropic they bill at about a tenth of the normal input price, and other providers give a discount too. That makes the cache hit rate the first number to check when an agent’s bill looks wrong.

There is no agreed definition of it. While auditing cost tooling, ours included, we found three formulas in use.

1. Reads over total input (correct). cache_read_tokens / total_input_tokens, where total input is fresh tokens plus cache reads plus cache writes. It answers the question people are asking: what share of my input was billed at the discount?

2. Writes counted as hits (too high). Writing to the cache costs more than normal input, about 1.25x on Anthropic. A write is a miss that fills the cache. If you add writes to the numerator, the first turn looks like a warm cache when you are paying the most. We found this one in one of our own dashboard views.

3. A double-counted denominator (too low). Most metering stores prompt tokens as the total input, which matches what providers bill. If you then compute cached / (promptTokens + cached), the cached tokens are in the denominator twice. A real 96% shows up as about 50%.

The day the number was wrong

Formula 3 was live in our own MCP connector. I saw “about 50% cache hit” on my coding-agent traffic and asked a frontier model to help me diagnose it. It gave a plausible answer: bloated tool results were dragging the ratio down. That fit what we already believed, and we started sketching a fix.

Then we checked the raw runs instead of the dashboard. The real rate was about 96%. There was no bloat problem. Runs with more tool-result bytes actually cached better, because long runs warm the prefix cache.

Every step of the reasoning after the number was sound. The number was wrong, and it sent us toward a problem that did not exist.

A wrong metric does more than mislead. It creates work. An agent reading that connector would have done the same thing without our moment of doubt: optimize the pipeline, watch a number that was never going to move, keep going.

The fix was one line. We also now keep one definition, reads over total input, and test for it everywhere the number appears. We check our own dashboards the way we check other people’s claims. This is also why AI agent cost monitoring starts with definitions.

Checklist for any tool’s cache hit rate

  • Ask whether writes count as hits. They should not.
  • Ask what the denominator is, and whether cached tokens are already in it.
  • Check it against the pricing. A long-running coding agent with a stable prompt should sit well above 90%. If a dashboard says 50%, suspect the formula before the agent.
  • If a surprising number is about to drive real work, check it against raw usage data first. Sometimes the answer is a feature you don’t need to build.

Running coding agents? ACP records each tool call its hook sees and makes the dangerous shell commands (a force-push, destructive SQL, curl | sh) wait for you. One command, free up to 5 agents:

macOS · Linux · WSL
curl -fsSL https://agenticcontrolplane.com/install.sh | bash
Windows · PowerShell
irm https://agenticcontrolplane.com/install.ps1 | iex

What the installer writes  ·  Getting started

Share X HN LinkedIn
Get the next data drop
What agents actually cost, new tool-surface captures, and the occasional incident post-mortem — sent when we publish something worth your inbox, not on a schedule. Unsubscribe anytime.
Share: Twitter LinkedIn
Related posts

← back to blog