Claude Code sub-agents burn your 5-hour window via 5-minute cache TTL; one-line fix cuts writes 75%
Schadz · reddit · 2026-09-18
A Reddit user diagnosed why Claude Code subscriptions get eaten in hours: sub-agent prompt caches default to a 5-minute TTL (main conversation gets 1 hour). Any tool call longer than 5 minutes—test runs, builds, git hooks—expires the cache, forcing the next request to rewrite the entire sub-agent context (300K–600K tokens) at the 1.25x cache-write price. Measured over one day: 26 full rewrites across 5 sub-agents, 12.2M cache-write tokens.
The fix: add "subagentPromptCacheTtl": "1h" to /.claude/settings. (or CLAUDECODESUBAGENTPROMPTCACHETTL=1h), requires Claude Code v2.1.242+. On usage credits the main conversation also drops to 5 minutes—add "promptCacheTtl": "1h" there. This cut cache writes 75% for the same work.
How to check: inspect /.claude/projects/<project>/<session>/subagents/agent-<id>.l; repeated large cachecreationinputtokens right after long tool calls are rewrites, and ephemeral5minputtokens vs ephemeral1hinputtokens show which TTL each write used.
More from coding & agent
- Tencent unveils Hyra 2.0, a research agent that builds reusable scientific tools — TencentHunyuan · 2026-11-02
- General Reasoning explains how to train agent swarms with RL and latency pressure — rosstaylor90 · 2026-11-02
- "Coding isn't the bottleneck anymore — usage windows are," says founder Kyle Gawley — kylegawley · 2026-11-02
- Demo passed ≠ production-ready: 5 questions to answer before letting agents run your business — _kellhus · 2026-11-02
- An AI agent passed 100 test chats—still not ready to run the business — djgoel123 · 2026-11-02
- Agent given total creative freedom produces a 1:44 code-drawn animated short film — ivegotnoidea1 · 2026-11-02