Skip to content

Warming

Drew T edited this page Oct 17, 2026 · 1 revision

Keeping caches warm

Claude Code keeps each agent's context in a prompt cache, so its next request reads that context cheaply instead of paying to write it again. The cache lasts 5 minutes after the agent's last request for a coder, and 1 hour for an expert and for Claude. An agent that waits longer than that pays to write its whole context again on its next request, or PA3 starts a fresh agent in its place.

Warming is the mod sending a waiting agent a one-character message, a dot, shortly before its cache would expire. The agent answers by ending its turn with a dot. That one small request reads the cache and keeps it alive for another 5 minutes or another hour.

The rule

A ping is worth sending while the wait is more likely to end soon than the ping costs compared with going cold.

  • A ping is cheap. It reads the agent's context once, at a twenty-fifth of the price of writing it on the 5-minute cache and a fortieth on the 1-hour cache, plus a few tokens of reply.
  • Going cold is not. A coder writes its whole context again. An expert is replaced by a fresh expert seeded with the task's progress notes (a median $0.37 to get back to work). Claude is replaced by a fresh Claude seeded from the journal (about $0.46).

PA3 set each limit from its own history: how long agents' waits actually lasted, and how likely a wait that had already run long was to end in the next half hour or hour.

The limits

Agent Cache Ping Kept warm for up to After that
A coder waiting on its own background shell 5 min about every 4.5 min (due 4 min after its last request) 2.5 hours (33 pings) it writes its context again when the shell's end wakes it
An expert 1 hour every 55 min 12 hours (12 pings); 7 hours past a 250k context a fresh expert with the task's progress takes over
Claude, under 100k context 1 hour every 55 min 12 hours a fresh Claude, seeded from the journal, takes your next message
Claude, 100k to 125k 1 hour every 55 min 6.5 hours the same
Claude, 125k to 175k 1 hour once, at 55 min about 2 hours the same
Claude, 175k and up 1 hour none its free hour the same

Coders. Of the 40 background-shell waits in PA3's history, 82% ended within an hour, and all but one overnight job within about 2 hours 10 minutes. Half an hour of pings costs about a third of a cold rewrite, whatever the coder's size, because both grow with its context. So warming pays until about 2.5 hours.

Experts. Of the 44 expert waits that outlasted the 1-hour cache, every one ended, the longest after 9.2 hours. Even after 4 to 6 hours, about a quarter of those still waiting ended in each following hour, while an hour of warming costs 3% to 18% of a fresh start. 12 hours also covers a question asked in the evening and answered the next morning.

Claude. A fresh Claude is cheap and starts lean, and Claude reads its whole context again with every message. After a long pause, a big Claude costs more to keep than to replace.

What it saves

  • On the six coder waits after 3.28.7 in two live projects, warming would have cost $0.34 against $1.66 going cold.
  • On the 44 expert waits in PA3's history, the 12-hour limit costs $1.64, against $3.69 with the earlier size rule and $31.42 with no warming.

How it works

  • The mod checks every 30 seconds. A coder is pinged only while it waits on a background shell of its own with its turn ended. An expert is pinged while it waits on a coder, a shell or your answer to its question. Claude is pinged while it is idle. Nobody is pinged while working, or while their task is stopped.
  • The ping is a dot, and the agent answers by ending its turn with a dot. If Claude Code then asks it for a report, it hands back a dot. A ping's answer is never shown to you or filed in the journal.
  • A real turn (a report, your message, a shell ending) starts the count over.
  • Nothing is sent to an expert or a Claude whose cache has expired: a fresh one takes the message instead.
  • Each ping is recorded in the usage ledger as a warm_ping event, with what it cost and the rewrite it avoided.

How it was checked

  • A simulated run drove the mod's own code on a mock clock, answering each ping as an agent would:
    • a coder: 33 pings, 4.5 minutes apart, warm for 2.56 hours, never more than 4.33 minutes after its last request;
    • an expert: 12 pings, 55 minutes apart, warm for 12 hours (7 pings and 7.4 hours past 250k);
    • Claude: 12, 6, 1 and 0 pings at 60k, 110k, 150k and 200k.
  • In real use, 26 pings to coders that landed 4.2 to 4.6 minutes after their previous request, and all 22 expert and Claude pings after 3.28.7, read the cache rather than writing it again.

Clone this wiki locally