Your Agentic Workflow's Cache Keepalive Costs 8x Too Much (v2: the interval frontier)

Updated with the full retention curve and the interval frontier: the keepalive saves on Anthropic AND OpenAI inside each provider's paying band, OpenAI's optimal interval is 8 minutes not 4, and an interval past the TTL is actively toxic: every ping re-prefills a dead cache at full price.

Your Agentic Workflow's Cache Keepalive Costs 8x Too Much (v2: the interval frontier)

A cache keepalive is the one optimization every agent builder agrees on, and almost everyone runs it at the wrong setting.

The convention is to ping every 30 seconds. That convention costs 8× more than necessary. I measured keepalive economics across Anthropic, OpenAI, Gemini, and DeepSeek, with a harness that can prove its own timing, and the numbers rearranged a few of my beliefs. The right interval is about 4 minutes, not 30 seconds. Whether the keepalive saves you money depends on the provider and on how long your agent pauses, and there is a clean rule for both: keep the cache warm only when your pause is longer than the provider's eviction point but shorter than its break-even horizon. Inside that window the keepalive pays. On Anthropic and OpenAI it saves real money. On DeepSeek and Gemini it buys only latency. Outside the window it is pure waste.

The pause that eats the cache

Provider prompt caches are one of the best deals in the API: send a prefix the server processed a moment ago, and you pay about a tenth of the input price and skip most of the prefill latency. But the cache expires in minutes, and agentic workloads are the worst possible user of it. An agent thinks, acts, waits. It fires a request, runs a build or a test suite or sits on a human approval for ten minutes, and only then sends the follow-up that would have reused the (now large) conversation prefix. The pause outlives the cache. The follow-up pays full price, full latency, and at agent scale this is a real line item.

The defense is well known. Re-send the exact prefix on a timer during the pause; every read refreshes the TTL. Aider shipped it in 2024, Anthropic's docs recommend it, and community posts worked out the Anthropic cost mechanics and even a 4-minute interval on paper. The folklore, it turns out, had part of the right answer. What it didn't have was measurement. Everything above is practice and arithmetic. Everything below is measured: four providers, idle gaps out to forty minutes, ping intervals out to fifteen, three independent runs, every call timestamped.

Credit where the project started: in a conference room in Bellevue, at AgentSys, where I saw Haiying Shen and Simon Peter present CacheWise, their study of KV-cache management for coding agents. Their trace analysis shows from the serving side exactly the problem above: agent sessions reuse enormous prefixes, and naive eviction wrecks them. Their question was how the server should manage the cache for agents; mine became what the client can do about it on its own. The keepalive is the client's answer, and this study is my thanks for the inspiration.

Where each cache actually dies

To know whether a keepalive is worth it, you first have to know when the cache would have died on its own. So I let idle prefixes sit, with no keepalive, and measured the warm rate out to forty minutes.

Retention curve: baseline warm rate vs idle time out to 40 minutes. Anthropic cliffs at 5 minutes, DeepSeek by 10, OpenAI by 30, Google never converges.
Idle cache survival with no keepalive, 100k prefix. The green band is the window where every provider is still warm.

Two things fall out of this curve, and both matter.

First: the documented TTL is exactly what you can rely on, and no more. Nothing evicted before its documented TTL, and nothing past it is guaranteed. Anthropic's cache falls off a cliff between 5 and 6 minutes, exactly at its advertised 5-minute TTL, with no grace period. DeepSeek is gone by 10. OpenAI actually outlives its documented 5 to 10 minutes, still half warm at 20, before going fully cold by 30; a pleasant bonus, but a provider-specific one you cannot plan around. Google never converges to warm or cold at all, hovering at a 33 to 83 percent hit rate at every gap, which is what a routing lottery looks like rather than a retention curve. So the retention window you can assume by default is the shortest documented TTL in your fleet, minus a margin. Warmth below it held everywhere I measured. Warmth above it is luck.

Second, and this corrected my own earlier conclusion: OpenAI is not sticky, it is slow. When I first measured only to ten minutes, OpenAI looked like it never evicted. It does. I just had not waited long enough. That distinction turns out to decide whether the keepalive ever pays for it.

The keepalive itself works everywhere, and that part was never in doubt. Wherever a baseline drops, the keepalive holds the same prefix warm:

