September 2026 · 8 min read
Context layout beats model price on agent cost

Key definitions
Prompt caching Providers cache the computed key-value tensors behind a repeated prompt prefix, billing replayed prefixes at roughly 0.10x input price (up to ~90% off), with byte-identical output. It discounts input tokens only; output tokens are never discounted.
Cache hit rate The share of requests that land on an already-cached prefix. On Anthropic's 5-minute tier, a hit rate below roughly 30% means the write premium costs more than the reads save; below 60% on stable-prefix workloads is a structural problem.
Keepalive Re-sending the prompt prefix on a timer during tool execution or human approval pauses to refresh the cache TTL and prevent eviction. Measured economics: ~4-minute intervals beat the 30-second convention at Anthropic's 5-minute TTL.
If your agent bill is growing, do not switch models first. Two 2026 empirical studies converge on the same conclusion: the first cost lever for agentic workloads is not token unit price — it is context layout and cache lifecycle. Same model, same prompts, different content order: the bill can differ by more than 2x. Pricing tables decide the unit price; context design decides how many units you pay.
Evidence 1: caching rescues agent loads — but only at a healthy hit rate
Prompt caching reuses computed key-value tensors: requests sharing a recent prefix bill at roughly 0.10x input price — up to ~90% off on Anthropic and OpenAI’s newer models, ~75% on Google’s implicit cache, ~0.1x on DeepSeek with no storage fee (2026 vendor list prices). Because the model recomputes nothing it has seen, output is byte-identical: this is the only free-and-lossless cost lever in the stack. The PwC team’s study “Don’t Break the Cache” (arXiv 2601.06007, Feb 2026) measured across 500+ agent sessions with ~10,000-token system prompts: API cost down 41–80%, time-to-first-token improved 13–31%. The same study carries the counter-intuitive warning: naive full-context caching can paradoxically raise latency in some configurations. Caching is a design discipline, not a toggle.
The dividing line is hit rate. Anthropic’s 5-minute tier charges a +25% write premium; breakeven is roughly 1.4 reads per cached write, and below ~30% hit rate the premium costs more than the reads save. On stable-prefix workloads, a hit rate stuck under 60% is a structural problem, not bad luck (figures per the Digital Applied guide, Jun 2026, linked below).
Evidence 2: ProjectDiscovery’s 7% → 84%: move working memory out of the system prompt
The most instructive case is ProjectDiscovery: after relocating dynamic working memory out of the system prompt into a user message at the end, cache hit rate went from 7% to 84% and overall LLM cost fell 59%, with 9.8B tokens served from cache. The mechanism is unforgiving — the cache is keyed on the literal token sequence, so a single changed character before the cache boundary invalidates that block and everything after it. Order prompts most-to-least stable: tool definitions, system prompt, reference docs, conversation history, then the live query.
Evidence 3: pauses are the #1 cache killer; keepalives are the antidote
An agent loop is think–act–wait: it sends a request, then runs a build, a test suite, or waits for human approval for minutes, and only then sends the follow-up that would have reused the cached prefix. Provider caches expire in minutes — Anthropic’s default TTL is 5 minutes, OpenAI clears after 5–10 minutes idle — so the follow-up pays full prefill again. arXiv 2607.19214 “Keeping the Cache Warm Pays” (Jul 2026) quantifies the fix: a 30-second keepalive held 40/40 prefixes warm through a 600-second gap (no-keepalive baseline: 0/48), cutting post-pause request cost up to 12.5x. And keepalive cost falls monotonically with interval, so the economical choice is the largest interval safely under the TTL: ~4 minutes at Anthropic’s 5-minute tier, an 8x reduction in keepalive spend versus the 30-second convention.
The same study delivers a second counter-intuitive result: DeepSeek’s re-prefill is too cheap to insure and Google’s cache almost never evicts — keepalives buy latency only on those two, not savings. Measured eviction points: Anthropic ~5 min, DeepSeek ~10 min, OpenAI ~30 min, Google never. Your provider determines whether a keepalive strategy even makes sense.
Our judgment: cache hit rate is the agent cost KPI
Industry discussion of agent cost still spends 90% of its attention on model selection and price per token — a legacy of last cycle’s token price war. The 2026 bill structure has changed: input tokens routinely dwarf output, and most of that input is the same context re-sent over and over. The three variables that actually decide the bill are: how much of the prefix is static, where the dynamic content lives, and whether the cache is still alive when the agent returns from a pause. None of them are model properties. They are all context design.
We validate this on our own architecture. OOMeta’s agents run on deepseek-v4-flash (automatic prefix caching, no storage fee) and gemini-3.5-flash; long sessions with skills (SKILL.md) loaded on demand form a naturally stable, cacheable prefix, and our “LLM proposes, scripts persist” principle keeps state on disk instead of in context — controlling prefix bloat at the source. A daily cron fleet re-executes near-identical system prompts, which is cache-friendly by construction: hit rate is the metric we watch first. The flip side: every high-value flow that requires human approval pauses for minutes, and keepalives decide whether that segment bills at 0.1x or full price.
Playbook: four moves you can make today
1. Measure hit rate before touching the model
Pull it from the provider dashboard or gateway logs. Below 60% on stable-prefix workloads is a structural problem — fix structure first, then revisit model selection.
2. Move dynamic content to the end of the prompt
Working memory, live state, and ephemeral instructions go into the final user message. Order the prefix by stability: tool definitions → system prompt → reference docs → conversation history → live query.
3. Add keepalives to wait-heavy flows
Interval ≈ 80% of TTL: ~4 minutes on Anthropic’s 5-minute tier, ~4 minutes on OpenAI. Only flows whose pauses exceed the eviction point need it; pure batch work without pauses does not.
4. Compare providers on discount plus write premium, not unit price
DeepSeek and OpenAI have no write premium — good for bursty loads; Anthropic’s 1-hour tier suits low-frequency long sessions; Google’s explicit cache carries storage fees and only pays off at high read volume.
Act: answer one question first
Decision question for AI app leads: what is your cache hit rate? If the answer is “we have never looked,” 41–80% of your cost space is probably sitting on the table. Wire hit rate into your cost dashboard, run the four moves above, and compare the bill in two weeks. We bet you land on the same conclusion we did: the first cost variable for agents is not the model — it is the context.
OOMeta AI
OOMeta is an AI-native advisory and product company: one human, many digital employees, one operating intelligence. Our own agents run daily on deepseek-v4-flash and gemini-3.5-flash; we control context bloat with “LLM proposes, scripts persist” and keep prefixes cacheable with on-demand skill loading. Context engineering is not a paper concept for us — it is how we control our own costs and the default lever in every agent system we design for clients.
Book a diagnosis callReferences: arXiv 2601.06007 “Don’t Break the Cache: An Evaluation of Prompt Caching for Long-Horizon Agentic Tasks” (PwC team, Feb 3, 2026, independent research) https://arxiv.org/abs/2601.06007 · arXiv 2607.19214 “Keeping the Cache Warm Pays: Keepalive Economics for Agentic Workloads” (Jul 24, 2026, independent research) https://arxiv.org/abs/2607.19214 · Digital Applied “Prompt Caching in 2026: Cut LLM Costs, Keep Quality” (Jun 16, 2026; includes the ProjectDiscovery case and provider pricing) https://www.digitalapplied.com/blog/prompt-caching-2026-cut-llm-costs-engineering-guide · Anthropic Prompt Caching docs (write premiums / TTL tiers, vendor-reported) https://platform.claude.com/docs/en/build-with-claude/prompt-caching · OpenAI Prompt Caching docs (vendor-reported) https://platform.openai.com/docs/guides/prompt-caching
FAQ
Why are agent workloads the worst-case user of prompt caching?+
An agent loops as think–act–wait: it sends a request, runs a tool or waits for human approval for minutes, and only then sends the follow-up that would have reused the cached prefix. Provider caches expire in minutes (Anthropic default TTL 5 minutes; OpenAI clears after 5–10 minutes idle), so the pause outlives the cache and the follow-up pays full prefill again.
How much can caching actually save?+
arXiv 2601.06007 (Feb 2026, PwC team): across 500+ agent sessions with ~10,000-token system prompts, prompt caching cut API costs 41–80% and improved time-to-first-token by 13–31%. But savings depend on hit rate — below breakeven, the write premium makes caching cost more.
At what hit rate does caching lose money?+
On Anthropic's 5-minute tier (write premium +25%), breakeven is roughly 1.4 reads per cached write; below ~30% hit rate the writes cost more than the reads save. Below 60% on stable-prefix workloads, assume dynamic content is leaking into the prefix (Digital Applied, Jun 2026).
How do you lift hit rate from single digits to 80%+?+
Order the prompt most-to-least stable: tool definitions, system prompt, reference docs, conversation history, live query — and move dynamic working memory into a user message at the end. ProjectDiscovery did exactly this and went from 7% to 84% hit rate, cutting overall LLM cost 59% with 9.8B tokens served from cache.
What do you do about tool or approval pauses?+
Use a keepalive: re-send the exact prefix on a timer during the pause. arXiv 2607.19214 (Jul 2026) measured a 30-second keepalive holding 40/40 prefixes warm through a 600-second gap (baseline 0/48), cutting post-pause request cost up to 12.5x; the economical interval is ~4 minutes at Anthropic's 5-minute TTL, an 8x reduction in keepalive spend vs the 30-second convention.
How do the providers differ on caching?+
Anthropic uses explicit breakpoints with a write premium (+25% 5-min tier, +100% 1-hour tier); OpenAI caches automatically with no write premium and 24-hour retention on newer models; Google gives ~75% implicit discount plus a storage fee for explicit caching; DeepSeek caches automatically at ~0.1x with no storage fee (2026 vendor list prices). DeepSeek's re-prefill is too cheap to insure and Google's cache rarely evicts, so keepalives buy latency only on those two.
Related articles
The token price war changed the real cost lever
OpenAI cut Luna 80% to $0.20/M; Sonnet 5 stays $2/$10. Our view: the price war ended model choice as the cost lever — cache, batch and retries set the bill now.
LLM routing: conditions behind 40-80% savings
Route each request to the cheapest capable model. Behind 40-80% savings claims: cheap share past 50%, an eval gate, closed-loop distillation.
Model routing is not a config: the closed loop is
RouteNLP pilot (ACL 2026): -58% inference cost, p99 1,847ms to 387ms. Our take: static routing gets half the savings; the closed loop is the other half.
Agent cost control moves to execution layer
Agent cost control moves to execution layer: budget pre-enforcement, per-call routing, full metering. Sapiom’s $35M: dashboards audit, execution layers govern.