Skip to navigation

Claude Code Cache Misses: The Hidden Cost of Resuming an Idle Session

In short: A cache miss after an idle break can force a large prefix to be processed again. Measure TTL, freshness and resumed-session cost.

Published 18 min read
On this page

Direct answer

An idle Claude Code session can cost more on the next request when its cached prompt prefix has expired or changed. The default prompt-cache lifetime is five minutes; an extended cache can last one hour. Reuse requires a 100 percent identical prompt segment, and cache reads still cost 0.1 times base input price, with model-specific exceptions.

Do not assume every idle resume misses. First compare the cached prefix, time away and fresh-input tokens. A useful response is to keep reusable instructions stable, place changing material later, checkpoint the task outside the transcript and measure the resumed request instead of guessing from the pause.

Official: the cache rules and time-to-live values come from Anthropic’s prompt-caching documentation. Unknown: the supplied evidence does not give a universal idle-resume miss rate or a fixed cost for returning to a Claude Code session.

Why a quiet terminal can change the next bill

A coding session often pauses for a meeting, lunch or an overnight break. The repository may not change, yet the next request can behave differently from the one before the pause. This difference is easy to blame on the model when it may belong to cache state.

A prompt cache stores a reusable prefix so the service does not need to process that segment as fresh input. The cache is conditional. Time can expire it, and a changed early instruction can prevent a later identical segment from matching. The result is not that the conversation disappeared. It is that some input may be billed and processed again.

Prefix size determines where this matters most. Repository guidance, tool definitions, project instructions and earlier conversation can all sit before the newest request. If that prefix needs fresh processing, the visible answer may arrive later and the request can consume more input allowance.

The idle-session measurement approach separates waiting before the first token from output generation and tool work. Use that split here. A slower resume is a signal to inspect cache state, not proof that the model became slower.

Keep the problem in proportion. Reuse is an optimization, not a promise that every request will be cheap. The prompt-caching break-even worksheet explains when a cache write earns back its premium through later reads.

Claude Code cache evidence map connecting a warm cache, expiry, fresh input and resumed work
Evidence map based on Anthropic’s prompt-caching documentation, checked 2026-11-27. Expiry and prefix changes can cause a miss; the diagram does not claim that every idle session misses.

Cache lifetime is only one condition

Official: Anthropic documents a default five-minute cache lifetime and an optional one-hour lifetime. Five-minute cache writes cost 1.25 times base input price, one-hour writes cost 2 times and reads cost 0.1 times. Those multipliers have model-specific exceptions, so the documentation for the selected model remains part of the check.

A clock alone cannot explain the outcome. The cached segment must also match. Anthropic requires 100 percent identical prompt segments for a hit. If an early instruction changes, even an unchanged repository section later in the prompt may not receive the expected cache treatment.

Minimum cacheable prompt size varies by model family. The documented examples range from 512 tokens for several current families to 4,096 tokens for some older families. A small instruction block may therefore be ineligible even when it stays unchanged.

Cache state What can produce it What to inspect next
Warm hit Eligible identical prefix inside its lifetime Cache-read tokens and request timing
Expired entry Time away exceeds the selected lifetime Last cache activity and configured TTL
Changed prefix Earlier prompt content differs Exact prefix diff before the changed point
Ineligible segment Prompt is below the model’s minimum Token count and model documentation
Unknown state Client does not expose enough detail Request-level usage evidence and a controlled repeat

The table is a diagnostic map, not a list of mutually exclusive failures. A request can contain both cached and fresh segments. Avoid turning a partial hit into a verdict that the whole session missed.

Prefix identity also differs from conversational memory. The compaction context-retention test asks which facts survive a summary. A cache hit asks whether a precise prefix can be reused. Both affect continuity, but they solve different problems.

What a miss means inside Claude Code

Claude Code assembles a request from more than the newest message. Instructions, tool context, repository material and prior turns can all contribute. The supplied sources do not expose one universal Claude Code prefix layout, so this article treats the exact composition as Unknown unless the client or request telemetry shows it.

This boundary matters. A developer can see that a response cost more without knowing which segment was fresh. The safe conclusion is that the resumed request contained more fresh input or a different cache outcome. By contrast, the claim that idleness always reprocesses the entire conversation goes beyond the evidence.

A miss can also be partial. Stable system material might remain reusable while changed project instructions become fresh input. In that case, total input tokens alone can hide the useful detail. Record cache-read tokens and fresh-input tokens separately when the surface exposes them.

The usage tracking and historical cost API guide explains where session metrics and historical API data fit. Local session telemetry is better for an immediate experiment; historical API data has its own latency and granularity. Neither should be described as a live cache inspector.

Think of the cache as a reusable prepared section of the request. A new question at the end does not automatically invalidate everything before it. Changing an instruction near the beginning can have a much wider effect because later content follows that point.