Four panels, baseline vs keepalive warm rate per provider out to 30 minutes: every baseline that dies is held at 100% by the keepalive
Baseline (dashed) vs keepalive (solid) warm rate, out to 30 minutes at 100k. Anthropic: 0 of 48 warm at ten minutes without the keepalive, 40 of 40 with it. Every provider that evicts is held at 100%.

The question this post is really about is not whether the keepalive works. It is whether it is worth paying for, and that depends entirely on where you are sitting on the retention curve above.

The interval is the whole game

Here is the entire economics of the keepalive, and it is settled arithmetic:

  1. A ping costs the read price (≈10% of input) every interval τ. Holding a prefix costs 0.1× per τ.
  2. A re-prefill costs 100% once (125% on Anthropic, which bills the cache write).
  3. So spend per hour falls as 1/τ, and the interval buys nothing except safety. The optimal interval is the largest one safely under the provider's retention: ≈ 4 minutes at Anthropic's 5-minute TTL. (Hold that thought; the last section shows what "safely under" is worth, and what happens when you cross it.)
  4. Break-even is idle ≈ τ(w/r − 1): about 46 minutes at Anthropic's prices, 36 for OpenAI and DeepSeek, 12 for Google (its cached reads are 0.25×, not 0.1×). Past that, stop pinging: let the cache die and pay the re-prefill.

That last one is the rule worth internalizing, so here it is as insurance. Every ping is a premium you pay to avoid one claim: the re-prefill. On Anthropic the premium is 0.1× the input price and the claim is 1.25×, so the claim is worth about twelve premiums. Pay one premium every 4 minutes and the premiums exceed the claim after roughly eleven of them: 46 minutes of pause. That is the line.

Concretely, on a 100k-token Anthropic prefix (about $0.30 of input at list price): each ping costs $0.03, and a cold re-prefill costs $0.38.

  • 10-minute pause: two pings, $0.06, and you skip the $0.38. Keep it warm. You are 6× ahead.
  • 46-minute pause: eleven pings, $0.33, versus the $0.38 re-prefill. Roughly a wash. This is the line.
  • 1-hour pause: fifteen pings, $0.45, to avoid a $0.38 re-prefill. Stop pinging. Let the cache go cold and pay the re-prefill when you come back.

The formula tells you where your own line sits once you plug in your prices and interval. The point is that there is a line, it is closer than people assume, and past it the disciplined move is to stop paying premiums on a policy you will never claim.

The 30-second convention everyone copies has a break-even of about 6 minutes, which is why it loses money at a 10-minute gap on all four providers. I ran the 4-minute arm too: pings fired at +240.1s and +480.1s (0.1s drift), held 23 of 24 samples warm, and cost 7.8× less than the 30-second arm for the same warmth. The convention isn't cautious. It's just expensive.

600s idle, 100k prefixLet it dieKeepalive 30sKeepalive 240s
Anthropic Sonnet 4.5$0.667 (cold)$0.867 (loses money)$0.414 (saves 38%)
OpenAI GPT-5.1$0.115 (usually warm anyway)$0.317 (loses)$0.136 (loses)
DeepSeek V3.2$0.043 (cold, 5.4s TTFT)$0.249 (loses)$0.060 (loses; but ~3× faster)
Gemini 2.5 Pro$0.131 (usually warm anyway)$0.649 (loses)$0.186 (loses)

Look at the last column. At a 10-minute pause, only Anthropic and DeepSeek have evicted, so only they have anything to insure, and even there the 30-second convention loses money. That is what I first published: at 10 minutes, only Anthropic actually saved. But that was a fact about 10 minutes, not about the providers. OpenAI and Gemini were still warm at 10 minutes, so of course keeping them warm bought nothing. The interesting question is what happens once they evict.

The paying band, measured

So I ran it again at a 30-minute pause, where the retention curve says every provider except Gemini is fully cold. Now there is a re-prefill to avoid on all of them. Same 4-minute keepalive, same 100k prefix:

1800s idle, 100k prefixLet it dieKeepalive 240sVerdict
Anthropic Sonnet 4.5$0.333 (cold, 2.9s TTFT)$0.214saves 1.56×
OpenAI GPT-5.1$0.104 (cold, 4.4s TTFT)$0.085saves 1.23×
DeepSeek V3.2$0.022 (cold, 5.4s TTFT)$0.108loses; buys latency

