← posts / ai integrations

Claude Code subagents get a 5-minute cache even on a subscription: when to set it to 1h, and how to check

On a subscription your main Claude Code conversation gets a one-hour prompt cache, but subagents, workflows and compaction stay at five minutes. The settings that change it, the precedence order, when the pricier 1h write pays off, and how to verify the TTL you got.

if.codesOct 16, 2026 · 6 min read#claude-code#prompt-caching#subagents#llm-costsAI-assisted
Claude Code subagents get a 5-minute cache even on a subscription: when to set it to 1h, and how to check

If you run Claude Code on a Pro or Max plan, your main conversation already gets a one-hour prompt cache. Your subagents probably do not. The prompt caching docs split every request into two TTL buckets, and only one of them gets the hour by default. That matters most for exactly the work subagents are good at: long fan-outs, slow research agents, and reviewers that sit idle while you read their output.

This post covers what the two buckets are, the settings that move them, the precedence order when several apply, when paying for the one-hour write is worth it, and how to check which TTL your requests actually got. That last part matters more than it sounds, because at least one public report shows the docs and the transcripts disagreeing.

The two buckets

Claude Code decides the cache TTL per request. Every request falls into one of two buckets:

The two different time-to-live buckets for prompt caching.
The two different time-to-live buckets for prompt caching.
  • Main conversation: your interactive turns, -p runs, Agent SDK turns, and the helpers Claude Code runs inline with them.
  • Everything else: subagents, workflows, in-process teammates, forks, compaction and session titles.

Defaults, per the docs:

  • Claude subscription, within plan usage: main conversation gets one hour. Everything else gets five minutes, except a small set of helper requests that Anthropic controls server-side.
  • Usage credits, API key or cloud provider: five minutes for both buckets.

The docs say it directly in the subagents section: subagents fall outside the main-conversation bucket, "so they get five minutes even on a subscription" until you choose otherwise. A subagent also starts with its own system prompt and tools, so its first request never reads the parent’s cache. It warms its own, and that cache dies after five idle minutes.

What the hour costs

The one-hour TTL is not free. On the API, a five-minute cache write costs 1.25x the base input price, a one-hour write costs 2x, and a cache read costs 0.1x (with lower read multipliers on some models). Here are the current per-million-token rates from the API prompt caching page for the two models most people run subagents on:

Balancing the higher write cost against the benefit of longer cache retention.
Balancing the higher write cost against the benefit of longer cache retention.
Opus 5.5Sonnet 5.5$0$2$4$6$85m cache write · Opus 5.5: $5$55m cache write · Sonnet 5.5: $2.5$2.55m cache write1h cache write · Opus 5.5: $8$81h cache write · Sonnet 5.5: $4$41h cache writeCache hit · Opus 5.5: $0.2$0.2Cache hit · Sonnet 5.5: $0.1$0.1Cache hit
Cache pricing per million tokens Source: Claude API prompt caching docs
Cache pricing per million tokens
Opus 5.5Sonnet 5.5
5m cache write$5$2.5
1h cache write$8$4
Cache hit$0.2$0.1

So the trade is simple. The hour costs an extra 0.75x of base input on every write. In return, a gap between 5 and 60 minutes becomes a cache read instead of a full rewrite. Take a subagent with a 50k-token prefix on Opus 5.5:

  • Five-minute TTL, no idle gap: write $0.25, next turn reads for $0.01. Total $0.26.
  • One-hour TTL, no idle gap: write $0.40, read $0.01. Total $0.41.
  • Five-minute TTL, one gap over five minutes: write $0.25, expire, write again $0.25. Total $0.50.
  • One-hour TTL, same gap: write $0.40, read $0.01. Total $0.41.

One avoided expiry per prefix pays for the hour. If the subagent never pauses for five minutes, the hour is pure overhead. Those dollar figures are API billing; on a subscription the same tokens count against your plan usage instead, but the shape of the trade is the same. The API docs list the same use cases for the hour: prompts reused less often than every five minutes but more often than every hour, such as "an agentic side-agent" that takes longer than five minutes.

When to set it to 1h

  • A subagent you resume later. The docs note a resumed subagent’s first request can read the cache the original run warmed, but only if it is still alive.
  • Long fan-outs where agents sit waiting on tools, builds or test runs for more than five minutes between turns.
  • A reviewer or auditor agent whose results you read, think about, then send back for a second pass.

When to leave it at 5m

  • Short, busy subagents that finish in a few back-to-back turns. Each turn resets the five-minute timer, so they never expire.
  • One-shot explorers whose cache is never read again.
  • Anything billed through usage credits where you have not measured idle gaps yet.

The settings

Each control takes 5m or 1h; Claude Code ignores any other value. The settings and environment variables require Claude Code v2.1.242 or later.

  • Main conversation: promptCacheTtl setting or CLAUDE_CODE_PROMPT_CACHE_TTL.
  • Everything else: subagentPromptCacheTtl setting or CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL.