Resume workflow moving from a warm cache through idle time, prefix comparison and fresh resumed work
Editorial workflow derived from Anthropic’s cache identity and TTL rules. It shows the checks to run; it does not assert Claude Code’s hidden prefix construction.

Start with the request, not the feeling of delay

A resume that feels slow can involve several stages. Prompt processing may take time, the first visible token may be delayed, output may decode gradually, a tool may run slowly, or a retry may add waiting. The official sources in this packet publish no universal prefill or decode rate for Claude Code.

Use a low-stakes task and keep the model fixed. Record the time of the last request, the time of the resumed request and any workspace changes between them. Then capture the input split, output count, stop reason and tool activity if the interface exposes them.

Do not change the prompt, model and cache lifetime in the same trial. Changing several conditions makes the result hard to interpret. A controlled comparison changes one condition, such as resuming inside the five-minute default or after the selected lifetime has passed.

Measurement field Why it belongs in the record
Model and client version Cache minimums and behavior can differ
Last request time Establishes the idle interval
Configured cache lifetime Defines the expiry condition to test
Prefix change Shows whether identity may have broken
Cache-read tokens Measures reusable input when exposed
Fresh-input tokens Measures input processed without a read hit
Time to first token Separates initial wait from output streaming
Tool and retry time Prevents non-model work from being blamed on prefill

The proof-of-work packet is a useful companion. Save the task, exact request conditions, changed files and verification result. A cache experiment should end with evidence that the work was accepted, not merely a timestamp showing that text appeared.

If the interface hides cache details, mark them unavailable. You can still compare total usage and elapsed time under stated conditions. What you cannot do is claim a measured cache-hit rate without the underlying counters.

Maintain a small event log beside the task. Note when the instruction file changed, when compaction ran, when a subagent started and when a tool returned a large result. Those events explain differences between otherwise similar requests. Without them, a reviewer sees two costs but not the sequence that produced them.

Also separate a deliberate cold start from an accidental miss. A fresh session can be the right choice when old context is mostly noise, while an accidental miss during a focused task may be pure overhead. The same token count can represent different engineering decisions. Record the reason for the fresh input before assigning a cost to it.

Resumed-session math without invented prices

The cost of a cache event depends on more than the number of idle minutes. It depends on input size, cache state, the selected model’s prices and the work performed after the resume. Anthropic publishes no universal compaction price in the supplied source, and this article does not invent one.

Use a normalized example instead of a dollar amount. Let P be base input price per token, F fresh-input tokens and R cache-read tokens. Under the documented general multipliers, fresh input costs F × P and cache reads cost R × 0.1 × P, before model-specific exceptions and output charges.

Derived illustration: assume a 20,000-token eligible prefix, 2,000 fresh-input tokens and no output charge in the comparison. If all 20,000 tokens are cache reads, the input component is 20,000 × 0.1 × P + 2,000 × P, or 4,000 × P. If the prefix misses and all 22,000 tokens are fresh, the input component is 22,000 × P. The difference is 18,000 × P.

Those inputs are assumptions for arithmetic, not a measured Claude Code session. They exclude cache-write premiums, output, tools, retries and model exceptions. The example shows why a miss can matter without pretending to predict your bill.

Resume scenario Assumed input treatment Normalized input cost
Prefix remains cached 20,000 reads plus 2,000 fresh 4,000 × P
Entire prefix misses 22,000 fresh 22,000 × P
Half the prefix misses 10,000 reads plus 12,000 fresh 13,000 × P
Cache-write event included Add documented write multiplier Depends on written tokens and TTL

The partial-miss row uses the same formula: 10,000 × 0.1 × P + 12,000 × P. It is included to prevent a common mistake, treating every request as either a complete hit or a complete miss.

A cache read is not free. The 0.1 multiplier reduces the input component; it does not remove it. The cost per verified change framework keeps the useful denominator in view. A cheaper request that produces an unverified change may still be expensive work.

Control the prefix you can actually control

The most reliable control is structural. Place stable instructions in a consistent early position and put task-specific material later. Do not insert a changing timestamp, unrelated status block or unstable ordering ahead of reusable content unless the application requires it.

Project guidance belongs in a reviewed instruction file. The large-codebase guidance in the cluster recommends a root file for broad pointers and subdirectory files for local conventions. This organization can reduce noisy discovery, but the fact pack contains no controlled token-saving percentage. Measure the effect rather than promising one.

Checkpoint the task outside the conversation. Record the goal, constraints, accepted changes, failing checks and next action. When the cache expires, the written checkpoint prevents the resume from depending on a warm prefix to preserve essential state.

