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
- Muse AI agent finds, calls and books a dentist in under 10 minutes, for free — ChrisUniverse · 2026-09-18
- Cursor Projects wins praise: kanban tracking, multi-model agents and 3-way bakeoffs — kieranklaassen · 2026-09-18
- OpenAI's Astra Struggles With Long-Term Architecture: Duplication, Overengineering, Bad Assumptions Linger — Substantial_Swan_144 · 2026-09-18
- Hang Ten Systems raises $53M more in seed funding, totaling $85M — vsikka · 2026-09-18
- Does AI coding actually become multiplayer? Shared Slack agents vs. supercharged solo devs — Telos_in_the_Void · 2026-09-18
- Skillry launches curated Agent Skills library to give Claude Code & Codex taste — yihui_indie · 2026-09-18