# Optimize burn <!-- ref: @protocol/optimize-burn type: protocol tags: [optimizer, burn, context, tokens, efficiency, cache, measurement] triggers: [why is my burn high, optimize burn, where did my context go, run an optimization, weekly burn review, optimizer] trigger_prompt: When the user asks why their agents' token burn is high, asks you to run an optimization from the protocol.supply Optimizer page, or a weekly burn review comes due. complements: [@protocol/optimizer-install, @protocol/efficiency-measurement, @protocol/context-tuning] version: 2 updated_at: 2026-10-31T00:30:32.148Z --> Your user's collector (`@protocol/optimizer-install`) pushes per-session totals to protocol.supply. This protocol turns those numbers into a short list of levers to try, and checks the levers already tried. You run it on the user's machine: the server holds counts, the transcripts stay here, and the step that needs a transcript says so. **Why it exists:** a burn number alone tells the user nothing to do. Most of the cost sits in a few sessions, and each one fails in one of a few known ways. Each way has a different fix, and one of them, earned context, should be left alone. ## Steps All reads are `curly protocol <path>`. Windows are ISO instants. Leave them out to get the default, which is the last 28 days. ### 1. Read the verdict ```bash curly protocol "/optimizer/metric?cut=protocol_used" ``` If `verdict` is `insufficient-data`, say so, quote `reasons`, and skip to step 2 for the session view only. If `reasonCode` is `no-control-group`, Protocol is in nearly every session and waiting will not help: fetch `/optimizer/metric?cut=<the earliest collector's firstSeenAt>` and read that before/after verdict instead. Never state a trend from fewer than 10 accepted units per arm. **Why:** the verdict already applies the noise floor and the guards. A trend you work out from thin data is a guess, and the user will act on it. ### 2. Find the expensive sessions ```bash curly protocol "/optimizer/session?sort=ctx_integral&limit=10&from=<7 days ago, ISO>" ``` `ctxIntegral` is the context the model re-read, summed over every turn of the session. It is the cost. **Why:** burn is heavily skewed. Ten sessions usually explain most of a week, so classifying them beats averaging all of them. ### 3. Classify each session, cheapest fix first - **Cache invalidation:** `coldWakes > 0` or `modelSwitches > 0`. A rebuilt cache costs about 12.5× a cached read per token, and a switch of model or an idle stretch past the cache's lifetime rebuilds the whole window. The fix is to stay on one model per session and to clear rather than resume after a long break. - **Boot overweight:** `ctxBoot` is above the 75th percentile of `ctxBoot` across the user's sessions. Work that percentile out from a wider page of `/optimizer/session`. Everything loaded before the first prompt is paid again on every turn. Route this to `@protocol/context-tuning`. - **Topic seam without a clear:** look at consecutive sessions in the same project. If one session ran long and the next started on unrelated work without a clear, earlier context was carried into the new task. **Confirm on this machine:** open that session's transcript (`~/.claude/projects/**/<externalSessionId>.jsonl`) and check whether later turns used the earlier context. If the task was the same, the context was earned. If it changed, the user lost tokens at the seam. - **Earned context:** one task, long and heavy, where the later turns needed what came before. **Leave it alone.** **Why the control matters:** a high cache-read-to-output ratio is normal for heavy work. What tells waste from earned context is whether the task continued, not how big the window was. A review without this check "fixes" the user's best sessions. ### 4. Check the guards If the acceptance rate fell, corrections per 100 turns rose, or rework rose between the arms, the headline is **"cheaper, not better"**, whatever CCU says. **Why:** a lower burn bought with worse work is a regression. The guards are there so a cost metric can't argue for that. ### 5. Write back Put these in the user's personal repo, so the next run and the user's other agents can read them: 1. **A report entry** that opens with the actions (verb, one line each), then the verdict with its numbers, then the classified sessions. 2. **One impulse per lever to try**, for example "clear at topic seams" or "don't switch models mid-session" (`@protocol/capture`). 3. **One ledger row per lever** in a `burn-experiments` rows entry with these columns: `lever`, `axis optimised` (the cost the lever should cut), `axis at risk` (the quality it could damage), `predicted`, `measured`, `status`. Create the entry on the first run. **Why:** a lever without a ledger row gets tried twice and never measured. The "axis at risk" column is what makes it an experiment rather than a habit. ### 6. Next run: read the ledger first Before step 1, read the ledger. For each lever marked as started, compare the metric over the windows before and after it began (`/optimizer/metric?cut=<ISO instant the lever started>`), then update `measured` and `status`. **Why:** the loop pays off only when levers are measured after they are adopted. Otherwise the review produces new advice every week and never learns which advice worked. ## Not in scope - Changing the collector or what it uploads: `@protocol/optimizer-install`. - Measuring with nothing uploaded at all: `@protocol/efficiency-measurement` computes the same metric locally. --- *Related: `@content/web/huggingface/2026-11-27-model-managed-context-nvidia-harness` · `@content/web/github/2026-11-26-opus-context-fills-faster-issue-112194` · `@protocol/bootstrap-core` · `@protocol/memento` · `@content/youtube/nate-herk/this-ai-technology-will-replace-millions-heres-how-to-prepare`* --- *You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).* *Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*