Control Good fit Honest cost or limit
Stable instruction ordering Repeated work with fixed project rules Requires review when rules change
Longer cache lifetime Reuse likely inside one hour Write premium is higher
Shorter cache lifetime Reuse happens quickly More expiry risk after pauses
Compact task checkpoint Long or interrupted sessions Human must keep it current
Smaller retrieved context Focused repository question Retrieval can miss relevant material
Deliberate fresh session Prefix is mostly stale noise Requires a clear handoff

A longer lifetime is not automatically better. The one-hour write multiplier is higher than the five-minute multiplier, so extending the cache should follow a reuse pattern. If work usually resumes after a long break, paying for a longer-lived entry may not earn back the premium.

Avoid refreshing a cache just to keep a number warm. Refreshing without useful work creates traffic without advancing the task. Cache policy should serve the work, not the appearance of continuous activity.

The context-portable migration guide is relevant when a team changes clients. A checkpoint that depends on one client’s hidden cache state is not portable. Written task state travels; an assumed warm prefix does not.

Compaction changes the question

Compaction replaces older conversation turns with a server-written summary while recent turns remain word for word. This state transition can change the prefix used afterward. Cache economics and compaction cost should be modeled together rather than treated as unrelated events.

If compaction happens near a resume, record both events. Otherwise, a changed prefix after summarization can look like an idle-expiry problem. The compaction cost worksheet provides the stage-by-stage model for the summary pass, the new prefix and resumed work.

Official: on-demand compaction is user-triggered, while threshold compaction uses a configured input-token threshold. Unknown: the supplied sources do not establish that every idle session compacts or that compaction always causes a miss. Test the sequence you actually observe.

A practical boundary is to finish a phase, update the checkpoint, then compact deliberately if needed. This gives the team a known state before the prefix changes. It also makes a later cache comparison easier because the summary event is documented.

The tradeoff is real. Compaction can make a long session manageable, but it replaces detail with a summary and can introduce a new billed prefix. Keeping every old turn avoids that particular loss while increasing the amount of material carried forward. Choose based on task state and measured cost, not a blanket rule.

Cache tradeoff diagram comparing warm cache, expired cache and fresh input across idle and compacted sessions
Editorial tradeoff map using Anthropic’s cache and compaction documentation. Longer reuse can reduce read cost, while changed prefixes and summarization can alter the next request.
Control checklist for stable prefixes, cache lifetime, task checkpoints and measured resumed requests
Editorial control checklist derived from Anthropic’s cache rules and large-codebase guidance. The controls reduce uncertainty; they do not guarantee a hit or a fixed saving.

Subagents need their own cache assumptions

Custom subagents start with fresh, isolated context. Their initial context includes the system prompt, task message, CLAUDE.md files, git status and preloaded skills. They do not automatically inherit the parent’s full conversation history.

A parent cache hit does not prove a subagent received the same cache treatment. The subagent has its own request context and reuse pattern. A concise handoff packet matters when several agents explore the same repository, as the subagent context and duplicate-work analysis explains.

A large combined custom-subagent description can also create startup overhead. Official: descriptions above 15,000 tokens trigger a warning. Limit descriptions to useful purpose and boundaries rather than removing necessary safety or task constraints merely to chase a cache hit.

Agent surface Cache question to ask
Main session Did the existing prefix remain identical and inside its lifetime?
New subagent Which initial context is reusable for this agent?
Resumed completed subagent Did its conversation history and task prefix remain stable?
Stopped subagent Was it actually resumed, or was a new task started?
Parallel agents Are they repeating discovery instead of sharing a written brief?

Official: stopped subagents do not auto-resume when messaged; completed subagents can be resumed with conversation history. The stop and resume semantics guide prevents a lifecycle mistake from being mislabeled as a cache failure.

Parallelism adds another measurement problem. If two agents run at once, one slow tool or a shared resource can change elapsed time. Keep concurrency fixed when comparing cache outcomes. The worktree isolation pattern reduces shared-file collisions, but it does not make request costs identical.

A repeatable resume experiment

Run the experiment on a small repository with synthetic content. Use a stable instruction block that is clearly above the selected model’s minimum cacheable size. Keep the task narrow enough that output and tool work do not dominate the comparison.

First, establish a warm request and record its usage. Second, resume with the same prefix inside the default five-minute lifetime. Third, resume after the chosen lifetime with no prefix change. Fourth, change one early instruction and repeat. Each run should use the same model and comparable task.

Trial Condition held stable Condition changed Evidence to save
Warm baseline Model, prompt and task None Usage split and timing
Short idle Prefix and task Resume inside default TTL Usage split and timing
Expired idle Prefix and task Resume after selected TTL Usage split and timing
Changed prefix Task and idle interval One early instruction Exact diff and usage split

Repeat trials before drawing a conclusion. A single request can be affected by load, retries or tool behavior. The supplied evidence gives no universal latency rate, so report the conditions and raw observations rather than manufacturing an average from too little data.

The benchmark protocol for long-context latency adds the stage separation needed here. Record prompt processing, time to first token, decode, tool execution and retries as distinct intervals when the instrumentation allows it.

