Claude Prompt Cache TTL: Why Agent Pauses Cost You Money

Is the Claude prompt cache TTL raising your agent bill? Learn why pauses over 5 minutes force a full rewrite and when the 1-hour cache pays off.

Sophia Carter

Sophia Carter

4 December 2026

Claude Prompt Cache TTL: Why Agent Pauses Cost You Money

Quick answer: The Claude prompt cache TTL is 5 minutes by default. Each cache hit resets the clock for free, but any pause longer than 5 minutes drops the cache, and the next request pays to write the whole prompt again. You can opt into a 1-hour TTL at twice the base input price per written token, which pays off when your agent’s pauses fall between 5 and 60 minutes.

Coding agents send the same long prefix on every step, caching makes that prefix cheap, and a human who takes 12 minutes to answer a question makes it expensive again.

This guide covers how the Claude prompt cache TTL works, what a pause costs in dollars, when the 1-hour cache earns its price, and how to design agent work so people review between runs instead of in the middle of them. If you run agents through Sharkly, that last part maps onto Task Chats and task review.

What is the Claude prompt cache TTL?

The Claude prompt cache TTL is how long a cached prompt prefix stays available after it was last used. Anthropic’s prompt caching docs set it to 5 minutes by default, refreshed at no cost on every hit. Add "ttl": "1h" to cache_control for a 1-hour lifetime.

Three details from the docs matter for agents:

  1. The clock starts at the request, not the response. The lifetime “is measured from the start of the request that writes or reads the cache entry.” A step that streams for three minutes leaves two.
  2. Order sets what breaks. The prefix runs tools, then system, then messages, and a change at one level invalidates that level and everything after it.
  3. Small switches count. Changing tool_choice, or adding or removing an image anywhere in the prompt, invalidates the cache.

Why agent pauses cost you money

An agent resends its prefix on every step: tool definitions, system prompt, repository context, and the conversation so far. With a warm cache, you pay the read rate on that prefix. With a cold cache, you pay the write rate, which is higher than base input.

Here are the Claude Opus 5.5 rates per million tokens, from the same docs page:

Opus 5.5 rate Price per 1M tokens Multiple of base input
Base input $4.00 1x
5-minute cache write $5.00 1.25x
1-hour cache write $8.00 2x
Cache hit (read) $0.20 0.05x

Take an agent with a 100,000-token prefix. A warm step costs $0.02 in prefix input. A step after a 12-minute pause costs $0.50, because the whole prefix is written again. That’s 25 times more for the same tokens, and the only difference is how long the human took.

Sequence diagram: the agent sends its prefix to the Claude API, which writes the cache; the agent asks a human a question; the human answers 12 minutes later; the agent resends the prefix, the 5-minute cache has expired, and the API writes the full prefix again at 1.25x base input.

Pauses add up fast. A run with ten human checkpoints at 12 minutes each pays roughly $5.50 in prefix writes on the 5-minute cache. The same run on the 1-hour cache pays about $1.00: one $0.80 write, then ten $0.02 reads. These figures count the prefix only; new tokens each step are written either way.

How GPT’s 30-minute cache compares

OpenAI’s prompt caching guide says caching is on by default. For GPT-5.6 and later, prompt_cache_options.ttl defaults to "30m", a 30-minute minimum lifetime with a 1.25x write rate, and "12h" costs 2.5x to write. So a 12-minute pause stays warm on GPT’s default and goes cold on Claude’s. A 40-minute pause goes cold on both defaults.

When the 1-hour cache pays off

The 1-hour write costs $3 more per million tokens than the 5-minute write on Opus 5.5. A single rescue saves $4.80 per million (a $5.00 rewrite replaced by a $0.20 read). So one pause between 5 and 60 minutes covers the extra cost.

Typical pause between steps Cheapest choice Why
Under 5 minutes 5-minute TTL Every hit refreshes the clock for free
5 to 60 minutes 1-hour TTL One avoided rewrite covers the 2x write
Over 60 minutes Neither saves you Both expire; design the pause out

That matches what one HN commenter found after measuring their own usage: the 5-minute cache was cheaper for them, and the 1-hour cache only helps when work is spaced 5 to 60 minutes apart. Measure before you switch.

Requesting the 1-hour TTL is one field. Here’s a request with the Python SDK:

import anthropic

client = anthropic.Anthropic()

response = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=2048,
    system=[
        {
            "type": "text",
            "text": AGENT_INSTRUCTIONS + REPO_CONTEXT,  # long, stable prefix
            "cache_control": {"type": "ephemeral", "ttl": "1h"},
        }
    ],
    messages=history,
)

If you mix TTLs in one request, the docs require longer-TTL entries to appear before shorter ones. Up to 4 cache breakpoints are allowed per request.

How to measure what pauses cost you

Don’t guess your pause pattern. Log the usage fields on every response and compare writes to reads:

u = response.usage
print({
    "written": u.cache_creation_input_tokens,
    "read": u.cache_read_input_tokens,
    "uncached": u.input_tokens,
    "by_ttl": u.cache_creation,  # ephemeral_5m_input_tokens, ephemeral_1h_input_tokens
})

A healthy agent session shows one large write, then mostly reads. A session that waits on people shows large writes after every human reply. On OpenAI, the matching field is usage.input_tokens_details.cached_tokens.

Also check the minimum length. On Opus 5.5 and Sonnet 5.5, prompts under 512 tokens aren’t cached at all, and no error tells you so.

