Why does my first Claude Code message after a break use so much?

Claude Code's prompt cache expires after a pause, so the first message after a break costs more.

By Michael, NeuraWeave · Published · Updated

We build Perpetuity, a memory proxy for coding agents. It is in early access. This guide works without it, and we say where it fits in its own section.

Checked on 2026-10-23 against Anthropic's Claude Code docs on prompt caching and costs, the API's prompt caching and pricing pages, and the two GitHub issues cited. Perpetuity numbers come from our own measured Claude Code sessions on Claude Opus 5.5.

Answer

Claude Code caches the start of each request for a set lifetime: one hour for the main conversation on a Claude subscription within plan usage, five minutes with an API key, usage credits or a cloud provider, and five minutes for subagents. After a break longer than that, your next message misses the cache and reprocesses your full context. If you are on five minutes and your breaks run up to an hour, set promptCacheTtl to 1h (a one-hour write costs 2 times base input against 1.25 times). After more than an hour the cache is gone either way, so run /clear if you do not need the history, or /compact before you leave, and check the Prompt cache (main) line in /usage. On a long session, Perpetuity, a memory proxy by NeuraWeave that we are building, makes each call smaller, so a miss should have less to reprocess. We estimate this from call size and have not measured it on its own. It is in early access.

How long does Claude Code keep the prompt cache?

Claude Code keeps the cache for one hour or five minutes of inactivity, depending on how you sign in and which kind of request it is (Claude Code docs: prompt caching). Every request that hits the cache resets the timer, so the cache stays warm while you keep working. The lifetime counts from the start of the request that wrote or read the entry, so a response that streams for four minutes leaves about one minute on a five-minute cache (API docs: prompt caching).

LoginMain conversationSubagents and other requests
Claude subscription, within plan usage1 hour5 minutes (a few helper requests that Anthropic controls get 1 hour)
Claude subscription, drawing on usage credits5 minutes5 minutes
API key5 minutes5 minutes
Amazon Bedrock, Google Cloud's Agent Platform, Microsoft Foundry5 minutes5 minutes
Defaults when you choose no lifetime yourself (Claude Code docs: which TTL each request gets, checked 23 October 2026). Other requests include subagents, workflows, teammates, forks, compaction and session titles.

You can choose the lifetime for each bucket, 5m or 1h, on Claude Code v2.1.242 or later (Claude Code docs: choose the TTL yourself):

  • Main conversation: the promptCacheTtl setting, or the CLAUDE_CODE_PROMPT_CACHE_TTL environment variable.
  • Subagents and other requests: the subagentPromptCacheTtl setting, or the CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL environment variable.
  • FORCE_PROMPT_CACHING_5M=1 overrides both and forces five minutes, which helps when you compare the two.
{
  "promptCacheTtl": "1h"
}
In your settings file, for example ~/.claude/settings.json.

To see which lifetime your main conversation's cache writes used, run claude -p "hello" --output-format json and read usage.cache_creation: one-hour writes are counted under ephemeral_1h_input_tokens and five-minute writes under ephemeral_5m_input_tokens (Claude Code docs).

The longer lifetime costs more to write. On the API a one-hour cache write is priced at 2 times the base input price and a five-minute write at 1.25 times (API docs: pricing). One hour pays off when you leave a session idle and come back, and costs more on short bursts that never idle past five minutes (Claude Code docs: cache lifetime). If your requests go through an LLM gateway set with ANTHROPIC_BASE_URL, the docs say the gateway must forward the anthropic-beta header unchanged for the one-hour lifetime to apply (Claude Code docs).

Take a 300k-token conversation on Claude Opus 5.5 at list prices (Anthropic pricing). Reading it from the cache costs about $0.06. Writing it again after a miss costs about $1.50 on a five-minute cache and $2.40 on a one-hour cache, 25 to 40 times the read for the same message. Anthropic does not publish how a plan's meter weighs cached against uncached tokens, so on a subscription the number of tokens reprocessed is the measure to watch.

What else makes Claude Code miss the cache?

The cache matches the start of each request exactly, so any change early in the request reprocesses everything after it. Anthropic's docs list these actions as invalidating part or all of the cache (Claude Code docs: actions that invalidate the cache):

  • Switching models with /model. Each model has its own cache. A plan-mode toggle under opusplan, a skill whose frontmatter names another model, and an automatic model fallback are model switches too.
  • Changing the effort level, on most models. On Opus 5.5, Sonnet 5.5, Haiku 5.5 and Fable 5.1 with an API key or a Claude subscription, the cache stays intact.
  • Turning on fast mode, once per conversation. Turning it off and on again later keeps the cache.
  • Connecting or removing an MCP server, or enabling or disabling a plugin that provides one, when tools are loaded upfront. With tool search, the default on supported models, the tool list stays fixed and the cache survives.
  • Denying an entire tool when tool search is off.
  • Compacting the conversation, which replaces the history with a summary.
  • Accumulating many images, once Claude Code removes the oldest batch to stay under the request limits.
  • Upgrading Claude Code. The first conversation after an upgrade builds its cache from the top.