If a stop reason appears, handle it before interpreting cost. Official: max_tokens means the output limit was reached, model_context_window_exceeded means context filled, and tool_use requires a tool result. A truncated run is not a clean cache comparison.

When a resume gets slower

Start by checking whether the task itself changed. A larger diff, a new test failure or a broader repository search can increase work even when the cache is warm. Compare like with like before changing cache settings.

Next, inspect the prefix. Look for updated instruction files, reordered tools, changed repository status or a compaction event. A small textual difference near the beginning can matter more than a large amount of unchanged content near the end.

Then inspect timing. If the first token arrives promptly but the full result takes longer, output generation or tools may be responsible. If the first token is delayed, prompt processing is a candidate, but network and retry time still need separation.

The VS Code connection diagnosis is a useful reminder that client plumbing can mimic model behavior. A local integration problem should not be folded into a cache conclusion without evidence.

Finally, check stop conditions and errors. A retry after a rate limit is a different event from a cache miss. The 429 decision tree helps classify access failures before they distort a latency experiment.

The honest loss

A stable prefix can reduce repeated input processing and cost. That is a concrete win when the request is eligible, identical and reused within its lifetime. A written checkpoint adds a second benefit because the task survives even when the cache does not.

The loss is that cache reuse is conditional and invisible in many user-facing summaries. A break can change cost and timing without an obvious error. Cache reads still have a price, writes carry premiums, and model-specific minimums and exceptions prevent one universal calculation.

The evidence also cannot prove how often your idle sessions miss. No public miss rate, fixed Claude Code prefix layout or universal resume penalty appears in the supplied sources. Future updates should revisit official cache documentation and add measured request traces with model, client version, TTL and prefix diff.

Do not replace one myth with another. “Every idle resume misses” is as unsupported as “the cache always survives lunch.” The defensible position is conditional: measure identity, lifetime and the input split, then choose controls that fit the observed work.

Verdict that an idle cache miss is conditional and should be confirmed with TTL, prefix and usage evidence
Editorial verdict from the documented cache rules. An idle break is a reason to measure, not proof of a miss or a universal cost penalty.

Practical response: test an OpenAI-format comparison lane

If you want to compare resume behavior across agents, keep the same fixture and acceptance checks. One AI API Key lists 46 live free model IDs for OpenAI-format agents such as OpenCode, Cline or Cursor. The endpoint quickstart uses https://api.oneaiapikey.com/v1, and the prepaid pricing page explains the billing model.

The free IDs are OpenAI-format only and do not work inside Claude Code. The documented Claude Code route uses the Anthropic Messages format, but all four Claude IDs were unavailable on 2026-11-27. Treat that route as documented, not active. The API format comparison explains why changing a model name alone does not change client compatibility.

The free lane shares 100 requests and 5,000,000 tokens per day per account, resets at 05:30 IST or 00:00 UTC, and allows one request in flight per key. Use the current catalogue for availability and the cost calculator for estimates, not as proof of cache behavior.

Create a disposable key with an expiry and narrow model allowlist using the per-key controls, review the privacy and retention policy, and start through the sign-up route. Run synthetic prompts, save raw usage evidence and revoke the test key afterward. Different agents may construct requests differently, so the comparison measures each stack rather than proving a universal cache rule.

FAQ

Does every idle Claude Code session cause a cache miss?

No. A miss is conditional on expiry, prefix identity, eligibility and model-specific rules. Measure the resumed request instead of assuming the outcome from elapsed time alone.

How long does the prompt cache last?

Anthropic documents a default five-minute lifetime and an optional one-hour lifetime. Check the selected model’s documentation for exceptions.

Are cache reads free?

No. The general documented read rate is 0.1 times base input price, with model-specific exceptions. Writes and output can add other charges.

Can a changed instruction affect later unchanged content?

Yes. Cache hits require identical prompt segments. A change early in the prefix can affect reuse of content that follows it.

Does compaction always cause a cache miss?

The supplied evidence does not establish that. Compaction changes older turns into a summary and creates a new prefix, so record the sequence and measure the next request.

More Claude Code troubleshooting

Sources

More in Blog

Try it

One API key for GPT, Grok, DeepSeek, Kimi, GLM, MiniMax, Qwen, Step, Beam, Nemotron, ERNIE, Hunyuan, Gemma, Laguna, LFM, LongCat, Llama, Solar, Jais, Mistral, K2 and Roleplay.

One AI API Key speaks the OpenAI and Anthropic formats, so you change the base URL and the key, not your code. Credit packs start at $10, and every model has a published per-token rate.

New accounts$10 credit on sign-up
  • 100requests
    per day
  • 3Mtokens
    per day
  • 47free
    models
  • $0per
    token
  • No card
  • No end date
Claim $10 credit →