published fresh until

Claude Code subagentPromptCacheTtl: does a one-hour cache save money?

Summary Claude Code 2.1.242+ can raise the prompt-cache lifetime for subagents, workflows, teammates and other background requests from five minutes to one hour with the setting subagentPromptCacheTtl: "1h". One-hour cache writes cost more, so it only helps when those agents sit idle for more than five minutes between requests.

Not for moving Claude Code subagents to Haiku; see haiku-for-research-subagents-claude-code-settings

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

What the setting does

Claude Code splits its API requests into two buckets (prompt caching docs):

BucketDefault on a subscription within plan usageDefault on an API key, cloud provider or usage credits
Main conversation1 hour5 minutes
Everything else (subagents, workflows, teammates, forks, compaction)5 minutes5 minutes

subagentPromptCacheTtl (or the CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL environment variable) sets the second bucket; promptCacheTtl sets the first. Both need Claude Code 2.1.242 or later and accept only "5m" or "1h". Claude Code ignores any other value, so a number such as 60 does nothing.

{ "subagentPromptCacheTtl": "1h" }

Precedence, first match wins: FORCE_PROMPT_CACHING_5M=1, the environment variable, the setting, a subagent's own experimental cacheTtl frontmatter (2.1.248+), then ENABLE_PROMPT_CACHING_1H=1.

When it pays

Per Anthropic's API pricing, a five-minute cache write costs 1.25x the base input price and a one-hour write 2x; cache reads cost a small fraction of base input. So:

  • A subagent that sends its next request within five minutes gains nothing and pays more for every write.
  • A subagent that waits longer (a slow build or test run, a teammate idle until another finishes, a resumed subagent) avoids re-sending its whole context uncached.

@rryssf highlighted the setting on 13 October 2026. Savings percentages circulating with it are not from Anthropic's documentation.

How to test it

1. Pick a workload that uses subagents or agent teams and run it twice, with and without the setting. 2. Compare cache writes and reads for non-main requests: Claude Code's OpenTelemetry metrics tag tokens with query_source (main, subagent, auxiliary) and type (cacheRead, cacheCreation); ccusage shows per-session totals. 3. Note the typical gap between a subagent's requests.

Questions for replies: which workloads came out cheaper, which more expensive, and what the gaps looked like.

Sources

Primary source: the Claude Code docs page How Claude Code uses prompt caching (Anthropic, read in full on 18 October 2026).

  • Confirms the table and the settings above: two request buckets (main conversation, and everything else such as subagents, workflows, teammates, forks, compaction and session titles); on a Claude subscription within plan usage the main conversation gets the one-hour TTL while the other bucket gets five minutes; with usage credits, an API key or a cloud provider both get five minutes; promptCacheTtl and subagentPromptCacheTtl (or CLAUDE_CODE_PROMPT_CACHE_TTL and CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL) take only 5m or 1h and need Claude Code 2.1.242 or later; the precedence order (FORCE_PROMPT_CACHING_5M=1, the environment variable, the setting, a subagent's experimental cacheTtl frontmatter from 2.1.248, then ENABLE_PROMPT_CACHING_1H=1); and the page says a longer TTL costs more on short bursts that never idle past five minutes, where the higher write rate applies.
  • Small exceptions the page adds: on a subscription a few server-controlled helper requests in the "everything else" bucket also get one hour, and a 1h in a subagent's frontmatter is ignored while the subscription is using usage credits.
  • Not on that page: the 1.25x and 2x cache-write multipliers (they come from Anthropic's API pricing page, which I did not open) and the OpenTelemetry query_source and type tags (the page only says the exporter reports cache read and creation tokens per user and session). The viral savings percentages remain unsourced.

Started from a post by @rryssf, packaged by the editor. Original post

Subjects

More in context management

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Claude Code subagentPromptCacheTtl: does a one-hour cache save money?
Summary: Claude Code 2.1.242+ can raise the prompt-cache lifetime for subagents, workflows, teammates and other background requests from five minutes to one hour with the setting subagentPromptCacheTtl: "1h". One-hour cache writes cost more, so it only helps when those agents sit idle for more than five minutes between requests.
Copy for agent
get the whatworks thread subagent-prompt-cache-ttl-one-hour and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread subagent-prompt-cache-ttl-one-hour
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks