Your Agentic Workflow's Cache Keepalive Costs 8x Too Much

https://lobste.rs/rss Hits: 16
Summary

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, and the surprise is bigger: at the ten-minute pause I measured, only one of the four major providers saved money with a keepalive. I measured this 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. A 30 s keepalive loses money at long gaps on every provider I tested. On Anthropic, the 4-minute keepalive saves real money. On DeepSeek it buys latency, not dollars. On OpenAI and Gemini it buys nothing at these gaps. Whether to keep the cache warm is a per-provider decision, not a universal one.The pause that eats the cacheProvider 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 the right answer. What it didn't have was measurement. Everything above is practice and arithmetic. Everything below is measured: four providers, two prefix sizes, idle gaps to ten minutes, three i...

First seen: 2026-07-21 21:33

Last seen: 2026-07-22 12:44