For all subagents in every project, add it to ~/.claude/settings.json (or .claude/settings.json for one project):

{
  "subagentPromptCacheTtl": "1h"
}

For a single session, use the environment variable:

CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL=1h claude

On an API key, the main conversation is also on five minutes by default, so you probably want both:

{
  "promptCacheTtl": "1h",
  "subagentPromptCacheTtl": "1h"
}

Per-subagent: the experimental cacheTtl

Usually only one or two agents idle long enough to justify the hour. Since v2.1.248 a subagent file can set its own TTL inside the experimental map (not at the top level of the frontmatter). Save this as .claude/agents/repo-auditor.md:

---
name: repo-auditor
description: Audits a large repository and reports what it finds
tools: Read, Glob, Grep
experimental:
  cacheTtl: 1h
---

You audit the repository. Report findings with file paths and line numbers.

Two caveats from the docs: Claude Code reads this field only from subagent files, and it ignores 1h there while your Claude subscription is drawing on usage credits.

Want AI wired into the systems you already run?I build LLM integrations with costs and quality you can see. The estimate is free.

Precedence: who wins

When more than one control applies, Claude Code takes the first match:

The order of precedence for cache settings.
The order of precedence for cache settings.
  1. FORCE_PROMPT_CACHING_5M=1, which forces five minutes for both buckets.
  2. The bucket’s environment variable.
  3. The bucket’s setting.
  4. For subagent requests, experimental.cacheTtl in the subagent file.
  5. ENABLE_PROMPT_CACHING_1H=1, which requests one hour for both buckets.
  6. The bucket’s default.

The consequence that trips people up: the per-agent frontmatter sits below the global setting. If you set subagentPromptCacheTtl to 5m globally and cacheTtl: 1h on one agent, the global setting wins and that agent gets five minutes. To use per-agent TTLs, leave subagentPromptCacheTtl unset. FORCE_PROMPT_CACHING_5M=1 beats everything, including managed settings, which makes it the right switch for an A/B comparison.

Check which TTL you actually got

The API reports cache writes split by TTL: ephemeral_1h_input_tokens and ephemeral_5m_input_tokens under usage.cache_creation. For the main conversation, the docs give a one-liner:

claude -p "hello" --output-format json | jq '.usage.cache_creation'

Subagents write their own transcripts. A GitHub issue reporter found them under ~/.claude/projects/<project>/ in subagents/agent-*.jsonl files and grepped the cache_creation objects. This version counts the distinct splits across every subagent transcript changed in the last hour:

find ~/.claude/projects -path '*subagents*' -name 'agent-*.jsonl' -mmin -60 -exec grep -ohE '"cache_creation":\{[^}]*\}' {} + | sort | uniq -c | sort -rn | head

If every line shows "ephemeral_5m_input_tokens":0, your subagents are writing one-hour caches. If the 1h counter is zero, they are on five minutes.

Run this before you change anything. In issue #84289, a subscriber on v2.1.222 with no overrides saw 100% of subagent cache writes land in the one-hour bucket, the opposite of the docs. A maintainer replied that Claude Code requests five minutes for subagents but the effective TTL is decided further downstream. A later commenter on v2.1.258 reported the opposite: all subagent writes in the five-minute bucket, and expensive re-caching when turns ran longer than five minutes. The behaviour has varied by version and model, so measure your own setup rather than trusting either the docs or this post.

For an ongoing view, /usage (v2.1.251+) shows a Prompt cache (main) line with hit ratio, misses and whether the cache is warm, and from v2.1.260 it names the likely cause of the last miss. As the name says, that line covers the main conversation. For subagents, the transcripts above or the OpenTelemetry cache token metrics are your evidence.

A sane default

  • Leave subagentPromptCacheTtl unset.
  • Add experimental.cacheTtl: 1h only to the agents you know idle or get resumed.
  • Check the transcript split once after the change, and again after each Claude Code upgrade.
  • Use FORCE_PROMPT_CACHING_5M=1 for a day if you want a baseline to compare against.

Sources

if.codesI build RAG, AI integrations and agent pipelines on Go and Python backends — and write about it here.
// keep reading

More posts on AI and backends.

// free quote

Read something you need? I’ll quote it for free.

RAG, AI integrations, agents or the backend underneath — tell me what you have and what should change. I read every request myself.

Free · no commitment

Tell me what you have. I’ll tell you what it takes.

1Describe the projectA few sentences is enough — about two minutes.
2I review itI read it myself and may ask a follow-up question.
3You get a free quoteScope, approach and estimate — yours to keep, no strings.
What kind of project is it?
Free and without obligation. Your details are used only to reply — see the privacy policy.