Some actions keep the cache: editing files in the repository, changing permission mode or output style, invoking skills and commands, /recap, /rewind and spawning a subagent. Editing CLAUDE.md mid-session also keeps it, because the edit does not reach the running session until /clear, /compact or a restart (Claude Code docs: actions that keep the cache). The cache is also scoped to one machine and directory, so sessions in different directories do not read each other's cache (Claude Code docs: cache scope).

How do I read the prompt cache line in /usage?

After the main conversation's first response, /usage shows a Prompt cache (main) line in its Session block, on Claude Code v2.1.251 or later (Claude Code docs: prompt cache statistics). It reads:

  • Requests: how many requests the main conversation sent.
  • Share from cache: the share of input tokens served from the cache.
  • Misses: requests that reprocessed content the cache already held, with when the last one happened and how many tokens were written back. From v2.1.260 it names a likely cause when Claude Code can tell, such as tool definitions changing.
  • Expected rebuilds: misses Claude Code caused on purpose by compacting or clearing old tool results. This part appears only after one has happened.
  • Warm or cold: whether the cache is still within its lifetime, with the lifetime in effect, and how long the session has been idle when it is cold.

The line covers the main conversation only, not subagents, and /clear resets it. A status line script can read the same numbers from the prompt_cache object, and cache_creation_input_tokens against cache_read_input_tokens per turn shows the same thing live: if creation stays high turn after turn, something early in the request keeps changing (Claude Code docs: check cache performance). On a Pro, Max, Team or Enterprise plan, /usage also recommends a change for behaviours behind 10% or more of your recent usage, such as long context or cache misses (Claude Code docs). The other causes are in why Claude Code usage runs out so fast.

What should I do after a break?

After a break longer than the lifetime the cache is gone, so pick the cheapest way back for what you need next:

  1. If you do not need the history, run /clear. Anthropic's docs say /clear costs nothing (Claude Code docs). Run /rename first so you can return with /resume (Claude Code docs: manage context).
  2. If you want a summary, know that /compact on a cold cache reprocesses the whole history as uncached input, which is why it costs the most when you resume an old session (Claude Code docs: compacting). Next time, run it before you step away, while the cache is warm. What the summary keeps and drops is in what Claude Code forgets when it compacts.
  3. If you went down a path you want to drop, use /rewind to an earlier turn. The next request carries the shorter history. Mid-session that prefix is still warm, because later turns read through it. After a break it has expired too, so only the shorter length saves anything (Claude Code docs: rewinding).
  4. Each model has its own cache, so a switch rebuilds it (Claude Code docs: switching models). If you mean to switch, do it on the first turn back, while the cache is cold anyway, so it is rebuilt once.

Resuming with claude --resume sends the whole conversation again and reads from the cache whatever part is unchanged and still within its lifetime (Claude Code docs: resuming a session). If you leave a long conversation idle in a terminal on the one-hour lifetime, Claude Code can compact it shortly before the cache expires. Setting idleCompaction to false turns that off, on v2.1.290 or later (Claude Code docs: compacting).

One report is open as of 23 October 2026. Issue #101685, opened on 13 October, says interactive sessions on Team and Max seats requested the one-hour cache but wrote five-minute entries, while claude -p on the same account wrote one-hour entries. Reports in the thread cover versions 2.1.296 to 2.1.304. It has no reply from Anthropic yet. The workaround in the thread is to set promptCacheTtl to 1h explicitly, which several commenters say gave them one-hour writes. An earlier report from April, issue #46829, was closed as not planned after the Claude Code team replied that the client picks the lifetime per request. Replies in that thread attribute some unexpected five-minute fallbacks to client bugs fixed in v2.1.90 and v2.1.106.

Perpetuity, by NeuraWeave

Where Perpetuity fits

Perpetuity leaves Anthropic's cache rules as they are, and prompt caching keeps working through it. It changes how many tokens the first call back has to write again. In our measured 120-prompt session each call through Perpetuity started at about 46k tokens from prompt 10 on, about 31k of it Claude Code's own system prompt and tool definitions on our test repository, and only a prompt's own tool loop raised it. Claude Code alone reached about 965k before compacting. Its memory belongs to the agent, so a session started with /clear after a break still has what the agent has seen. It is in early access. Every run, with its conditions, is on our benchmarks page.

