Extend Claude Code subagent prompt cache TTL
Claude Code's subagent cache lasts only 5 minutes by default, but a setting can extend it to 1 hour—though testing is recommended before changing it.
By default, the subagent cache in Claude Code lasts for only 5 minutes. This means that if a subagent remains idle for more than 5 minutes, you lose the ability to use the cache at a reduced price.
You can change this behavior with the following setting:
"subagentPromptCacheTtl": "1h"
However, Boris Cherny notes that the default settings work well for most users. Therefore, before changing this parameter, it is worth testing it and measuring the results.
You can run this script to evaluate whether increasing the subagent cache lifetime to 1 hour will save money.
Why it matters
AnalysisA longer TTL can reduce prompt cache costs for long-running or interrupted subagent workflows, but the savings depend on actual usage patterns.
Discuss in community
Share your questions and insights with developers
Related in Ecosystem
Practical guides, core terminology, and agent skills
Subagents and Parallel Execution in Claude Code: Running Multiple Tasks Simultaneously
A comprehensive guide to task parallelization in Claude Code: subagent architecture, shared vs. isolated context, Fan-Out and Swarm patterns, headless CLI orchestration with -p, and token economics.
Claude Code Projects: How a Single AI Orchestrates a Team of Autonomous Agents
A deep dive into Claude Code Projects: Coordinator and Threads architecture, parallel branches, shared memory via MEMORY.md, and cloud agent management.
Claude Code
The official terminal agent from Anthropic, operating directly in the command line via Claude 3.7 Sonnet with native support for Bash, Git, file systems, and the MCP protocol.
Claude Code adds automatic fixes for excessive token usage in /usage menu
Starting with Claude Code 2.1.305, users can automatically apply fixes that reduce excessive token usage and inspect Prompt cache hit/miss statistics.