Design pauses out of the run

The TTL choice is a patch. The bigger fix is where your human checkpoints sit. An agent that stops mid-run to ask a question holds a warm context it can’t keep. An agent that finishes its run, hands back a result, and starts a fresh run after review pays one write per run instead of one per question.

Three habits help:

  • Front-load questions. Ask the agent to list open questions before it starts, answer them in the task, then let it run without stopping.
  • Keep the prefix stable. Don’t toggle tools, tool_choice or images between steps. Each change invalidates everything after it.
  • Batch review. If a reviewer answers three agents in one sitting, each resumes within minutes of the last, which is where the 5-minute cache works best.

For more on review as the real constraint, see human review is the bottleneck.

How Sharkly keeps human waits between runs

Sharkly is a work management platform for coding agents. It doesn’t replace Claude Code or Codex; it assigns tasks to Agents that run on those tools, and model usage bills to the account configured on each Runtime. Sharkly doesn’t touch your provider’s cache, so the pricing above applies unchanged. What it changes is where the wait happens.

According to Sharkly’s task execution docs, an Agent can leave a task waiting for a human reply or waiting for human review. That hand-off shows up in the sidebar’s Task Chats module, which lists the task conversations you started by recent activity. The reviewer replies in the task chat or @mentions the Agent in a comment, and that starts the next run; rapid mentions of the same Agent don’t create duplicate pending runs. A plain comment with no mention doesn’t start anything, so a reviewer can leave notes freely and clear a batch of hand-offs in one sitting.

That puts the human pause between runs, not inside a held session. Whether the next run reads a warm cache still depends on the Runtime and how fast you answer, so the design advice above still applies: answer review in batches and keep each Agent’s instructions stable.

Architecture diagram: an Agent's run ends and the task waits for review in Sharkly's Task Chats; the reviewer replies in the task chat or @mentions the Agent, which starts a new run on the same Agent and Runtime; the provider cache sits outside Sharkly and is reused only if the new run starts inside its TTL.

Pick the model per Agent

Cache prices scale with the model. A 5-minute write is $5.00 per million tokens on Opus 5.5 and $2.50 on Sonnet 5.5 . Each Sharkly Agent carries its own Runtime and default model, so a role that waits on people often can run on the cheaper model while another Agent keeps Opus.

An Agent's Computer, Runtime and working directory settings in Sharkly, with the Default model picker highlighted: each Agent sets its own model.

For help choosing, read Sonnet 5.5 or Opus 5.5: which agent gets the task and when a cheaper model costs more.

Other ways to cut pause costs

  • Cache warmers. One HN commenter sends a near-empty request every few minutes to refresh the 5-minute TTL and reports large weekly savings. Each ping is a read of the full prefix, so it only pays when the pause is short and predictable.
  • Smaller prefixes. Trim repository context and tool lists to what the task needs. A 40,000-token prefix costs 60% less to rewrite than a 100,000-token one.
  • Choose the provider by pause pattern. If your workflow has long, unpredictable gaps, a longer default TTL matters more than the headline price.

For tracking spend across tools, see coding agent cost management.

Stop paying for idle minutes

A 5-minute cache punishes slow answers, and agents that wait on people are slow by design. Log cache_creation_input_tokens for a week, switch to the 1-hour TTL if your pauses land between 5 and 60 minutes, and move questions out of the middle of runs. Then set up your Agents in Sharkly so review happens between runs, and the cache question shrinks to one write per run.

FAQ

How long does the Claude prompt cache last?

5 minutes by default, measured from the start of the last request that wrote or read the entry. Every hit refreshes it at no cost. You can request a 1-hour TTL per breakpoint.

How much does the 1-hour Claude cache cost?

Writes cost 2x the base input price, against 1.25x for the 5-minute cache. Reads cost the same on both. On Opus 5.5 that’s $8.00 against $5.00 per million written tokens.

Does GPT have a 30-minute cache?

For GPT-5.6 and later, OpenAI’s docs list "30m" as the default cache TTL, with a "12h" option at a 2.5x write rate. Earlier models use a different retention setting.

What invalidates the Claude prompt cache?

Any change to tool definitions invalidates everything. A change to the system prompt invalidates system and messages. Changing tool_choice, or adding or removing images, also invalidates the cache.

Can I keep the cache warm with dummy requests?

Yes, a request that reads the cache refreshes its TTL. But each one pays the read rate on the full prefix, so it only beats the 1-hour TTL for short, predictable pauses.

How do I know if my agent is losing its cache?

Check cache_creation_input_tokens on each response. Large writes after every human reply mean your pauses outlast the TTL.

Explore more

How to Connect GitLab to AI Agents in Sharkly

How to Connect GitLab to AI Agents in Sharkly

Want GitLab issues worked by AI agents? Learn how the Sharkly GitLab integration syncs issues to tasks and links merge requests back.

4 December 2026

How to Control a Sharkly Agent From Lark

How to Control a Sharkly Agent From Lark

Want a Lark AI agent bot for your team? Learn how to file Sharkly Tasks from a Lark group, run an Agent, and get progress back in the thread.

4 December 2026

How to Run an AI Coding Agent From Discord or Telegram

How to Run an AI Coding Agent From Discord or Telegram

Want an AI coding agent Discord bot or Telegram bot? Learn how to connect a Sharkly Agent, file Tasks from chat, and stop runs where they start.

4 December 2026

Claude Prompt Cache TTL: Why Agent Pauses Cost You Money