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.

Original post →

More from coding & agent

coding & agent channel →