Modern AI-driven development has entered an era where the bottleneck is no longer just the quality of the code generated, but the efficiency of the token spend. Developers using Claude Code often find themselves in a high-productivity flow, delegating complex refactors to an autonomous agent, only to be surprised by an API bill that scales faster than their project. This financial friction usually stems from a hidden architectural quirk in how large language models handle long-term memory during a session. The industry has moved toward prompt caching to solve this, yet the implementation of these caches often introduces a new set of constraints that can inadvertently drive costs upward for power users.
The Hidden Tax of the Five Minute TTL
Recent measurements across 185 local sessions reveal a startling inefficiency in the current Claude Code workflow. Data shows that cache rebuild costs account for approximately 22% of the total billing. This expenditure is not a result of inefficient prompting, but a direct consequence of the 5-minute Time To Live (TTL) assigned to Claude Code's prompt cache. In the world of LLM orchestration, a cache is only as useful as its persistence. When a request is made with a specific prefix, the system stores that processed data to avoid re-encoding it in the next turn. However, if more than five minutes elapse between requests using that same prefix, the cache expires automatically. The developer is then forced to pay the full price to rebuild that cache from scratch.
The financial disparity between a cache hit and a cache miss is significant. Reading from an existing cache costs only 0.1x the standard input price. In contrast, when a cache expires and a re-encoding event occurs, the user is hit with a write cost of 1.25x. This means that failing to maintain a warm cache doesn't just cost the base rate; it imposes a premium penalty for the act of re-writing the data into the system. In the observed sessions, these re-encoding events were not minor. Individual rewrite processes frequently involved massive token volumes, ranging from 200K to 500K tokens. When a developer is processing a large codebase, paying a 1.25x premium on half a million tokens every few minutes creates a compounding financial drain.
The Sub-Agent Paradox and the Reverse Proxy Solution
The most frequent cause of this cache expiration is the inherent architecture of agentic workflows. Claude Code often employs a main agent that delegates specific, time-consuming tasks to sub-agents. The tension arises because the sub-agent operates using a different cache prefix than the main agent. While the sub-agent is deep in the weeds of a complex task, the main agent remains idle, waiting for a response. If the sub-agent's task exceeds the five-minute threshold, the main agent's cache—which contains the entire context of the project and the current session—simply vanishes. By the time the sub-agent reports back, the main agent must re-encode the entire conversation history, effectively paying a tax on the time it spent waiting.
This is where claude-thermos enters the pipeline. Rather than attempting to modify the Claude Code binary or the Anthropic API itself, claude-thermos implements a local reverse proxy. By configuring the `ANTHROPIC_BASE_URL` to point to a loopback port, all traffic from Claude Code is routed through this proxy before reaching the actual Anthropic API. The proxy acts as a sentinel, monitoring the TTL of the prompt cache in the background. It automatically sends heartbeat-style updates to keep the cache active, ensuring that the main agent's context remains warm regardless of how long a sub-agent takes to complete its mission.
By maintaining this state, claude-thermos shifts the cost profile of a session. It ensures that every turn of the conversation is processed at the 0.1x read rate, bypassing the 1.25x write penalty entirely. The tool essentially eliminates the volatility of the billing cycle by removing the risk of sudden, massive re-encoding charges. For developers working on complex workflows where sub-agent tasks routinely exceed five minutes, the utility of this tool is transformative, turning a fluctuating expense into a predictable, minimized cost.
To deploy this optimization, the system must have the claude CLI configured in the PATH. The tool requires Python 3.11 or higher and is designed to be executed via uvx, the Python package execution tool. The implementation is a single command that wraps the existing CLI:
uvx claude-thermos claudeWhile the 22% savings figure is a benchmark derived from 185 local sessions, the actual ROI for an individual developer depends on their specific usage patterns. Those who engage in rapid-fire prompting may see negligible gains, but for those managing deep, autonomous agentic loops, the reduction in token waste is substantial. The shift toward tools like claude-thermos signals a broader trend in LLMOps where the focus is moving from prompt engineering to infrastructure engineering, optimizing the very plumbing of how tokens are cached and delivered.