There it is. Once OpenAI actually evicts, its keepalive saves money too. The keepalive was never an Anthropic-only trick; it pays for any provider once your pause is long enough to reach eviction and short enough to stay under break-even. Each provider has a band where this holds: Anthropic from about 5 to 46 minutes; OpenAI from about 30 minutes out to over an hour at its own best interval (next section). Outside the band, on either side, you are paying premiums for nothing.

DeepSeek is the honest exception. It does evict, but a cold re-prefill costs two cents, so the pings cost more than the eviction they prevent no matter how you time them. Its keepalive is a latency play only: 5.4 seconds to first token down to 2.0. Gemini is worse: it never reliably evicts (its hit rate is a routing lottery, not a retention curve) and its cached reads cost 0.25× instead of 0.1×, so there is no pause length where keeping it warm pays on cost. For those two, keep warm only if you are buying speed, never dollars.

Past the TTL, pings turn toxic

One question remained, and it is the one a sharp reader would ask next. If keepalive cost falls as the interval grows, why stop at 4 minutes? So I kept going: same 30-minute pause, same prefix, ping intervals of 4, 8, and 15 minutes.

Three panels: marginal keepalive cost vs ping interval for Anthropic, OpenAI, DeepSeek, with warm counts and the let-die baseline as a dashed line
Marginal cost of the pause at each ping interval, with warm counts. Dashed line: just letting the cache die.

The interval is bounded by the provider's own retention, and the chart shows both sides of that line.

OpenAI's cache holds 8-minute gaps, so 8-minute pings halve its cost again: $0.042 against a $0.104 re-prefill, a 2.45× saving, double what 4-minute pings deliver. Its true optimal interval is about 8 minutes, not 4.

Anthropic at 8-minute pings is a catastrophe, and the reason matters. Its cache dies at 5 minutes, so every 8-minute ping lands on a dead cache and re-prefills it at full write price. Three pings, three full prefills, and you still arrive warm only by accident of timing. The bill: $1.334, four times the cost of never pinging at all. An interval past the TTL is not merely wasteful. Every ping pays the exact penalty it was meant to avoid.

Nobody survives 15-minute pings, and DeepSeek at 8 minutes is a coin flip (its cache dies around 9). So the sharpened rule: the economical interval is your provider's own measured retention minus a margin, and it is per-provider. Four minutes on Anthropic. Eight on OpenAI. A multi-provider agent that uses one global ping interval is either overpaying on OpenAI or burning money on Anthropic.

What is settled, and what I believe

Settled: the arithmetic above, the measured retention curves, the measured 7.8×, the break-even horizons, and the interval frontier with its toxic edge. Those you can check against the data, which is public with the harness.

Belief: what happens when everyone takes this advice. A cache tier's eviction policy ranks by expected reuse; a keepalive manufactures recency, so once every client pings, LRU has nothing left to rank and the tier degrades for everyone. Residency today is priced per read, not per token-hour held, so each operator's rational rent payment imposes an unpriced cost on every other tenant. My prediction: keepalive adoption forces providers to meter residency directly. Google's explicit cache already bills per token-hour, and Anthropic's 1-hour tier at 2× write is a step in the same direction. The arbitrage is real, and it has an expiry date.

The policy

  • Keep warm only across bounded, plausibly reused pauses (a tool call, an approval wait), at τ* set per provider to its measured retention minus a margin. About 4 minutes on Anthropic, 8 on OpenAI, 50 on Anthropic's 1-hour tier.
  • Never let τ exceed the provider's retention. Past it, every ping re-prefills a dead cache at full price and the keepalive costs more than doing nothing (4× more, on Anthropic at 8-minute pings).
  • Abandon the keepalive past the break-even horizon (≈46 minutes at Anthropic prices). Let it die, re-prefill, walk away.
  • Stay inside the paying band. Keep warm only when your pause is longer than the provider's eviction point (Anthropic ~5 min, OpenAI ~30 min, DeepSeek ~10 min, Gemini never) and shorter than its break-even. Anthropic and OpenAI save money inside their bands. DeepSeek and Gemini never save on cost, only latency.
  • Below the eviction point, do not bother. The cache is still warm on its own, so the pings buy nothing. This is the mistake the 30-second convention makes on every provider.
  • Never keep a dead session warm. The pi agent harness implements exactly this: pings only while a tool batch runs, default off.

Keep it warm, briefly, at your provider's own rate. Ping less, but never slower than the cache forgets.

References