Cache Hit Priced at One-Tenth: The Real Logic Behind Agent Inference Cost
When inference providers cut cache-hit pricing to one-tenth of the base rate, many teams assume higher hit rates automatically mean lower costs. But that’s only half the story. The discount is a per-token price change, while the real bill is determined by the combined effect of hit token ratio and discounted unit price. The deeper reason lies in how Agent workloads naturally produce long stable prefixes, and how the smaller KV footprint of newer models makes those prefixes easier to cache, retain, and reuse. Together, these factors turn the “discount on top of a discount” from a pricing signal into a practical cost optimization opportunity. This article breaks down the math, the architectural reasons, and the engineering practices—request structuring, stable serialization, cache key design, and cost monitoring metrics—that determine whether the lower cache-hit price actually reaches your bottom line.
From “Discount on Discount” to Multiplicative Savings
Cache-hit billing can be abstracted as follows: uncached tokens are billed at the standard unit price, while cached tokens are billed at a discounted rate. Let P be the standard unit price, d the cache-hit discount, and h the hit token ratio. The effective unit price can be approximated as:
Effective unit price = P × (1 - h × (1 - d))
When d = 0.1, meaning the cache-hit price drops to one-tenth of the base rate:
h=0.7 -> Effective unit price = P × (1 - 0.7×0.9) = 0.37Ph=0.9 -> Effective unit price = P × (1 - 0.9×0.9) = 0.19P
These figures are illustrative only and do not represent any specific pricing rules, but the point is clear: when the hit ratio rises from 70% to 90%, the effective unit price drops by nearly half again. The so-called “discount on a discount” is not a simple one-time reduction—it is a multiplicative effect between the unit-price discount and the hit ratio. If the hit ratio is low, even a very low cached-token price fails to meaningfully reduce total cost. If the hit ratio is high, the discount is fully amplified. Therefore, evaluating this price change should not focus solely on “whether the hit rate is high,” but on “which tokens are stable, which are dynamic, and whether the cache can be reused over time.”
Why Agent Workloads Naturally Fit Exact Prefix Caching
Exact prefix caching requires the token sequence prefix of a request to be identical in order to reuse the existing KV cache. The structure of Agent requests fits this requirement naturally. A typical Agent request can be decomposed into a stable prefix and a dynamic suffix:
- Stable prefix: system prompt, tool schemas, repository context, memory snapshot, session summary, etc.
- Dynamic suffix: latest observation, current task description, run identifier, turn information, etc.
In multi-turn tool-calling scenarios, the system prompt and tool schemas typically remain unchanged; repository context is stable within a certain phase; memory snapshots and session summaries update at a lower frequency; what actually changes from turn to turn is often just the tool-returned observation, the current task, and the run identifier. This gives requests the shape of a “long stable prefix with a short dynamic suffix.” Once a cache hit occurs, the KV states for the stable prefix are computed only once, and subsequent turns can directly reuse them, significantly reducing redundant computation and first-token latency.
This also explains why the hit rate should not be viewed in isolation. If the prefix is short and the suffix is long, even a high hit-rate number translates into limited token savings. If the prefix is long and stable, cache hits become truly meaningful. The value of Agent workloads is that they shift a large amount of repeated content into a stable prefix.
How a Smaller KV Footprint Amplifies the Effect
KV footprint refers to the memory space each token occupies in the inference cache, typically correlated with model depth, the number of attention heads, hidden dimensions, precision, and batching strategy. A smaller KV footprint means the same amount of GPU memory or RAM can hold more prefix cache entries, evictions happen less frequently, long prefixes are more likely to stay resident, and reuse frequency rises.
This is especially important for Agent workloads. Agent prefixes often contain long system prompts, tool definitions, and repository contexts—the longer the prefix, the greater the cache benefit, but also the larger the footprint. With a smaller KV footprint, the same memory capacity can preserve more prefixes. Cache hit rates improve not only because requests are structurally similar, but because the cache can physically accommodate and retain more entries. Conversely, if the cache is frequently evicted, even a request structure ideal for caching will degrade into repeated recomputation.
Therefore, this round of price reductions cannot be attributed simply to “high hit rates.” The more accurate chain is: Agent workloads produce long stable prefixes → a smaller KV footprint improves cache residency → exact prefix caching boosts reuse probability → and ultimately, with the cache-hit price at one-tenth, a compound cost-reduction effect emerges.
Engineering Practice: Designing Cacheable Request Structures
To make the discount actually appear on the bill, request organization matters more than chasing a high hit-rate number. Follow the principle of “stable blocks first, dynamic blocks last, stable serialization, and interpretable cache keys.”
def build_agent_request(stable_blocks, dynamic_blocks):# stable_blocks must be concatenated in a fixed order, with no timestamps,# random numbers, or turn numbers included.# dynamic_blocks should only contain content that varies from turn to turn.return {"prefix": stable_blocks,"suffix": dynamic_blocks}stable_blocks = [system_prompt_template, # system prompt templatecanonical_json(tool_schema), # tool schemas, canonically serialized and sortedsorted_repo_context, # repository context, deterministically orderedmemory_snapshot, # memory snapshot, updated at low frequencysession_summary # session summary, updated at low frequency]dynamic_blocks = [latest_observation, # latest tool-returned observationcurrent_task, # current task descriptionrun_id # run identifier, placed in the suffix]
Key points to observe:
- Stable blocks follow a fixed order. The ordering of the system prompt, tool schemas, repository context, memory, and summary must not change across turns. Any change in a leading block invalidates the entire subsequent prefix.
- Serialization must be deterministic. Key order, whitespace, and array sorting in tool schemas should be normalized. Do not mix timestamps, random IDs, or turn numbers into the prefix.
- Dynamic fields go at the end. Run identifiers, current task descriptions, and latest observations should be placed in the suffix to avoid polluting the prefix.
- Cache keys include version information. Cache keys should distinguish model version, prompt template version, tokenizer version, precision configuration, and prefix hash to prevent incorrect reuse.
- Multi-tenant isolation. Shared system prompts can improve reuse, but tenant-specific sensitive data must be isolated. Both cache keys and cache storage need tenant boundaries.
- Context compression requires caution. If the session summary is rewritten every turn, the prefix will churn frequently. Treat the summary as a low-frequency update block, or move the new summary into the suffix and preserve the old stable prefix.
Cost Monitoring: Beyond the Hit Rate to Hit Token Ratio
Request-level hit rates alone can be misleading. Metrics that more closely track cost include: hit token ratio, uncached token ratio, effective unit price, cache eviction rate, prefix reuse count, first-token latency, and tail latency. It is recommended to group observations by Agent type, tool set, and repository context version, then identify scenarios with “long prefixes but low hit rates.” Prioritize fixing issues such as dynamic field pollution, frequent tool schema changes, and unstable context ordering.
Adoption Recommendations for Enterprises
For enterprises using general inference services, the key is not memorizing a particular discount number, but designing request structures into reusable prefixes. Roll out in three steps: first, identify the stable and dynamic blocks in Agent requests and build templated prefixes; second, establish cache-key conventions, serialization standards, and version management; third, verify hit token ratio and effective unit price using load testing and monitoring, rather than looking only at the hit rate. For scenarios with frequently changing tool schemas, version them and control the change frequency. For repository contexts, use content-addressed storage and deterministic ordering. For memory and summaries, set low-frequency update strategies.
Conclusion
The cache-hit price dropping to one-tenth is a cost signal worth attention, but its essence is not the discount itself—it is the combined result of evolving Agent workload patterns and smaller KV footprints. Long stable prefixes give exact prefix caching content to reuse; a smaller KV footprint lets the cache hold more and keep entries resident longer; and a lower cache-hit price amplifies the reuse effect onto the bill. Only by designing request structures, cache keys, serialization, monitoring, and isolation together can the compounding discount be turned into sustainable inference cost optimization.
