Keep-Warm
When a session pauses longer than its prompt-cache lifetime and then resumes, most of the prefix is written again at the cache-write rate. A Keep-Warm ping reads the cached prefix just before it expires, which refreshes it for another hour at roughly a tenth of the input price.
How to turn it off, on, or down
Section titled “How to turn it off, on, or down”cd ~/.claude/skills/token-optimizer/scriptspython3 measure.py keepwarm-decide set off # in session and headlesspython3 measure.py keepwarm-decide set on # both on, without waiting for the linepython3 measure.py keepwarm-decide set budget 3 # dollars per 24 hours; 0 is offpython3 measure.py keepwarm-decide status # what is on, why not, and today's spendThe line is printed only in an interactive terminal session of Claude Code on macOS or Linux. Print mode, agents, cloud sessions, desktop-only use, Windows and other tools never print it, so nothing pings there until you run set on. A settings file that cannot be read, or a saved value or environment switch Token Optimizer does not know, turns Keep-Warm off.
Approving Keep-Warm in the savings plan is the same as set on. One other thing counts as a yes, for headless pings only: a consent of enabled saved by an earlier version. An environment variable is never a yes. TOKEN_OPTIMIZER_KEEPWARM_HEADLESS=on, which 5.13.85 and earlier accepted, now does nothing: run keepwarm-decide set on instead.
Your newest choice wins, in session and headless:
keepwarm-decide set onis a fresh yes. It clears an earlier decline.keepwarm-decide set offandkeepwarm-disablestop both paths and clear an earlier yes.
If an older version saved both a yes and a decline, the decline wins until you choose again.
The off switches in the environment beat any choice:
TOKEN_OPTIMIZER_KEEPWARM=offstops both paths.TOKEN_OPTIMIZER_KEEPWARM_HEADLESS=offstops headless pings.
A watcher that is already running reads your choice again before each ping. One started by 5.13.76 through 5.13.85 keeps the old code in memory and stops when its pause ends, at most about two hours, or when you close that session.
A repository’s .claude/token-optimizer.json can turn Keep-Warm off. It cannot turn it on, stand in for the notice, or change the daily limit. A project’s .claude/settings.json can set environment variables for the whole Claude Code process, and Token Optimizer cannot tell those from your own. None of them is a yes, but one that moves the config folder could point at a file the repository carries. Review a repository’s settings before you trust it, as you would its hooks.
keepwarm-enable is paused in this release and changes nothing.
What it spends
Section titled “What it spends”A ping is a cache read of the whole session prefix, a small write of up to 5%, and about 1,000 fresh input tokens, at your model’s price. These limits apply to every automatic path together:
| Cap | Limit |
|---|---|
| Per pause | 2 pings |
| Per session, 24 hours | 4 pings |
| Whole installation, 24 hours | 8 pings |
| Money, 24 hours | API billing: a $3.00 rolling budget unless you raise it (set budget), checked before each ping; an in-flight reply can run past it, after which automatic pings pause for 24 hours. Subscription: plan allowance, not dollars |
Subscription pings also need fresh readings of both limits, under 80% of the 5-hour limit and under 90% of the weekly limit. API billing has no such meter, so the caps and the daily dollar limit protect it.
On API billing, or when Token Optimizer cannot tell how a session is billed, a ping goes out only if what pings cost in the last 24 hours plus the whole worst case of the next one fits your limit. The worst case is a missed cache, the full prefix written again for an hour, plus a reply of up to 4,096 tokens. A session too large to rewrite inside the limit is not pinged. Token Optimizer cannot cap a single reply, so an in-flight reply can run past the budget. Paid pings go one at a time: the next waits up to 10 minutes for the bill of the last. A long reply is still counted in full, and automatic pings then pause for 24 hours.
A subscription counts as proven only when Claude Code is signed in with an account, fresh 5-hour and weekly meters exist, and no API key, gateway or cloud provider is set in the environment or in user, project or managed settings. Pings there use plan allowance, not dollars, and the meters above protect it.
The default of $3 comes from a 30-day replay of one heavy user’s history: under the API rule, $3 a day came out ahead and $1 a day forecast a small loss. It is an estimate from one user, not a guarantee. No real ping has been measured yet.
When it pings
Section titled “When it pings”A ping goes out only when all of this is true:
- The session has a measured one-hour cache and at least 100,000 tokens of prefix.
- The cache is close to expiry (55 minutes) and has not expired.
- Your own history has at least 20 comparable pauses, and the chance of a return times the avoided rewrite is at least three times the ping cost.
- The model has a known price and the session is still paused.
- The ping fits in what is left of the daily limit.
Nothing pings a subagent or an ended session. The fork runs one turn, disables hooks, blocks permission prompts and is not saved.
What can run
Section titled “What can run”| Path | Where | Needs |
|---|---|---|
| In-session | Claude Code desktop mod | the notice, or keepwarm-decide set on |
| Desktop fallback | Claude Code desktop mod | the notice, or any yes |
| Terminal watcher | an open terminal session on macOS or Linux | the notice, or any yes; no scheduler needed |
| Scheduler tick | launchd (macOS) or systemd (Linux) | the notice or any yes, and the scheduler installed |
The scheduler is not implemented on Windows.
Safety stops
Section titled “Safety stops”- Proof. Each ping must show that it read at least 90% of the prefix and wrote at most 5%. A failed proof stops that session, and stops headless pings for the installation.
- Tripwire. At least five pings and a negative verified net over seven days stop automatic pings.
- Ledger. Spend is reserved before the request runs, so a crash cannot hide it. Savings show the signed net: every ping’s cost is deducted, including pings that never led to a return. No forecast enters a savings total.
Commands
Section titled “Commands”cd ~/.claude/skills/token-optimizer/scriptspython3 measure.py keepwarm-tick --dry-run # what would be pinged and why, without firingpython3 measure.py keepwarm-scheduler status # install | uninstall | statuspython3 measure.py keepwarm-consent-status # billing mode and saved consentpython3 measure.py keepwarm-forecast --days 30 # projection from your own historypython3 measure.py keepwarm-backfill --days 30 # replay over your real historypython3 measure.py keepwarm-report # pings, spend, realized and netpython3 measure.py keepwarm-quota-value # subscription value in quotakeepwarm-scheduler install refuses while Keep-Warm is off or its notice has not been shown. keepwarm-arm is kept for older hooks and does nothing.
The subscription quota-value story
Section titled “The subscription quota-value story”On a subscription the plan is flat-rate, so a ping does not save money. The scarce resource is rate-limit quota, and a cold resume spends it. keepwarm-quota-value reports Keep-Warm in that currency.
cd ~/.claude/skills/token-optimizer/scriptspython3 measure.py keepwarm-quota-value --jsonThe effect on subscription limits is measured separately and has no proven conversion to dollars.
Default state
Section titled “Default state”On in Claude Code after the notice, inside the daily limit, for anyone who has not chosen. Reporting commands work either way. keepwarm-backfill reads history and can write its own sidecar file.
The manual Keep warm button
Section titled “The manual Keep warm button”The Claude desktop status bar (part of the Token Optimizer plugin) has a Keep warm button. It is separate from automatic Keep-Warm.
| Automatic Keep-Warm | Keep warm button | |
|---|---|---|
| Runs | on its own, after the notice or your yes | only when you click |
| Billing | any plan | any plan |
| Cost | plan limits or API credits per ping, within the caps and the daily limit | a small amount of your usage per click; it tells you how many tokens it re-read from the cache |
| After expiry | no ping | disappears |
The button never fires on its own. See the desktop status bar.
Risk rating
Section titled “Risk rating”Low. The cost of being wrong is a capped spend that shows in keepwarm-report. If a ping fails you fall back to an ordinary cold resume.
Related
Section titled “Related”- Cache TTL watchdog:
cache-reportmeasures the expiry waste Keep-Warm targets. - Subagent prompt cache: the 1-hour lifetime for subagent prefixes.
- Cache economics: why a cold resume costs more.
- Your data and privacy: consent state and how to reset it.
- Configuration: the environment variables.
