A practical guide to where the money actually goes when you code with an Anthropic-powered AI agent — and the handful of settings that decide whether 1,000 turns of work costs you $37 or $550. The general lesson — smaller context is cheaper than a giant re-read every turn — applies broadly, but the cache-write premiums, 5-minute cache TTL, keep-warm heartbeat and shared-prefix savings in this guide are mostly Anthropic-specific. OpenAI, Gemini and xAI use different caching economics, so they do not need the same keep-warm strategy. None of this is guesswork: to find what actually drives the bill, we went back through our own usage — more than 340,000 messages across 600+ real coding sessions — and measured it. Skim the five-step short version below, or read on for why each one holds.
An LLM has no memory between turns. To "remember" the conversation, the entire history is re-sent on every turn. Prompt caching makes those re-sent tokens cheap — they bill at the cache-read rate (~10% of input) instead of full price — but cheap is not free. You still pay to re-read the whole prefix, every turn, and that bill grows with the conversation.
Here is the same turn, mid-conversation, in a small-window chat vs a large-window chat. Only one line changes:
Summarizing is what resets that re-read tax: it collapses 160k of history back down to a 3k summary, so the next 29 turns re-read a small prefix again. And the summary itself is cheap — a few cents per collapse (often free; see §4). The re-read tax, by contrast, is paid on every one of the 157 turns between summaries. That asymmetry — cheap-and-occasional vs small-but-relentless — is why avoiding summaries to "save money" backfires.
A summary is one extra model call that fires when your context fills up. Two things set the price — which summarizer you pick, and where you set the trigger:
Here is the cost of one single summary, by window size and where you trigger it, with Pre-compute summaries in background OFF (one call at the threshold) vs ON (rewritten after every message):
| Window | Trigger | ≈ Context | Pre-compute OFF | Pre-compute ON |
|---|---|---|---|---|
| 200k | 40% | 80k | $0.017 | $0.038 |
| 50% recommended | 100k | $0.017 | $0.038 | |
| 60% | 120k | $0.018 | $0.057 | |
| 70% | 140k | $0.018 | $0.057 | |
| 80% | 160k | $0.019 | $0.076 | |
| 90% | 180k | $0.019 | $0.076 | |
| 272k | 40% ≈100k | 109k | $0.017 | $0.038 |
| 50% | 136k | $0.018 | $0.057 | |
| 60% | 163k | $0.019 | $0.076 | |
| 70% | 190k | $0.019 | $0.076 | |
| 80% | 218k | $0.020 | $0.095 | |
| 90% | 245k | $0.021 | $0.114 | |
| 1M | 40% | 400k | $0.025 | $0.190 |
| 50% | 500k | $0.027 | $0.228 | |
| 60% | 600k | $0.030 | $0.285 | |
| 70% | 700k | $0.032 | $0.323 | |
| 80% | 800k | $0.035 | $0.380 | |
| 90% | 900k | $0.037 | $0.418 |
The sweet spot is a token count, not a percentage: aim to summarize around 100k of context. That's 50% of a 200k window, ~40% of a 272k window, and only ~10% of a 1M window — which is why a big window left at a high % gets pricey. Two patterns to read off the table: the OFF column barely moves (it's a single call no matter how full you let it get), while the ON column climbs steadily, because pre-compute rewrites the summary after every message and a higher trigger stacks up more messages before it fires. At the recommended ~100k it's under 4¢ a summary either way — cheap enough to leave pre-compute on for the instant turns.
This is the knob you actually control: how full does the context get before we compress. Those last figures were single-turn and single-summary snapshots. The chart below is the real thing — we replayed 52,321 actual turns from 219 of our own real coding conversations through the exact prices we get billed at, sweeping the summarize threshold from 50k all the way to a 1M window. y-axis is the all-in cost to drive 1,000 turns; the x-axis is where you set the trigger. Three curves show the same sweep under three assumptions for the floor (how big the prefix is right after a summary: system prompt + tools + the ~3k bridge + pins) — because that floor, not the threshold, is the real driver, and it depends on your prompt and tool set.
Here is the full data behind the chart — every point, all three floor assumptions — so you can read your own setup off it instead of trusting our headline. ($ per 1,000 turns; the cheapest threshold for each floor is highlighted.)
| Threshold X | floor 22k | floor 28k | floor 35k |
|---|---|---|---|
| 50k | $36.56 best | $40.43 best | $47.54 |
| 100k | $39.84 | $41.38 | $43.27 best |
| 150k | $46.12 | $47.28 | $48.63 |
| 200k | $52.62 | $53.55 | $54.63 |
| 250k | $59.31 | $59.96 | $61.25 |
| 300k | $65.96 | $66.68 | $67.58 |
| 350k | $71.93 | $72.52 | $73.76 |
| 400k | $78.23 | $79.03 | $79.41 |
| 450k | $84.59 | $84.89 | $85.77 |
| 500k | $89.61 | $90.21 | $91.23 |
| 550k | $95.83 | $96.53 | $97.16 |
| 600k | $101.14 | $101.82 | $102.31 |
| 650k | $105.67 | $106.19 | $106.87 |
| 700k | $110.19 | $111.02 | $111.87 |
| 750k | $116.20 | $116.65 | $117.10 |
| 800k | $120.99 | $121.49 | $122.48 |
| 850k | $126.10 | $126.71 | $127.32 |
| 900k | $130.26 | $130.94 | $131.88 |
| 950k | $134.53 | $134.86 | $135.42 |
| 1M | $139.63 | $140.08 | $140.57 |
| never summarize | $550.71 | $550.71 | $550.71 |
A note on the absolute numbers: these are averages across every conversation we looked at, and most real chats are short and never reach a high threshold — which is why the averages here sit below the single deep-turn example in §1–2. Don't anchor on the exact dollars; anchor on the shape, which never changes: cheap on the left, a steady climb to the right, and a cliff if you never compress at all.
The summary is produced by a separate model call — it can't share the chat's cache, so its cost is real and was easy to overlook. Two knobs decide how much it adds: which model writes the summary, and how often it fires.
| Summary model | Pre-compute | All-in $/turn · 200k | All-in $/turn · 1M | Summary's own cost / collapse · 1M |
|---|---|---|---|---|
| Local model | either | $0.067 | $0.178 | $0.00 — free |
| Haiku (cloud) | off | $0.068 | $0.178 | $0.04 |
| Haiku (cloud) | on | $0.070 | $0.180 | $0.42 (22 fires) |
| Sonnet (flagship) | off | $0.069 | $0.178 | $0.11 |
| Sonnet (flagship) | on | $0.075 | $0.185 | $1.25 (22 fires) |
Reading that table: the two all-in $/turn columns are the cost of the entire turn — almost all of it your main coding model re-reading context, which you pay no matter who summarizes — so they barely budge between rows. The summarizer only moves the last column. That's why the local-model row still shows ~$0.067 / ~$0.178: those are what the coding model charges to do the work; the summary itself is genuinely free ($0.00, last column).
But before you go unchecking it: 11× cheaper than what, and is it worth the wait? A summary's cost rides on how many user messages piled up before the window filled — and that scales with your threshold. At a small threshold an epoch holds only a message or two, so there's almost nothing to save. Here's the real cost of one compaction, with the Haiku summarizer, at the thresholds you'd actually pick:
| Summarize at… | Pre-compute OFF | Pre-compute ON | You save / compaction |
|---|---|---|---|
| 50k | $0.016 | $0.019 | $0.003 · 1.2× |
| 100k (recommended) | $0.017 | $0.038 | ~$0.02 · 2.2× |
| 500k | $0.027 | $0.23 | $0.20 · 8.4× |
| 900k (near max) | $0.037 | $0.42 | $0.38 · 11× |
Tempting: no summarizer cost, no compression loss. But the re-read tax tells you the answer before you run it. The cost of a big chat isn't the summary — it's re-reading the giant prefix every turn, which you pay whether you summarize or not.
| Strategy | $/turn | $/1,000 turns | Continuity |
|---|---|---|---|
| 200k + summarize | $0.070 | $70 | 3k bridge carried forward |
| 1M @ 90% + summarize | $0.180 | $180 | 3k bridge carried forward |
| Run to 900k, never summarize, new chat | $0.177 | $177 | total amnesia — 0 handoff |
Keep-warm is a provider-specific optimization, not a universal one. It matters when a provider charges extra to write a cache entry, then expires that entry quickly unless you refresh it. Of the four major providers we compared, Anthropic is the only one with both halves of that cost structure: a paid write premium and a short 5-minute message-cache TTL.
| Provider | Write premium? | Guaranteed TTL | Free retention window | Keep-warm verdict |
|---|---|---|---|---|
| Anthropic | Yes (1.25–2×) | 5 min | None | ON — real savings |
| OpenAI | No | Up to 24h | 1–24h free retention | OFF — cache already persists |
| Gemini | No | None guaranteed | Implicit / best-effort | OFF — net-negative gamble |
| xAI | No visible premium | n/a | n/a | OFF — no premium to dodge |
We measured the gaps in the real history, not a synthetic trace: every conversation database on the machine, 90 databases covering 3,142 conversations and 447,321 assistant turns over 125 days. The surprising part was where cold-cache returns came from. It was not mostly slow shell commands. It was ordinary human time: reading a diff, answering Slack, getting coffee, or just thinking.
A cold return is expensive because the token mix flips. In the trace we inspected, a normal warm turn read about 86k cached tokens and wrote only ~1.1k new tokens. The turn after a five-minute-plus gap read almost nothing from cache and wrote about 93k tokens — the whole conversation rebuilt from cold. On Anthropic Opus pricing at the time, cache read was $0.50/M, fresh input was $5.00/M, and 5-minute cache write was $6.25/M: a read was about one-twelfth the price of a write.
We tried that first, and it looked great on paper: trade the 5-minute message cache for a 1-hour cache and rescue human pauses automatically. The catch is that Anthropic's 1-hour write cost was higher ($10/M vs $6.25/M), so the blanket version taxes every ordinary warm turn too. In the replay, that added +$2,609 on healthy turns while rescuing only -$1,137 of cold idle rewrites; another +$234 was wasted on returns cold for over an hour, which a one-hour cache could not help anyway.
On Anthropic, your conversation's message cache expires after 5 minutes (the system prompt and tools live a full hour — that's the shared prefix in §7). If even that message cache lapses while you're away, the history must be re-written on your return — the expensive write tier. To dodge that, the keep-warm heartbeat quietly re-reads the cached history every few minutes (the cheap read tier, ~12× cheaper than a rewrite), nudging the 5-minute timer forward — but only up to a point.
And the bigger the Anthropic context, the more even those cheap reads add up while you're away — priced at a mid-tier (Sonnet-class) read rate: a 160k chat burns about $0.58/hr idle, an 800k chat about $2.88/hr doing nothing (roughly 1.7× those on a flagship model). One more reason to keep context small.
What shipped is intentionally boring: a Keep Warm toggle and a small fuse indicator under the context meter. Flip it on for Anthropic, and FrankenCoder quietly spends cheap reads during normal pause-length gaps, then lets the cache lapse on long absences instead of bleeding heartbeats forever.
The cost dashboard keeps it honest. In this captured workspace, Keep Warm is just 0.4% of the bill while protecting a 43.5% prompt-cache hit rate.
Two things sit at the very bottom of every request and never change between turns: the system prompt (instructions + standing orders + read-only workspace context) and the tool definitions (the schema for every tool the agent can call). Together they're a large, fixed block. FrankenCoder builds it to be byte-identical across every chat — no conversation name, no timestamp baked in — and caches it with a 1-hour TTL, twelve times longer than the 5-minute message cache.
Because the bytes are identical, that cache entry is shared across your chats. Warm it once — just by using the agent — and for the next hour every new chat you open finds its system prompt and tools already cached: you pay the cheap read rate (~10%) on that whole block instead of a cold write, on the very first turn of each new conversation. Open ten chats in an hour and nine of them skip rewriting the prefix entirely.
So, to actually bank the discount: pick an Anthropic model and stay on it across the chats you open in a session — model-hopping re-pays the cold prefix on every switch. This one needs no toggle and no summarizer; it's just free, as long as you don't change models. (The 5-minute message cache from §6 is the part the keep-warm heartbeat protects; this 1-hour system+tools prefix is the cross-chat freebie underneath it.)
Summarize around 80–100k of context · local-model summaries · one model per session · Anthropic keep-warm capped at ~30 min. Smallest re-read tax, free summaries, a warm system+tools prefix shared across all your chats, and heartbeats only where they avoid a paid short-TTL rewrite.
At the recommended 80–100k threshold, unchecking "Pre-compute summaries in background" saves only ~2¢ per compaction — keep it on for instant turns. It only pays off (toward ~11×, 20–40¢ each) if you deliberately run very large windows.
A continuity feature, not a savings feature. Reach for it only when an uninterrupted reasoning chain matters more than the ~3× per-turn cost.
How we know this. These numbers aren't hypotheticals. We went back through our own usage — more than 340,000 messages across 600+ real coding sessions — and replayed tens of thousands of those turns through the exact prices we actually get billed at, so what you see here reflects real work, not a toy model. The single-turn walkthroughs in §1–2 follow one deep conversation so you can watch the mechanism turn by turn; the §3 chart averages the whole pile of real sessions — most of which are short — so the dollars there come out lower, but the re-read-tax shape is exactly the same. Your own bill will shift with which model you run and how tool-heavy your work is, but the ratios — and the settings that move them — hold.