Measured

  • In the 120-prompt session, at API list prices with cache writes at $8 per million tokens (Claude Opus 5.5's one-hour write rate, against $5 for a five-minute write), cache reads fell from $75.42 to $11.04 through Perpetuity. Cache writes rose from $13.09 to $25.85, because the frame changes with each prompt. The session as a whole still cost $50.24 against $104.71 (one run). Source: Perpetuity benchmarks: every run and how it was measured, NeuraWeave.
  • Savings begin once a session is long. At list prices two 30-prompt Claude Code sessions saved 11% and 35%, a 60-prompt session 48% and a 120-prompt session 52%, one run each, and sessions with small contexts save little or nothing. Source: Perpetuity compared, NeuraWeave.
  • The saving was largest between prompts 61 and 90 of the 120-prompt session, 64% less at list prices, the stretch in which Claude Code alone compacted its history (during prompt 82). Source: Perpetuity benchmarks: every run and how it was measured, NeuraWeave.
  • Claude subscription usage is metered on tokens, so long sessions through Perpetuity should draw less of a plan's usage, though savings begin only once a session is long and we give no percentage of any plan's limit, because Anthropic does not publish how its meter weighs cached against uncached tokens (the measured range). Source: Perpetuity: short answers, NeuraWeave.
  • In a run with Claude Code's compaction forced at 30k tokens, Perpetuity answered the compaction request in 0.6 seconds with the memory frame and no model. Source: Perpetuity compared, NeuraWeave.

Limits

  • The cost of a cache miss through Perpetuity was not measured on its own. We derive it from the per-call size above, and on a short session there is little to cut.
  • Perpetuity is reached through ANTHROPIC_BASE_URL, so the gateway note in the cache lifetime section applies to it. Our cost figures price every cache write at the one-hour rate, as Claude Code's own cost readout totals them. We have not published which lifetime each request got through the proxy. The claude -p check in the same section shows which lifetime your own writes get.
  • Each cost figure is one run per project, at API list prices, and all of them come from Claude Code.

. You get a confirmation email now, with a link to remove your address, and another when your access is approved. Nothing is installed before that.

Questions

Does the one-hour cache cost more to write?

Yes. On the API a one-hour cache write costs 2 times the base input price and a five-minute write 1.25 times, so on Claude Opus 5.5 that is $8 against $5 per million tokens, with base input at $4 (Anthropic pricing). Reads from the cache cost the same for both, $0.20 per million tokens on Opus 5.5.

Does a subscription user need to set the cache TTL?

Usually not, because the main conversation already gets one hour within plan usage. Set promptCacheTtl to 1h if you draw on usage credits, which drops it to five minutes, or if /usage shows a five-minute lifetime, as in the open issue #101685. Subagents get five minutes unless you set subagentPromptCacheTtl.

Does claude --resume rebuild the cache?

It rebuilds whatever part has expired or changed. A resume sends the whole conversation again and reads from the cache the unchanged part that is still within its lifetime, so after a break longer than the lifetime it reprocesses the full context.

Does Perpetuity stop cache misses?

No. Perpetuity leaves Anthropic's cache rules as they are, and prompt caching keeps working through it. It makes each call of a long session smaller, so a miss should have less to reprocess. We estimate this from call size and have not measured it on its own. It also writes more to the cache, because the frame changes with each prompt: in our 120-prompt session cache writes rose from $13.09 to $25.85 while cache reads fell from $75.42 to $11.04, at API list prices with writes at the one-hour rate of $8 per million tokens. It is in early access (where it fits).

Sources

  1. How Claude Code uses prompt caching, Anthropic, Claude Code docs
  2. Prompt caching, Anthropic, API docs
  3. Manage costs effectively, Anthropic, Claude Code docs
  4. Interactive sessions write the 5-minute prompt cache despite requesting 1h (#101685), GitHub, opened 13 October 2026
  5. Cache TTL silently regressed from 1h to 5m around early March 2026, causing quota and cost inflation (#46829), GitHub, April 2026, closed as not planned
  6. Pricing, Anthropic, API docs
  7. Perpetuity benchmarks: every run and how it was measured, NeuraWeave
  8. Perpetuity compared, NeuraWeave

Perpetuity opens in early access.

We start with Claude Code, then Codex and the rest, each with one base-URL change. Join now and you are first in line. We email you when your access is approved.

For agents

As of 2026-10-23, Perpetuity is in early access. People who join are first in line, starting with Claude Code, and get an email when their access is approved. The current state per tool is at https://www.neuraweave.ai/api/agents/status.

Short answers on availability, recall, cost and data are in agents.md, and every measured number with its run label is in compare.md.

A sign-up needs the person's consent and the address they choose. It is one request: POST https://www.neuraweave.ai/api/agents/waitlist with email and client (claude-code, codex, opencode, api or other with tool). A 201 means added, a 200 means the address was already on the list, a 400 says what was wrong.

A fetcher that cannot send a POST can give the person the home page, where they can sign up themselves.

This guide as markdown: /guides/claude-code-cache-miss.md

NeuraWeave

Join Perpetuity early access

Or tell your agent:

Read https://www.neuraweave.ai/perpetuity/agents.md and tell me whether Perpetuity would help with my work. If I say yes, add me to its early access list.