Rendered at 21:00:34 GMT+0000 (Coordinated Universal Time) with Cloudflare Workers.
Wowfunhappy 1 days ago [-]
I find it really weird that Anthropic uses only a five minute cache on the API. Even in the course of active work, many commands—compiling, running tests, etc—take longer than five minutes to complete.
I of course don't know what it costs Anthropic to keep the cache warm—but since their subscription plans use one hour, Anthropic must have concluded a longer cache is more economical for most users. And there's a big difference between one hour and five minutes.
Aurornis 1 days ago [-]
> I find it really weird that Anthropic uses only a five minute cache on the API.
You can set 5 minute or 1 hour with API requests. It's the user's choice, not something they force on you. You get the cheapest option (5 minutes) if you don't specify the time.
> You get the cheapest option (5 minutes) if you don't specify the time.
Okay, but isn't it weird that the default is a giant footgun?
Aurornis 1 days ago [-]
The API is used for a lot more than agentic coding. I would not be surprised if 5 minute was preferred on average across all types of usage.
If Anthropic set it to the more expensive option by default, we'd be reading articles about people complaining how evil they were for defaulting to the more expensive option.
PHLAK 22 hours ago [-]
But why not have a 30 minute option by default then allow users to opt-in to either more or less as needed?
reddozen 17 hours ago [-]
But why not have a 5 minute option by default then allow users to opt-in to more as needed?
plzrun 16 hours ago [-]
Why not have no default and make it explicit?
rat9988 6 hours ago [-]
You break backward compatibility
reddozen 9 hours ago [-]
True! Every single option have no default! Your curl should look like a book every invocation.
plzrun 5 hours ago [-]
No, just that one.
bigfishrunning 6 hours ago [-]
mine usually does...
drfloyd51 17 hours ago [-]
beautiful
InsidiousWombat 10 hours ago [-]
because it's a footgun, pls follow thread you're answering to, it was already discussed
reddozen 9 hours ago [-]
It's not any more of a footgun than setting a default to a more expensive option.
You're advocating for a change therefore it's your burden to provide a positive argument which you're presupposing.
pohl 7 hours ago [-]
Isn’t the shorter cache time more expensive for the user?
rat9988 6 hours ago [-]
Depends on the usecase.
infecto 7 hours ago [-]
I have to wonder if you have even coded with any of these APIs before. I have been using them far before caching was even an option and for a lot of workflows you build you don’t necessarily want to use any caching. These APIs are not that complex and I am kind of shocked people would even think it’s a footgun. There are a handful of configurable items and if this a footgun I fear for engineering.
krzyk 12 hours ago [-]
Because 5min is cheaper for users. Look at API costs
alienbaby 22 hours ago [-]
Because that doesn't minimise their costs?
IanCal 19 hours ago [-]
Because that's more expensive for any single request.
gcr 18 hours ago [-]
API users who care could opt-in to less caching though.
weird-eye-issue 7 hours ago [-]
The default is already NO CACHING. You have to enable caching explicitly in the first place!
renaudg 16 hours ago [-]
API users who care can opt-in to more caching though.
gobdovan 1 days ago [-]
yeah, not sure why you're downvoted, but the API is clearly for using Claude in your products that you serve to your users. It's also why it's priced higher since it's assumed to be close to where you make money. It's the same with cloud computing, where clouds could charge 1000x the involved compute for some per-access DB, but you wouldn't run a nuclear reactor simulation on Firebase.
anakaine 1 days ago [-]
> you wouldn't run a nuclear reactor simulation on Firebase.
I mean... you say I wouldn't, but im all up for trying.
vnorilo 1 days ago [-]
naturally on a single instruction move-only VM in real time database that works via database trigger cloud functions!
sheepscreek 22 hours ago [-]
More often than not, they’ve come out looking disingenuous. Maybe they need to hire a better customer relations leader - someone that gets ahead of the problem.
Their API customers should know about changes affecting them well ahead of time. They should have a zero surprise policy around any change that influences cost (cache is one such thing, price difference between a cache hit/miss is 2x-5x input cost per request).
xvector 22 hours ago [-]
There's so much hysteria around Anthropic that there's no point in them hiring a customer relations person, HN has totally lost the plot when it comes to them
redanddead 20 hours ago [-]
> The API is used for a lot more than agentic coding. I would not be surprised if 5 minute was preferred on average across all types of usage
These vendors are interchangeable, the business models and sectors are largely the same, I doubt there’s a purely business reason behind that decision, likely a technical leadership decision
The more opinionated a vendor is within a category that’s merging, the worse the user experience
And about your second point, Anthropic is not exactly a friend. It’s dubious to be knocking open models the way they do, while simultaneously restricting free use for others. That’s not a normal thing to do
jazzypants 23 hours ago [-]
> I would not be surprised if 5 minute was preferred on average across all types of usage.
Why would anyone prefer something they don't notice unless it's more expensive?
drfloyd51 17 hours ago [-]
When the alternative is paying more and never noticing it could possibly be lower?
infecto 22 hours ago [-]
Because it is more expensive and I think that is true for most/all api providers.
jjfoooo4 23 hours ago [-]
It's highly workload dependent whether the (cheaper to write) 5 min cache or 60 min cache ends up being cheaper. For my co's workforce we went with 60 min, but it's basically a wash
bensyverson 5 hours ago [-]
No, it's the correct default. Most API calls are not coding agents.
wat10000 6 hours ago [-]
It's not. I've done the analysis on my usage and 5m is cheaper. From talking with others, this seems to be typical. The default is what's cheapest for most users.
The root comment mentions commands that take over five minutes to complete. How often is the agent doing that, versus something quicker? Usage tends to be, the agent does a ton of quick back and forth actions with directory listings and edits and file reads, and then after many quick rounds it eventually kicks off some slower compile/test/run stage which might exceed five minutes. If you use the 1h cache then that slower stage might be cheaper, but all of those quick rounds leading up to it are definitely more expensive. For 1h to work out in your favor, you need a substantial proportion of your work to wait between 5-60 minutes between rounds, including all those little back and forth rounds that happen while the agent is working and barely appear in the UI. This isn't very likely.
munk-a 1 days ago [-]
This is a place where it'd probably good if there wasn't a default set. I think we leap too readily to providing defaults for settings without thinking through whether the value is something the user should be intentional about declaring or leaving as-is.
infecto 7 hours ago [-]
Giant footgun? Are we all imbeciles? I am truly confused what folks like yourself are arguing. These APIs have a handful of items you can tune. You have to opt into caching via API already. Why is this a footgun? Are we saying an engineer who has made the decision that their work benefits from caching (which costs more) can not understand that it defaults to the lower cache limit?
kristjansson 1 days ago [-]
If it was the other way people would complain they’re gouging
blurbleblurble 15 hours ago [-]
Par for the course
bagels 21 hours ago [-]
You know that memory isn't free, right?
Loquebantur 1 days ago [-]
It's what their business model tells them to do: maximize profit per token.
Making you spend tokens without noticing it is a free meal to them.
There are various other possibilities to clandestinely extract tokens from you. People just haven't thought about it yet.
munk-a 1 days ago [-]
Given the massive opacity around tokens and how they're used in closed systems we interact with I'm often surprised when discussions around them just assume there is no underhandedness involved in inflation or controlled deflation to maximize revenue.
2001zhaozhao 1 days ago [-]
> footgun
What a load-bearing observation. Good instinct!
KronisLV 12 hours ago [-]
Why not 15 minutes and 1 hour?
Why not 30 minutes and 1 hour?
Because 5 minutes is probably good only for uninterrupted agentic work, if I have to pause and read anything, it's expired.
etherlink 21 hours ago [-]
[dead]
TheRealPomax 23 hours ago [-]
except API requests are billed separately from your paid plan, so...
PaulKeeble 1 days ago [-]
Deepseek seemingly stores the cache for literally days, so its a really odd choice to have it so short.
speedping 1 days ago [-]
Latest deepseek kv cache is tiny compared to other models thanks to its architecture, so storing it requires much less space
minraws 1 days ago [-]
It's also less vram and hence bandwidth hungry so much friendlier to hold for longer and swapping in and out to storage. If kv cache is large enough and slow enough, then prefill could turn out to be faster than cache restore... Although it depends on how the cluster and infra is setup, either way, Anthropic is subsidizing the subscriptions if all benefits and limits and etc. are included by at least 2 orders of magnitude aka ~100x compared to API which is rather insane..
It's surprising, and also not really surprising that they then charge enterprises and companies with over 100/150 employees full API prices with some bulk discounts.
I have seen a bill for a small 100+ person company for their tokens and it's insane when you compare it to how many tokens I burn in a week.
I waste more tokens on chasing useless stuff over a couple weeks, then their entire company spends in an entire month tbh that might include resets but this is madness, I am not sure if the music will stop but if it does I don't feel like I nor my current employer will be paying the full price for the tokens.
InsidiousWombat 9 hours ago [-]
Only shows profitability is a long way out
extr 24 hours ago [-]
Do they store it for days or do they just not charge you for breaking it?
The latter. I get no payment hit for resuming a project weeks later.
TeMPOraL 11 hours ago [-]
I got a "payment hit" by Claude Code's recently introduced "auto compact while idle" "feature" fatally poisoning every conversation after an hour, which I didn't immediately notice. This wasted me a good day of work (and two resets) before realizing that Fable isn't sandbagging me, it's just dumb, because the session gets compacted every time I'm not looking at it.
Disabled this since, but I'm angry at whoever thought up this "feature".
hombre_fatal 1 hours ago [-]
The feature is essential for me.
I guess if you're like me and you use a lot of long-running conversations over the course of days, like convos running on your remote machines in tmux where you want to ssh in and pick things back up from last time, idle-compact is a money (usage) saver.
But if you leave conversations open that you never plan on using again or if you have long-running convos where you would rather keep all context than a compacted version, then you won't want it. But those seem like exceptional cases.
resonious 16 hours ago [-]
You can refresh the cache TTL by sending an empty inference request.
We save about $1,000 per week by implementing an Opus cache warmer that keeps the 5-minute cache alive for ~30 minutes instead (on the router level).
It's so strange to me that Anthropic does not do this on their end...
kleton 1 days ago [-]
If you use the claude cli via subscription Oauth2- you will see that this endpoint does not accept five or sixty minute cache control directives in request bodies, just "ephemeral". So presumably they are using a sensible time period for normal use, but this report is on third party harnesses, so it is using the bill-per-token api.
helsenki 23 hours ago [-]
Hit this with Rust all the time. One cold cargo test run takes over five minutes and wipes the cache.
pilafbigking 14 hours ago [-]
[dead]
ethan-ys 8 hours ago [-]
You could try using a mobile app to send commands on the go—especially one with push notifications and haptic alerts so you can pick up right where you left off. I've been using https://apps.apple.com/us/app/andco/id6818176139 for this.
Majromax 1 days ago [-]
Since the API is bare, the use cases will be broader than just agent sessions -- automated scripting and customer-served chatbotting are two obvious supplemental use-cases. Those are likely to have very different cache dynamics compared to a Claude Code session, so 5m expiry might be the hit-rate-optimizing point.
kolinko 1 days ago [-]
You can select 1h via api, but it’s seldom useful really. If you handle stuff via api, you can just have a keepalive around 4 min checkmark. It is quite irritating though.
iaaan 1 days ago [-]
Interesting that you'd conclude Anthropic is looking out for the economic interests of their customers over their own.
Wowfunhappy 1 days ago [-]
The amount Anthropic can charge per token is determined by how much value users get from those tokens. If users are getting more value, Anthropic can charge more and take a bigger profit.
Which means it is in Anthropic's interest to set cache lifetimes at a number that will let users get the most value from their tokens, relative to whatever it costs Anthropic to maintain the cache.
jason_s 1 days ago [-]
That economic statement assumes that customers are rational, transactional (vs relationship/brand-driven) and are monitoring and optimizing their cost spending frequently.
Which is not true for many in the enterprise world. Anthropic has been much better (IMHO) at branding than OpenAI, and rather than talking about "agents" many of my coworkers talk about "Claude". I think most of us aren't aware of the cache lifetimes; we just use the model we're used to, and switch only if pressured/forced by our company AI staff to do something different.
Grocery stores are a great example of the power of branding --- some grocery stores are more expensive on the whole but people still shop there for other reasons: because it's conveniently located, because they have certain items in stock, because they have sales, because they just like the shopping environment.
Wowfunhappy 23 hours ago [-]
Of course consumers aren't perfectly rational, but there is still a relationship between the usefulness of Claude's output (per how much it costs) and whether people will keep paying for it.
If there was truly no relationship, why cache anything at all instead of making it expire immediately? Why not increase prices infinitely? Why release new Opus models at all, instead of referring to new versions of Sonnet as Opus?
Capricorn2481 1 days ago [-]
Does the average user even know what value they are getting from Anthropic? As though there is some kind of metric?
I don't think value is some immediately obvious and observable phenomenon. The average person doesn't even know what prompt caching is. It's completely feasible for them to set defaults that overcharge customers without them knowing.
10111001 1 days ago [-]
> The amount Anthropic can charge per token is determined by how much value users get from those tokens. If users are getting more value, Anthropic can charge more and take a bigger profit.
I feel like statements like that, looked at most charitably, benefit from the confusion between some technical definition of "value" and a a more colloquial definition.
The easiest way to interpret that is: "what's good for you is good for Anthropic, so trust Anthropic," but that's almost never what's going on when you're dealing with a sophisticated business. In all market interactions, "value" is relative and everything is almost always obscured by intense information asymmetries. The business wants to maximize profit for itself, which often entails minimizing the value provided to customers (because more "value" usually costs something) and maximizing the price they pay for it.
Wowfunhappy 23 hours ago [-]
> The easiest way to interpret that is: "what's good for you is good for Anthropic, so trust Anthropic,"
All I'm saying is that Anthropic has an incentive to help you get more done with fewer (uncached) tokens. They are also incentivized to charge you more for those tokens once you've become more efficient, which is obviously not in your interest. But purposefully setting cache lifetimes to a value they knew would screw people over would be insane.
It would be equally stupid for Anthropic to, for example, make the Claude Code harness waste tokens needlessly, as some people seem to believe they do. That doesn't make any sense, because people are paying for how much use they can get out of Claude.
Loquebantur 1 days ago [-]
The interest of any provider of proprietary inference is to make the most money per token.
Users don't have such a precise metric that would allow them to discriminate value per token reliably. Or have you never seen those comparison sites, with dozens of different scales?
If they can make you reload your cache statistically more often without you noticing (increasing their profits), their business model mandates them doing so.
vineyardmike 1 days ago [-]
They are for subscription plans, where they pay by token and the user pays a fixed cost.
Subscription plans best align the user’s interest with the company’s interest. Presumably, the user’s goal is not token burn but some underlying task. The cheaper the company can accomplish that task, the more money the company keeps. If the user has to constantly retry because the model is bad, that’s more cost to the provider. If the model is big and slow and wastes tokens, that’s more cost to the provider. The more tasks that can be accomplished in the fixed quota, the better value perception by the user.
bee_rider 1 days ago [-]
It seems like what would best align the interests of the customer and company would be if they’d charge by completed task instead of… tokens/time. (Why are these internal compute metrics being exposed to the customers?).
dotancohen 1 days ago [-]
For the same reason cars are sold with fuel gauges and people ask how many liters of gas they need to go 100 km.
It's a useful metric, especially for those who know what it means.
Wowfunhappy 23 hours ago [-]
Bob asks Claude to build a single-page, static website for his reading club
Alice asks Claude to build a brand new operating system with an original C compiler and web browser.
Are Alice and Bob both billed for one completed task?
No, obviously not—you'd have to somehow bill by the amount of effort each task takes. Now you need a way to measure "effort".
Okay, now we need a way to measure effort. Hmm, how about, measuring by the amount of tokens the task consumes? Oh, wait... :)
Loquebantur 1 days ago [-]
That's not true.
It's rather an equilibrium based on what they can get away with.
It's safe to say, that equilibrium is a safe distance from what's in the users interest.
dpz 1 days ago [-]
From their side as well it's preferable for uses to hit the cache. Definitely cheaper for them too
wat10000 6 hours ago [-]
Smart businesses find ways to look out for the economic interests of both parties. The Jevons paradox means that this often comes from finding ways to sell your products cheaper.
Modern business seems to be forgetting this lesson, and Anthropic may not be "smart" by this definition, but it would be completely rational for them to look for ways to cut their customers' costs.
Loquebantur 1 days ago [-]
There are many such open questions about "clandestine token-maxing" that get glossed over.
For any provider of proprietary inference, the targeted optimization of how (long) their models work according to their own goals is a central part of their business.
People believe those optimizations being about giving them the "best" inference. They fail to notice whose "best".
cavemandaveman 1 days ago [-]
It's a competitive market, is it not? If they don't, they'll lose market share to Google or OpenAI
eli 1 days ago [-]
They probably do around the edges. But I bet they'd lose more if they raised the list price per token and included a longer cache time by default even if it the average bill works out the same.
traviswingo 1 days ago [-]
I regularly favor the economic interests of my customers over my own.
I’m also not running a multi billion or trillion dollar company, and probably never will if I keep doing it.
I’m okay with that.
gleenn 1 days ago [-]
If the KV cache is in RAM (whether system or GPU) it's because RAM is at a huge $$$ premium right now.
auspiv 1 days ago [-]
it takes claude 15-30 min to add a disk layer cache after system memory FYI... have this going on my 8x v100 server for all openweight models I'm running. currently preferring glm-5.3-flash. prefill is around 3k tok/s, decode is about 80 tok/s. have room for 3x 262k sessions with room to spare. and memory for another million. then a 6.4TB NVMe for quite a bit more.
deepseek-v4.1-flash per token kv is IIRC 600-700 bytes. this is much, much less than other models. and 500x less than deepseek v3.
tecleandor 8 hours ago [-]
What do you use for disk layer cache?
nonacosa 2 hours ago [-]
[dead]
xenoci 1 days ago [-]
[dead]
yuppiton 15 hours ago [-]
[dead]
nelox 19 hours ago [-]
[dead]
michaelmrose 1 days ago [-]
[dead]
Aurornis 1 days ago [-]
On a subscription plan (not API requests) Claude Code defaults to 1-hour cache duration for the main conversation and 5 minutes for subagents.
So if you're not paying API rates, you need not worry. You can force the main conversation or subagents to either 5 minute or 1 hour in the Claude settings file if you would like.
If you are paying API rates, paying close attention to caching is important. 1 hour is best for sessions where you have to think a lot, examine output, or wait for long builds because 5 minute interruptions are very common. The price premium for 1-hour TTL isn't that high over 5-minute, so I use it by default.
It's also good to get in the habit of doing /compact when you know you might be AFK for more than the cache TTL. Doing the /compact on a long context conversation after the cache has expired is much more expensive.
ffsm8 1 days ago [-]
Claude code actually compacts the main session just before the cache runs out automatically.
No idea when they added that, Its gray text that looks exactly like the auto summary line, so easy to miss (as it only shows up when you're idle for 55 minutes or so, and have a session that's compact worthy - again no idea what threshold they use)
skerit 1 days ago [-]
That is indeed a setting that is in by default now, though I've noticed in some session that it doesn't trigger and I have no idea why
ValentineC 22 hours ago [-]
Auto compact for 1M models only happens if the context window exceeds 400k:
I haven’t been able to always turn this on. Sometimes idle compaction happens and sometimes it doesn’t. Does anyone know how to always enable this?
giancarlostoro 1 days ago [-]
> and 5 minutes for subagents.
Ah, this explains so much, I need to adjust my settings. Lately I've been using bigger models to drive smaller models to do changes, sometimes they run for 45 minutes or more, so I definitely need to tweak my subagent cache time window. I'm not on API billing, but still.
RussianCow 20 hours ago [-]
To be clear, the cache "refreshes" on every new request. So it would only expire if your agent didn't send a request for 5 minutes, which is very unlikely.
taude 19 hours ago [-]
what about for the sub-agents? I thought they were in their own CC sessions? Do subagets keep the parent session refreshed?
RussianCow 3 hours ago [-]
> Do subagets keep the parent session refreshed?
Not until they finish, but the cache duration for main session defaults to an hour. So as long as the subagent doesn't take over an hour, it doesn't matter.
zerd 18 hours ago [-]
Not unless they "reply" to it, e.g. when they finish.
What helped me a lot was to add a rule to "inside subagents, bound each blocking call at ≤4.5 min". A lot of times it would have a `timeout 600 run command`, and then every time that timed out it would be a cache miss. Making it aware of the 5 minute limit helped. You can also ask it "analyze the previous week of Claude sessions and look for ways to improve <x>".
ryanskidmore 17 hours ago [-]
It's usually more efficient to just refresh the 5 minute cache rather than pay for 1 hour caching
On subs if i remember correctly cache time for openai is infinite.
They are nice like that
whatifitoldyou 1 days ago [-]
Is there a pi plugin for resetting the keepalive? Sounds simple enough. From the article:
What is a keep-alive ping for prompt caching?
-
You send the last request again with max_tokens set to 0 about every 4.5 minutes. The API reads the cached prefix, returns no output tokens and restarts the cache timer. In our replay, keep-alive pings capped by session depth cut a Claude coding bill by about 8 to 9% net.
"hey claude make a plugin for our api proxy that removes 1hr cache requests" and sends keepalives like this ^^^
lol if this works there is no way they are gonna let you keep getting away with it
Aurornis 1 days ago [-]
You pay for the cache reads. It's not a loophole.
cognitivegears 17 hours ago [-]
correct. The trick is to figure out how likely you are to come back to it. Warming the cache costs money, but can make sense if you are likely to send another message.
I've been thinking it might make sense to make a mod that uses a super cheap decision model (Jev or similar) to evaluate (maybe based on time of day, whether the last message was a question, etc.) to decide whether to warm the cache.
compiler-guy 1 days ago [-]
Everything old is new again. Something similar was a time honored technique for getting an OS scheduler to keep a long-running task at interactive priority by writing a character to the console every so often, so it looked like an interactive process.
How to defeat these countermeasures used to be covered in os courses. I suspect the llm vendors will adopt similar techniques.
If I'm not mistaken, on subscription plans your main agent defaults to 1 hour cache with subagents spawned by the main session on 5 minute cache timer.
Best ensure your subagents avoid getting blocked if there's any wait or command that takes more than 5 minute.
staticshock 1 days ago [-]
Yeah, this looks like a discussion of API traffic, not claude code subscription traffic. I'd be shocked to find out that my claude code sessions, which auto-compact "before the cache expires", after 54 minutes of idle time, due to claude code's own idleCompaction setting, was actually already expired at that point.
viccis 1 days ago [-]
You can also spawn subagents with 1h TTLs if you know they'll be doing activity with lots of time spent waiting
jondwillis 1 days ago [-]
Welp, doing this immediately. I had to build a Rust build queue and a client lease system for a game I have been building entirely with agents (intentionally with a lot of subagents and multiple top-level sessions) just to avoid consuming all available memory and compute on a server I have laying around. I have a lot of subagents that end up having to wait for a long time for their turn to build and run the game to verify behavior.
bigmadshoe 1 days ago [-]
Do those tokens cost more? Why would anyone choose the shorter cache?
viccis 1 days ago [-]
They cost 2x as much
Ask your agent to look at its own usage metrics to see if you would have saved money by doing so. If your test suite is >5 mins then you likely will.
Bolwin 1 days ago [-]
Probably takes more usage though, so it's the same deal
anakaine 1 days ago [-]
Though not the same cost since cache hits are significantly cheaper than a new cache load.
Eg Opus 5.5 is $4/m input vs $0.2/m cache hit
piishi 6 hours ago [-]
Are there any studies comparing user willingness/satisfaction and prompt wait time? Would likely have to be sorted by type of user, type of AI, and type of prompt (ex developers might be willing to wait longer, people might wait longer for it to generate a slideshow or go through data). Feel like this could be interesting, especially for AI agent developers/startups/etc.
extr 1 days ago [-]
This is obvious if you just put cache timeout in your statusline. If the nature of your work is such that every time you return to the window the 5m cache is expired, bump it up.
bensyverson 1 days ago [-]
Isn't Claude Code on a 1hr cache?
qwertox 1 days ago [-]
On the subscription plan it is 1h for the main agent, its subagents get 5m with some exceptions that also get 1h.
API is all 5m but apparently keeping it warm every 4.5 mins on API is fine.
This is what i heard.
todience 8 hours ago [-]
[dead]
extr 1 days ago [-]
It's not Claude Code so much as provider. If you're on a subscription plan this article doesn't apply to you. If you're using Vertex API or similar it defaults to 5m.
shahbaby 1 days ago [-]
It applies on a subscription too. Not using the cache burns your usage faster.
jadar 1 days ago [-]
Yes but the cache on subscription plans is 1hr
FiReaNG3L 1 days ago [-]
Not for subagents it isnt, 5 minutes for them
wahnfrieden 1 days ago [-]
For some context, on Codex subscriptions, the cache is forever
andai 1 days ago [-]
I guess that refers to cache pricing? (Surely after some time the tokens are no longer cached, but you mean they still charge you as though they were?) Either way, that's surprising.
wahnfrieden 13 hours ago [-]
All we know is what OpenAI claims which is that they're cached permanently. Yes, it's billed as such.
> You can now cache for 12h in the API and for logged in users across Codex & Work we keep cache forever and you don’t have any penalty for coming back to an old conversation or resuming after a few hours and are now guaranteed to hit the cache.
However, a month later:
> First request after a long turn reports a near-full cache miss for logged-in users
I also make it compact at 200K tokens and not 1M. Has anyone seen a benefit to using 1M context wth Fable?
andai 1 days ago [-]
Several studies have found that performance degrades sharply after 100k tokens or so, even in models with much larger contexts. (The further out you get the lossier the attention gets from what I understood.)
(Which is funny, because you pay a premium on many providers for the worse attention!)
The last study I found was from a little while ago though, and there's been a lot of development in attention mechanisms since then. So it might be less bad now.
ywvcbk 9 hours ago [-]
I think that was certainly true 6-12 months ago but recent SOTA models are much better at operating with contexts closers to 1 million.
ValentineC 22 hours ago [-]
I wonder if those studies are relevant for frontier models like Fable 6.2 and Opus 5.5 now, considering they're supposed to be good for "long-running tasks".
nimchimpsky 1 days ago [-]
[dead]
extr 1 days ago [-]
Okay and? The article is not about subagents, and subagents are a natural fit for the shorter cache window.
theanonymousone 1 days ago [-]
Where can I find cache "duration" of different providers? I have never seen such information, despite it being a very big deal in cost estimation. Or maybe it's dynamic?
daemonologist 1 days ago [-]
Not all providers publish it, and aren't always correct when they do. For some providers (e.g. DeepSeek, Antigravity Gemini) it is indeed dynamic/not guaranteed.
Bet bet is to measure it yourself by observing billing/credit usage or time-to-first-token.
I don’t know why this is downvoted — it’s true since october or sometime around that
wahnfrieden 13 hours ago [-]
People too pilled on other providers that can't imagine it to be true.
refulgentis 1 days ago [-]
It's not dynamic, in the sense pricing has rules, but, it is dynamic in the sense you won't always hit the cache.
Generally, by Googling "(provider) llm cache cost and duration" - can't recommend any source that collects them all.
Generally OpenAI and Anthropic are very serious about this and document it well.
Google is currently a shit show but getting better if you're on Interactions API.
The not-$1T crowd, i.e. other inference providers, can't and won't really guarantee anything.
OpenRouter shows data on their cache hit rates.
On not-$1T-crowd APIs, they'll want to set an arbitrary hint that they'll use for server affinity. (i.e. Fireworks needs to know this request wants to run on the same server/cluster/whatever as the last request so it can get a cache hit)
unleaded 22 hours ago [-]
Why haven't the AI companies tried a thing where they send you a [encrypted or whatever] blob of the KV cache to store locally, then you can send it back to them (maybe after they've stored it for a while and it's expired) to save them the work of processing it again?
gruez 22 hours ago [-]
Because the KV cache is huge, in the range of hundreds of gigabytes for SOTA models.
unleaded 21 hours ago [-]
DeepSeek V4.1 Flash stores 890 bytes/token so a full 1M context window is just less than a gigabyte. I'm sure you're right about the SOTA models but there must still be a lot of costcutting possible once the money slows down
stingraycharles 22 hours ago [-]
The whole “X-minute cache” is a poor abstraction anyway, in reality there are many more caching layers: you need to pre-fetch (fast) into the GPU from RAM, there’s a local disk cache on the nodes, and finally there’s the high latency external storage KV cache.
I think they’d rather have you pay for the 60 minute vs the 5 minute cache than upload / download the huge KV cache at every request (and huge really is huge, dozens if not hundreds of GB).
rishabhaiover 1 days ago [-]
This is a big contributor to long-running sessions. I built a small CLI that opens in a tmux popup and shows what my Cursor agents cost: https://github.com/rishabhBudhouliya/tend.
It uses a ridgeline chart to show how big each chat's context has grown and what it's spending.
refulgentis 1 days ago [-]
These AI written articles are exhaustingly long, and the #s included make it feel very scientific but are one offs for one person.
It's self-labelled as a 15m read and a human in the loop should recognize it's about 3m, tops. Here:
LLM API context caches, by default, only last for 5 minutes on Anthropic and 30m on OpenAI.
If you use Claude, there's an hour cache for 2x the cost of the 5 minute one.
If you use OpenAI, there's a 12 hour cache for 2.5x the cost of the 30m one.
FWIW, it's very Chicken Little / "the sky is falling!!111!": the idea is if you walked away for > 5m between every Claude request, re-caching would be 23% of your bill.
gcr 1 days ago [-]
There’s potential for a 12hr cache on OpenAI?? That’s so good! Thank you I didn’t know this, I’ll have to configure that
viccis 1 days ago [-]
>FWIW, it's very Chicken Little / "the sky is falling!!111!": the idea is if you walked away for > 5m between every Claude request, re-caching would be 23% of your bill.
I did indeed run into this problem when I was steering 4 or 5 chats that would ask for feedback that took a few minutes to provide. Pretty soon you're juggling a bunch of 5 min timers if you don't want every single response to have to rebuild the cache.
vikramkr 1 days ago [-]
Not even 3 min. Took like 3 seconds to skim the title and understand that it's about cache misses (and that Claude is probably presenting it in some inane incomprehensible technobabble so someone who isn't familiar with prompt caching's budget impact already is going to read the whole thing and still have zero idea wtf is going on)
cespare 1 days ago [-]
Nice summary.
I could tell that this was AI-written just from the turn of phrase in the title before I even clicked :\
jmkni 1 days ago [-]
Yep, KISS seems to have been thrown out the window in the age of AI
matkoniecz 1 days ago [-]
> FWIW, it's very Chicken Little / "the sky is falling!!111!": the idea is if you walked away for > 5m between every Claude request, re-caching would be 23% of your bill.
On subscription (so 1h cache) I run into this being even higher, reaching 50%, before I noticed problem.
bob1029 11 hours ago [-]
I think that ultra fast models are going to do wonders for cache hit rates.
We could probably reduce cache TTL under a minute if we can get our agent loops and token rates fast enough.
Speed is the answer to everything, including more intelligent models.
NooneAtAll5 1 days ago [-]
just use deepseek
10-100x cheaper is not something to sneeze at
jasondigitized 1 days ago [-]
Can I get close to Opus 5.5 levels of goodness?
the_real_cher 1 days ago [-]
Via what portal?
phainopepla2 1 days ago [-]
Deepseek official API is best.
the_real_cher 19 hours ago [-]
I haven't used anything but Claude I didn't know DeepSeek had its own. Thanks.
matkoniecz 1 days ago [-]
10-100x cheaper than what?
Are they offering Opus 5.5 quality and quantity of 20$ Claude subscription at and 2$/month? Or 0.2$/month?
What about using anthropic (or openai) models from other tools? E.g. github copilot or jetbrains junie ?
superjan 1 days ago [-]
What helps: run agents in a VM so they can have full control and don’t need to wait for your approval. Firewall it from your local network.
And start a new blank session with its own branch (and have the agent update the project readme) so you can restart without context.
sneak 1 days ago [-]
Why firewall it from your local network?
ticulatedspline 1 days ago [-]
isolation from your own agents hacking you.
It's a bit overkill for most users but depending on what you're asking it to work on it could theoretically traverse your local network to compromise devices/computers and escape the sandbox.
sneak 1 days ago [-]
> isolation from your own agents hacking you.
This is not something that happens, or that is worth spending time or energy thinking about.
> On May 7, 2026, the company began a reinforcement learning run to train an internal-only experimental model that was never released
Come on, it's literally the first or second sentence. It was never released, and it was pre-RL. Base models are wild, always have been, this is common knowledge. The models people are using are not this wild.
Such internal model can tell you how to make a bomb no problem, but try doing that with an actually released, fully cooked one.
Now, of course that agents can lose sight and do weird stuff, RL or not, but IMO it absolutely does hold that spending time on sandboxing their network is a micro-optimization, unless you're doing something that you know does actually trigger that tendency.
Anecdotally, I've been running agents with full permission (YOLO / dangerously skip permissions / whatever harness specific thing) for over two years, with not a single issue. They also have sudo and configure my server's app deployment, firewall rules, and everything else. Again, not once have they deleted anything I didn't want to, do anything significant I didn't want to, hack anything...
Alignment is absolutely a hard problem, but the released models, from openai and anthropic at least, are well behaved and tame.
superjan 1 days ago [-]
As stated by others, it’s a precaution. It’s been shown that agents can get desperate and use whatever they can get their hands on to solve the problem at hand. I don’t want them snooping around the network for information, credentials or test data.
Edit: Not likely to happen currently but having this infra makes it easier to demonstrate compliance with your orgs rules.
kreyenborgi 1 days ago [-]
Many services have ports open, which could give access to things you dont want to share. E.g. if you run syncthing, there's full access to your synced folders if you have localhost access.
sneak 1 days ago [-]
A VM does not have access to ports bound to localhost only, even without a LAN firewall.
eptcyka 1 days ago [-]
To not let the clanker own every computer on your local network?
sneak 1 days ago [-]
If that's something that's possible, you are vulnerable every single time you connect to airport or coffee shop or hotel wifi, and you aren't.
Unless you think it has some secret stash of 0days, in which case you should monitor its traffic and sell the RCE for a million bucks.
eptcyka 15 hours ago [-]
I use other mitigations for those environments.
sneak 8 hours ago [-]
I don’t, and nothing is at risk. Being able to send packets to my machine isn’t a security boundary.
CharlieDigital 23 hours ago [-]
I wrote about my experience using Claude Code in a multi-harness setup (e.g. Orca, T3, Herdr, Paseo)[0]: turn your /autocompact to 300000
The problem I found was that in a multi-harness, multi-agent setup, the other workstreams may take over and then it comes back to a CC agent. Now it's no longer in cache and gets the hit of 800k token close to the limit (example). Burns tokens very, very quickly.
NOTE: you have to `/autocompact 300000` for every model; the setting is model-by-model.
Claude code defaults to 400k autocompact now fwiw.
edwinarbus 1 days ago [-]
Edwin from Anthropic here. Thanks for the thorough writeup. I will point out two things:
1. This looks like API-billed traffic only. Claude Code defaults to a 1 hour cache, not 5 min! So if you're within your plan's usage, this doesn't really apply [1].
2. In the API, we have 5 min and 1 hour TTL options. The "23%" here for the 5 min option includes breaks over 30 min, where both Claude's and GPT's default caches have expired and the loss is the ~same (7.8% vs. 8.5%). If you run long sessions with breaks, and are using an API key, you could set "ttl": "1h". There will be a bit higher write price, though [2].
I measured not just anthropic and openai but also google and deepseek. The cache logic these providers have makes sense for chat but doesn't make sense for agentic workflows. My guess is they have already optimized this on their end or are working on it.
I've felt this long before and my agent's contexts are compacted very very often. Even though they work on a common bus, I try to keep them regularly pooled back to minimum.
kixelated 23 hours ago [-]
scan your transcripts to see if you should change these settings: https://max.kixel.me/
prathamgrv 1 days ago [-]
sure, but the other big use is chat with real users, and people are slower than agents. They don't answer within 5 minutes if they're actually working on something.
jueyi4 22 hours ago [-]
I prefer 1 hour because I think it is more effecient
peter_d_sherman 15 hours ago [-]
I never thought about it before, but apparently
the length of time that a given AI/LLM provider caches prompts for...
(apparently 5 minutes in the case of Claude, 30 minutes in the case of ChatGPT (other vendors will have different numbers) -- if the claims of the article are accurate, as of the article's publication date -- and remember, those numbers even if accurate could be subject to change in the future...),
...does make a very real, important difference in AI/LLM economics!
That is, it's another variable in AI/LLM pricing/costing that must be accounted for!
And, I never saw it, nor thought about it, prior to reading this article...
So, an excellent article for getting me to consider it; for getting me to think about it!
AyishikD 1 days ago [-]
For me umm, the cache matters this much only because every turn resends the whole history. For long running agents I measured on a public long convo benchmark sending full chat history was about 35k tokens per question, while retrieving the 10 most relevant past messages was 500. With 500 tokens a cache miss doesnt matter much so pauses stop mattering. The trade off for me is accuracy full history got more answers right, but also gave more wrong answers than the retrieval setup, which said I dont know more often. Ngl has anyone benchmarked spamming keep alive pings vs just shrinking the context for pausing agents?
the_mitsuhiko 1 days ago [-]
That's why pi has cache warming.
NooneAtAll5 19 hours ago [-]
vs days of cache of deepseek, while being 10x cheaper
ycui7 19 hours ago [-]
vs DeepSeek's 7 days of cache.
charlie2agent 8 hours ago [-]
[dead]
t9tokenbudget 6 hours ago [-]
[dead]
PeterStuer 4 hours ago [-]
[dead]
jeffdrizzy 12 hours ago [-]
[dead]
julianlam 1 days ago [-]
Requisite smarmy comment about how this is not an issue with local models.
There's even the ability to persist your kv cache to disk, so future session resumptions load back into context instantly without needing to do a full prefill ingestion by the LLM. (CachyLLaMA, iirc, not sure where the project is now)
haolez 1 days ago [-]
Up until a few weeks ago, I wouldn't say it (at least for my use case).
But now, with Bonsai 2.5 27B, this is the first time that I don't need Haiku (or a similar cheap model) for tasks in their scope. I think local models are close to an inflection point in usefulness.
Note: I don't have anything local remotely close to reasoning capabilities of SOTA models such as Opus/Neon/Astra.
Forgeties79 1 days ago [-]
What do you use bonsai for? I haven’t really played with it yet
haolez 18 hours ago [-]
Coding. It's not amazing, but it's usable for many tasks. And it is fast.
spillguard 1 days ago [-]
Requisite smarmy reply about how local models are still a subscription, NVIDIA just bills you for it up front
vikramkr 1 days ago [-]
Neon really cooked with tamping down on the inane incomprehensible Claude slop huh? It's so damn annoying when they spew this poetic babbling gibberish.
TDLR prompts are cached. Prompt cache hit == $. Cache miss == $$$$$$$. Claude ttl is 5 min. Codex ttl is 30 min. If u take longer than 5 min between turns then $$$$
wahnfrieden 13 hours ago [-]
Codex TTL is now infinity. Cache doesn't expire on subscription.
On API it's up to 24 hours.
knollimar 1 days ago [-]
Are you saying this is neon? This one sounds like slop to me.
vikramkr 16 hours ago [-]
No I'm saying this is claudeslop, comparing to some of why there was so much hype around neon recently. Claude's writing style is such a mess
j45 1 days ago [-]
It feels a little click baity to not include the word API in that title somewhere.
bill10 17 hours ago [-]
never measured it, but that might explain why my openai subscription last a little longer
h1fra 1 days ago [-]
so we need this loop to keepalive?
for +i; send prompt=prompt+"."
brunoborges 1 days ago [-]
Rust developers be like: "seriously?"
hoechst 1 days ago [-]
indecipherable slop article
srgb_vs_cmyk 9 hours ago [-]
I am sure there is some interesting insight inside, but they hid it too well.
aionapex 9 hours ago [-]
[dead]
weiyiwang 11 hours ago [-]
[dead]
srinivaspadmana 9 hours ago [-]
[dead]
qmplayveil 9 hours ago [-]
[dead]
ben-greenspring 1 days ago [-]
[dead]
longhei_pcyw 17 hours ago [-]
[dead]
prsky99 5 hours ago [-]
[dead]
donovancoledev 19 hours ago [-]
[dead]
srikondapalli1 6 hours ago [-]
[dead]
triangulumlabs 1 days ago [-]
[dead]
ahaliav 1 days ago [-]
[dead]
feerouter 10 hours ago [-]
[dead]
Aryan_Patil5 7 hours ago [-]
[dead]
kevinbaiv 22 hours ago [-]
[dead]
zurfyx 1 days ago [-]
[dead]
amauriya 13 hours ago [-]
[dead]
dann1y 14 hours ago [-]
[dead]
oiwdis 1 days ago [-]
[dead]
cobwebcheck 1 days ago [-]
[dead]
k_ivanow 1 days ago [-]
[dead]
halfinsider 14 hours ago [-]
[dead]
sourav_biswas 18 hours ago [-]
[dead]
Yash16 23 hours ago [-]
[dead]
shllg 23 hours ago [-]
[dead]
junglistguy 21 hours ago [-]
[dead]
doctorpangloss 1 days ago [-]
This is so dumb. Sign the cache and ship it to the client, accept signed caches from clients, problem solved.
esafak 1 days ago [-]
What about the latency problem? Caching takes gigabytes for each session.
doctorpangloss 1 days ago [-]
How do you figure?
I would rather pay for bandwidth than tokens anyway.
I of course don't know what it costs Anthropic to keep the cache warm—but since their subscription plans use one hour, Anthropic must have concluded a longer cache is more economical for most users. And there's a big difference between one hour and five minutes.
You can set 5 minute or 1 hour with API requests. It's the user's choice, not something they force on you. You get the cheapest option (5 minutes) if you don't specify the time.
https://platform.claude.com/docs/en/build-with-claude/prompt...
Okay, but isn't it weird that the default is a giant footgun?
If Anthropic set it to the more expensive option by default, we'd be reading articles about people complaining how evil they were for defaulting to the more expensive option.
You're advocating for a change therefore it's your burden to provide a positive argument which you're presupposing.
I mean... you say I wouldn't, but im all up for trying.
Their API customers should know about changes affecting them well ahead of time. They should have a zero surprise policy around any change that influences cost (cache is one such thing, price difference between a cache hit/miss is 2x-5x input cost per request).
These vendors are interchangeable, the business models and sectors are largely the same, I doubt there’s a purely business reason behind that decision, likely a technical leadership decision
The more opinionated a vendor is within a category that’s merging, the worse the user experience
And about your second point, Anthropic is not exactly a friend. It’s dubious to be knocking open models the way they do, while simultaneously restricting free use for others. That’s not a normal thing to do
Why would anyone prefer something they don't notice unless it's more expensive?
The root comment mentions commands that take over five minutes to complete. How often is the agent doing that, versus something quicker? Usage tends to be, the agent does a ton of quick back and forth actions with directory listings and edits and file reads, and then after many quick rounds it eventually kicks off some slower compile/test/run stage which might exceed five minutes. If you use the 1h cache then that slower stage might be cheaper, but all of those quick rounds leading up to it are definitely more expensive. For 1h to work out in your favor, you need a substantial proportion of your work to wait between 5-60 minutes between rounds, including all those little back and forth rounds that happen while the agent is working and barely appear in the UI. This isn't very likely.
Making you spend tokens without noticing it is a free meal to them.
There are various other possibilities to clandestinely extract tokens from you. People just haven't thought about it yet.
What a load-bearing observation. Good instinct!
Why not 30 minutes and 1 hour?
Because 5 minutes is probably good only for uninterrupted agentic work, if I have to pause and read anything, it's expired.
It's surprising, and also not really surprising that they then charge enterprises and companies with over 100/150 employees full API prices with some bulk discounts. I have seen a bill for a small 100+ person company for their tokens and it's insane when you compare it to how many tokens I burn in a week.
I waste more tokens on chasing useless stuff over a couple weeks, then their entire company spends in an entire month tbh that might include resets but this is madness, I am not sure if the music will stop but if it does I don't feel like I nor my current employer will be paying the full price for the tokens.
Disabled this since, but I'm angry at whoever thought up this "feature".
I guess if you're like me and you use a lot of long-running conversations over the course of days, like convos running on your remote machines in tmux where you want to ssh in and pick things back up from last time, idle-compact is a money (usage) saver.
But if you leave conversations open that you never plan on using again or if you have long-running convos where you would rather keep all context than a compacted version, then you won't want it. But those seem like exceptional cases.
We save about $1,000 per week by implementing an Opus cache warmer that keeps the 5-minute cache alive for ~30 minutes instead (on the router level).
It's so strange to me that Anthropic does not do this on their end...
Which means it is in Anthropic's interest to set cache lifetimes at a number that will let users get the most value from their tokens, relative to whatever it costs Anthropic to maintain the cache.
Which is not true for many in the enterprise world. Anthropic has been much better (IMHO) at branding than OpenAI, and rather than talking about "agents" many of my coworkers talk about "Claude". I think most of us aren't aware of the cache lifetimes; we just use the model we're used to, and switch only if pressured/forced by our company AI staff to do something different.
Grocery stores are a great example of the power of branding --- some grocery stores are more expensive on the whole but people still shop there for other reasons: because it's conveniently located, because they have certain items in stock, because they have sales, because they just like the shopping environment.
If there was truly no relationship, why cache anything at all instead of making it expire immediately? Why not increase prices infinitely? Why release new Opus models at all, instead of referring to new versions of Sonnet as Opus?
I don't think value is some immediately obvious and observable phenomenon. The average person doesn't even know what prompt caching is. It's completely feasible for them to set defaults that overcharge customers without them knowing.
I feel like statements like that, looked at most charitably, benefit from the confusion between some technical definition of "value" and a a more colloquial definition.
The easiest way to interpret that is: "what's good for you is good for Anthropic, so trust Anthropic," but that's almost never what's going on when you're dealing with a sophisticated business. In all market interactions, "value" is relative and everything is almost always obscured by intense information asymmetries. The business wants to maximize profit for itself, which often entails minimizing the value provided to customers (because more "value" usually costs something) and maximizing the price they pay for it.
All I'm saying is that Anthropic has an incentive to help you get more done with fewer (uncached) tokens. They are also incentivized to charge you more for those tokens once you've become more efficient, which is obviously not in your interest. But purposefully setting cache lifetimes to a value they knew would screw people over would be insane.
It would be equally stupid for Anthropic to, for example, make the Claude Code harness waste tokens needlessly, as some people seem to believe they do. That doesn't make any sense, because people are paying for how much use they can get out of Claude.
Users don't have such a precise metric that would allow them to discriminate value per token reliably. Or have you never seen those comparison sites, with dozens of different scales?
If they can make you reload your cache statistically more often without you noticing (increasing their profits), their business model mandates them doing so.
Subscription plans best align the user’s interest with the company’s interest. Presumably, the user’s goal is not token burn but some underlying task. The cheaper the company can accomplish that task, the more money the company keeps. If the user has to constantly retry because the model is bad, that’s more cost to the provider. If the model is big and slow and wastes tokens, that’s more cost to the provider. The more tasks that can be accomplished in the fixed quota, the better value perception by the user.
It's a useful metric, especially for those who know what it means.
Alice asks Claude to build a brand new operating system with an original C compiler and web browser.
Are Alice and Bob both billed for one completed task?
No, obviously not—you'd have to somehow bill by the amount of effort each task takes. Now you need a way to measure "effort".
Okay, now we need a way to measure effort. Hmm, how about, measuring by the amount of tokens the task consumes? Oh, wait... :)
It's rather an equilibrium based on what they can get away with.
It's safe to say, that equilibrium is a safe distance from what's in the users interest.
Modern business seems to be forgetting this lesson, and Anthropic may not be "smart" by this definition, but it would be completely rational for them to look for ways to cut their customers' costs.
For any provider of proprietary inference, the targeted optimization of how (long) their models work according to their own goals is a central part of their business.
People believe those optimizations being about giving them the "best" inference. They fail to notice whose "best".
I’m also not running a multi billion or trillion dollar company, and probably never will if I keep doing it.
I’m okay with that.
deepseek-v4.1-flash per token kv is IIRC 600-700 bytes. this is much, much less than other models. and 500x less than deepseek v3.
So if you're not paying API rates, you need not worry. You can force the main conversation or subagents to either 5 minute or 1 hour in the Claude settings file if you would like.
If you are paying API rates, paying close attention to caching is important. 1 hour is best for sessions where you have to think a lot, examine output, or wait for long builds because 5 minute interruptions are very common. The price premium for 1-hour TTL isn't that high over 5-minute, so I use it by default.
It's also good to get in the habit of doing /compact when you know you might be AFK for more than the cache TTL. Doing the /compact on a long context conversation after the cache has expired is much more expensive.
No idea when they added that, Its gray text that looks exactly like the auto summary line, so easy to miss (as it only shows up when you're idle for 55 minutes or so, and have a session that's compact worthy - again no idea what threshold they use)
https://code.claude.com/docs/en/model-config#context-window-...
https://code.claude.com/docs/en/settings-reference#idlecompa...
Ah, this explains so much, I need to adjust my settings. Lately I've been using bigger models to drive smaller models to do changes, sometimes they run for 45 minutes or more, so I definitely need to tweak my subagent cache time window. I'm not on API billing, but still.
Not until they finish, but the cache duration for main session defaults to an hour. So as long as the subagent doesn't take over an hour, it doesn't matter.
What helped me a lot was to add a rule to "inside subagents, bound each blocking call at ≤4.5 min". A lot of times it would have a `timeout 600 run command`, and then every time that timed out it would be a cache miss. Making it aware of the 5 minute limit helped. You can also ask it "analyze the previous week of Claude sessions and look for ways to improve <x>".
https://skids.dev/blog/anthropic-cache-tokenomics/
They are nice like that
What is a keep-alive ping for prompt caching? - You send the last request again with max_tokens set to 0 about every 4.5 minutes. The API reads the cached prefix, returns no output tokens and restarts the cache timer. In our replay, keep-alive pings capped by session depth cut a Claude coding bill by about 8 to 9% net.
lol if this works there is no way they are gonna let you keep getting away with it
I've been thinking it might make sense to make a mod that uses a super cheap decision model (Jev or similar) to evaluate (maybe based on time of day, whether the last message was a question, etc.) to decide whether to warm the cache.
How to defeat these countermeasures used to be covered in os courses. I suspect the llm vendors will adopt similar techniques.
https://algomaster.io/learn/operating-systems/multilevel-que...
Best ensure your subagents avoid getting blocked if there's any wait or command that takes more than 5 minute.
Ask your agent to look at its own usage metrics to see if you would have saved money by doing so. If your test suite is >5 mins then you likely will.
Eg Opus 5.5 is $4/m input vs $0.2/m cache hit
API is all 5m but apparently keeping it warm every 4.5 mins on API is fine.
This is what i heard.
https://x.com/thsottiaux/status/2112712984644784534
> You can now cache for 12h in the API and for logged in users across Codex & Work we keep cache forever and you don’t have any penalty for coming back to an old conversation or resuming after a few hours and are now guaranteed to hit the cache.
However, a month later:
> First request after a long turn reports a near-full cache miss for logged-in users
https://github.com/openai/codex/issues/61757
(Which is funny, because you pay a premium on many providers for the worse attention!)
The last study I found was from a little while ago though, and there's been a lot of development in attention mechanisms since then. So it might be less bad now.
Bet bet is to measure it yourself by observing billing/credit usage or time-to-first-token.
Claude Code is here: https://code.claude.com/docs/en/prompt-caching
If you're using OpenRouter they publish cache hit rates, which can be used as a sort of proxy, e.g.: https://openrouter.ai/deepseek/deepseek-v4.1-flash-1017#pric...
Generally, by Googling "(provider) llm cache cost and duration" - can't recommend any source that collects them all.
Generally OpenAI and Anthropic are very serious about this and document it well.
Google is currently a shit show but getting better if you're on Interactions API.
The not-$1T crowd, i.e. other inference providers, can't and won't really guarantee anything.
OpenRouter shows data on their cache hit rates.
On not-$1T-crowd APIs, they'll want to set an arbitrary hint that they'll use for server affinity. (i.e. Fireworks needs to know this request wants to run on the same server/cluster/whatever as the last request so it can get a cache hit)
I think they’d rather have you pay for the 60 minute vs the 5 minute cache than upload / download the huge KV cache at every request (and huge really is huge, dozens if not hundreds of GB).
It uses a ridgeline chart to show how big each chat's context has grown and what it's spending.
It's self-labelled as a 15m read and a human in the loop should recognize it's about 3m, tops. Here:
LLM API context caches, by default, only last for 5 minutes on Anthropic and 30m on OpenAI.
If you use Claude, there's an hour cache for 2x the cost of the 5 minute one.
If you use OpenAI, there's a 12 hour cache for 2.5x the cost of the 30m one.
FWIW, it's very Chicken Little / "the sky is falling!!111!": the idea is if you walked away for > 5m between every Claude request, re-caching would be 23% of your bill.
I did indeed run into this problem when I was steering 4 or 5 chats that would ask for feedback that took a few minutes to provide. Pretty soon you're juggling a bunch of 5 min timers if you don't want every single response to have to rebuild the cache.
I could tell that this was AI-written just from the turn of phrase in the title before I even clicked :\
On subscription (so 1h cache) I run into this being even higher, reaching 50%, before I noticed problem.
We could probably reduce cache TTL under a minute if we can get our agent loops and token rates fast enough.
Speed is the answer to everything, including more intelligent models.
10-100x cheaper is not something to sneeze at
Are they offering Opus 5.5 quality and quantity of 20$ Claude subscription at and 2$/month? Or 0.2$/month?
And start a new blank session with its own branch (and have the agent update the project readme) so you can restart without context.
It's a bit overkill for most users but depending on what you're asking it to work on it could theoretically traverse your local network to compromise devices/computers and escape the sandbox.
This is not something that happens, or that is worth spending time or energy thinking about.
Come on, it's literally the first or second sentence. It was never released, and it was pre-RL. Base models are wild, always have been, this is common knowledge. The models people are using are not this wild.
Such internal model can tell you how to make a bomb no problem, but try doing that with an actually released, fully cooked one.
Now, of course that agents can lose sight and do weird stuff, RL or not, but IMO it absolutely does hold that spending time on sandboxing their network is a micro-optimization, unless you're doing something that you know does actually trigger that tendency.
Anecdotally, I've been running agents with full permission (YOLO / dangerously skip permissions / whatever harness specific thing) for over two years, with not a single issue. They also have sudo and configure my server's app deployment, firewall rules, and everything else. Again, not once have they deleted anything I didn't want to, do anything significant I didn't want to, hack anything...
Alignment is absolutely a hard problem, but the released models, from openai and anthropic at least, are well behaved and tame.
Edit: Not likely to happen currently but having this infra makes it easier to demonstrate compliance with your orgs rules.
Unless you think it has some secret stash of 0days, in which case you should monitor its traffic and sell the RCE for a million bucks.
The problem I found was that in a multi-harness, multi-agent setup, the other workstreams may take over and then it comes back to a CC agent. Now it's no longer in cache and gets the hit of 800k token close to the limit (example). Burns tokens very, very quickly.
NOTE: you have to `/autocompact 300000` for every model; the setting is model-by-model.
[0] https://chrlschn.dev/blog/2026/10/larping-with-agents-and-wh...
1. This looks like API-billed traffic only. Claude Code defaults to a 1 hour cache, not 5 min! So if you're within your plan's usage, this doesn't really apply [1].
2. In the API, we have 5 min and 1 hour TTL options. The "23%" here for the 5 min option includes breaks over 30 min, where both Claude's and GPT's default caches have expired and the loss is the ~same (7.8% vs. 8.5%). If you run long sessions with breaks, and are using an API key, you could set "ttl": "1h". There will be a bit higher write price, though [2].
[1] https://code.claude.com/docs/en/prompt-caching
[2] https://platform.claude.com/docs/en/build-with-claude/prompt...
I measured not just anthropic and openai but also google and deepseek. The cache logic these providers have makes sense for chat but doesn't make sense for agentic workflows. My guess is they have already optimized this on their end or are working on it.
the length of time that a given AI/LLM provider caches prompts for...
(apparently 5 minutes in the case of Claude, 30 minutes in the case of ChatGPT (other vendors will have different numbers) -- if the claims of the article are accurate, as of the article's publication date -- and remember, those numbers even if accurate could be subject to change in the future...),
...does make a very real, important difference in AI/LLM economics!
That is, it's another variable in AI/LLM pricing/costing that must be accounted for!
And, I never saw it, nor thought about it, prior to reading this article...
So, an excellent article for getting me to consider it; for getting me to think about it!
There's even the ability to persist your kv cache to disk, so future session resumptions load back into context instantly without needing to do a full prefill ingestion by the LLM. (CachyLLaMA, iirc, not sure where the project is now)
But now, with Bonsai 2.5 27B, this is the first time that I don't need Haiku (or a similar cheap model) for tasks in their scope. I think local models are close to an inflection point in usefulness.
Note: I don't have anything local remotely close to reasoning capabilities of SOTA models such as Opus/Neon/Astra.
TDLR prompts are cached. Prompt cache hit == $. Cache miss == $$$$$$$. Claude ttl is 5 min. Codex ttl is 30 min. If u take longer than 5 min between turns then $$$$
On API it's up to 24 hours.
for +i; send prompt=prompt+"."
I would rather pay for bandwidth than tokens anyway.