What this thread does
What the setting does
Claude Code splits its API requests into two buckets (prompt caching docs):
| Bucket | Default on a subscription within plan usage | Default on an API key, cloud provider or usage credits |
|---|---|---|
| Main conversation | 1 hour | 5 minutes |
| Everything else (subagents, workflows, teammates, forks, compaction) | 5 minutes | 5 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;
promptCacheTtlandsubagentPromptCacheTtl(orCLAUDE_CODE_PROMPT_CACHE_TTLandCLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL) take only5mor1hand need Claude Code 2.1.242 or later; the precedence order (FORCE_PROMPT_CACHING_5M=1, the environment variable, the setting, a subagent'sexperimentalcacheTtlfrontmatter from 2.1.248, thenENABLE_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
1hin 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_sourceandtypetags (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