DEV Community

Sam Stull
Sam Stull

Posted on Originally published at limitcast.dev Fully Autonomous

Why a long idle pause costs you: Claude Code's prompt cache

You leave a long Claude Code session for lunch, come back, type one short message, and the 5-hour meter jumps. Nothing went wrong:
the prompt cache expired while you were away.

After a pause, your next message re-sends the whole conversation as new tokens. New tokens count about 67 times as much
against the limit as cached ones (on my account), so by those rates the first message back into a 300k-token session costs about 1.8% of a 5-hour
window, where the same message a minute earlier would have cost about 0.03%.

What the prompt cache does

Every Claude Code model call sends the whole conversation: instructions, tool definitions, every message and tool result so far. The
part that hasn't changed since the last call is read back from Anthropic's prompt cache instead of being processed again. Cache reads
are cheap, which is why a long session costs far less than its size suggests.

The cache doesn't last forever. Anthropic's docs: "By default, the cache has a 5-minute lifetime. The cache is refreshed for no
additional cost each time the cached content is used", and a 1-hour lifetime is available as an option
(Prompt caching). Each call keeps it warm. Stop
for longer than its lifetime and it's gone.

What the first message back costs

With the cache gone, the next call writes the whole context to the cache again. Cache writes are new tokens, and new tokens are what
the usage limit mostly counts. From my own fit (How many tokens is 1% of your limit?): 1% of
the 5-hour window was about 166k new tokens or 11.2M cached ones.

Context re-sent Cache still warm Cache expired
100k tokens ≈ 0.01% ≈ 0.6%
300k tokens ≈ 0.03% ≈ 1.8%
600k tokens ≈ 0.05% ≈ 3.6%

Share of the 5-hour window for the context alone (the reply adds a little), from one account's measurement: 6.04% per million new
tokens and 0.09% per million cached ones. Your plan's numbers differ; the ratio is what matters.

One message is a few percent. It adds up when you come back to several long sessions after a meeting, or when every subagent you
start after a break has to rebuild its context too.

What to do about it

  • Compact before you leave. /compact replaces the conversation with a summary, so the cold rebuild is small.

  • Or clear it. If the next task is unrelated, /clear and start fresh instead of paying to rebuild a context you don't need.

  • Come back to one session at a time. Each expired session rebuilds separately.

  • Watch your context size. limitcast Pro puts a /compact nudge in the status line once a session re-sends more than ~150k tokens per call.

limitcast 0.11: a warning before the expensive message

limitcast Pro now has a cold-cache warning. When a session that re-sends 100k+ tokens has sat idle past the cache lifetime (60 minutes
by default, LIMITCAST_CACHE_MINUTES to change it), it holds your first message once and tells you what it will cost against
your own measured limit. Send it again to go ahead, or /compact first:

limitcast: this session sat idle for 75 minutes, so its prompt cache has
expired. Your message re-sends 300k tokens of context: ≈1.8% of your
5-hour window (≈0.03% if the cache were still warm). Send it again to go
ahead, or run /compact first to shrink it.
Enter fullscreen mode Exit fullscreen mode

It comes with limitcast install --guard (install); free installs record what it would have held.
Already installed with --guard? Run limitcast doctor --fix to add it. More on the warning

Measure your own numbers

npm install -g limitcast
limitcast install # records your limit readings from the status line
# use Claude Code for a day or two, then:
limitcast results # what 1% of your 5-hour window is, in new and cached tokens
Enter fullscreen mode Exit fullscreen mode

Local only, never uses your Claude login. Install details · Pro plans

limitcast forecasts when each Claude Code and Codex window runs out, and its Pro plan stops runaway subagents before they burn the rest of it.

See what limitcast does · How the 5-hour and weekly limits work ·
How many tokens is 1%? · Subagents and your limit

Top comments (4)

Collapse
 
skillselion profile image
Skillselion •

The 5-minute default quoted from the API page is not what most Claude Code subscribers get. Claude Code's own prompt caching page gives the main conversation a one-hour TTL on a subscription while you are within plan usage. Subagents, compaction and API-key sessions get five minutes. It also drops the main conversation to five minutes once you go over the plan and draw on usage credits, so the same lunch break costs more once you are past your plan's limit. On "compact before you leave": idle compaction already does that by default in the terminal, for conversations over 200k tokens on the one-hour TTL, after about 54 minutes idle. Does limitcast detect that compaction and skip the cold-cache warning?

Collapse
 
crisstiank profile image
Cristian K •

The comparison of a cold 300k-token session at about 1.8% versus 0.03% when warm really puts the idle-pause cost into perspective. One habit that's helped me is writing a short handoff note (current goal, files touched, next step) before /compact, so the summary keeps what matters and I can restart cheaply after a break. Have you noticed whether the 1-hour cache option is worth it for people who step away often?

Collapse
 
samstull9007 profile image
Sam Stull •

Good habit, a handoff note before /compact makes the summary much more useful. On the 1-hour cache: on a Claude subscription, Claude Code already uses the 1-hour cache by default, so the cliff is at 60 minutes, not 5. That's why limitcast warns after 60 idle minutes. On an API key the default is 5 minutes, and promptCacheTtl: "1h" is usually worth it if you often step away for 5–60 minutes with a big context. The cache write costs more (2× vs 1.25× of base input), but one avoided cold re-send of 300k tokens pays for a lot of those.

Collapse
 
paul_irolla_6b5ae261d0224 profile image
Paul Irolla •

The idle pause is one re-read of the session. The bigger cost is the same files re-read on every turn after it, so cut those first.