Follow Discord
Sweep 10 Nov 2026 · 02:18Z Build v2.1.322 539 read Stable v2.1.311 Latest v2.1.322 Next v2.1.322 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

optimizing-for-cost-and-intelligence changedabout-claude/models/optimizing-for-cost-and-intelligence

Recorded here
Lines+6added
Lines−6removed
From line 192 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits37to this page, all time

The whole hunk

from line 192, old and new numbered
/
lines
from line 192
192192 
193193#### What breaks the cache
194194 
195Put per-request text, such as a status line, at the end of the newest user turn, after the last cache breakpoint. On later requests, leave each earlier turn as you sent it, with its old status line still in it. Make cache-invalidating changes at a natural break, such as the first request after a compaction. On models that run the [prefix check](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking#prefix-check), a request that edits the system prompt or `tools` can get a 400 error even at such a break. Send those changes in `messages` instead, where your platform supports it (see [Make changes without editing the prefix](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking#replace-prefix-edits)). The cache is a byte-exact prefix match over the request in order (tools, then system prompt, then messages), so a change anywhere invalidates everything after it.
195Put per-request text, such as a status line, at the end of the newest user turn, after the last cache breakpoint. On later requests, leave each earlier turn as you sent it, with its old status line still in it. Make cache-invalidating changes at a natural break, such as the first request after a compaction. On [models that run the prefix check](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking/prefix-checks#enforcement), a request that edits the system prompt or `tools` can get a [400 error](https://platform.claude.com/docs/en/api/errors#thinking-block-conversation-mismatch) even at such a break. Send those changes in `messages` instead, where your platform supports it (see [Change tools or instructions without failing the prefix check](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking/change-tools-or-instructions)). The cache is a byte-exact prefix match over the request in order (tools, then system prompt, then messages), so a change anywhere invalidates everything after it.
196196 
197197When something must change mid-conversation, send it in the form that keeps the cache, where the model supports it. Anthropic tested each change both ways on Claude Fable 5.1, Claude Opus 5.5, and Claude Sonnet 5.5, on a cached conversation of about 100,000 tokens that held the model’s first reply with its thinking. Editing the system prompt cost about 25 to 50 times what the same text cost as a mid-conversation system message. Changing effort at the top level cost 20 to 40 times what changing it in a message cost<sup>[18](https://platform.claude.com/docs/en/about-claude/models/optimizing-for-cost-and-intelligence#refs)</sup>:
198198 
from line 202
202202 
203203When a change invalidates the cache, the part of the prefix it affects is written again instead of read. A write to the 5-minute cache costs 1.25x the input price, and a cache read costs a small fraction of the input price. At list prices, that write costs 50 times a read on Claude Fable 5.2, Claude Mythos 5.2, Claude Fable 5.1, and Claude Mythos 5.1, where a cache read costs 0.025x the input price. That write costs 25 times a read on Claude Opus 5.5 and Claude Sonnet 5.5 (0.05x), and 12.5 times on Claude Haiku 5.5 (0.1x). The chart’s figures are from the Messages API.
204204 
205A request that edits the system prompt or `tools` can also fail outright. On models that run the [prefix check](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking#prefix-check), a request that makes either edit and sends earlier thinking blocks back can get a 400 error<sup>[18](https://platform.claude.com/docs/en/about-claude/models/optimizing-for-cost-and-intelligence#refs)</sup>. In a separate Anthropic test, waiting for a compaction didn’t avoid the error: on Claude Opus 5.5 and Claude Fable 5.2, such a request still got it as the first request after a compaction at a token threshold<sup>[18](https://platform.claude.com/docs/en/about-claude/models/optimizing-for-cost-and-intelligence#refs)</sup>. By default on the Claude API, a request that fails the check gets the error on every account if the model is Claude Fable 5.2, Claude Mythos 5.2, or Claude Mythos 5.1. If the model is Claude Fable 5.1, Claude Opus 5.5, Claude Sonnet 5.5, or Claude Haiku 5.5, the request gets the error on some accounts and no error on others. For the outcomes by model and account, see [When `prefix_mismatch_behavior` is unset](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking#enforcement).
205In a separate Anthropic test on Claude Opus 5.5 and Claude Fable 5.2, requests that edited the system prompt or `tools` and sent earlier thinking blocks back still got the 400 error. They got it even as the first request after a compaction at a token threshold<sup>[18](https://platform.claude.com/docs/en/about-claude/models/optimizing-for-cost-and-intelligence#refs)</sup>.
206206 
207207**What to do.**
208208 
from line 211
211211* Check which models support each form: [mid-conversation system messages](https://platform.claude.com/docs/en/build-with-claude/mid-conversation-system-messages), and [per-message effort](https://platform.claude.com/docs/en/build-with-claude/effort-per-message), which is in beta.
212212* After a cache-invalidating change, confirm cache reads have not dropped; if they have, [cache diagnostics](https://platform.claude.com/docs/en/build-with-claude/cache-diagnostics) shows where the prefix diverged.
213213 
214On an earlier model, Anthropic measured when to make such a change, on long sessions of the issue-triage agent described in [Trim input and context tokens](https://platform.claude.com/docs/en/about-claude/models/optimizing-for-cost-and-intelligence#trim-input-and-context-tokens)<sup>[18](https://platform.claude.com/docs/en/about-claude/models/optimizing-for-cost-and-intelligence#refs)</sup>. The sessions that made changes started at low effort, then switched to the default effort and added one tool. Making the two changes mid-session cost the most. Making them on the request that triggered the compaction cost nearly as much, because that request still carried the whole conversation and wrote it to the cache again. Making them on the next request, the first after the compaction, cost the least. Accuracy was within run-to-run noise. That model doesn’t run the prefix check. On a model that does, add the tool in a message instead: see [Add or remove tools with `tool_addition` and `tool_removal`](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking#tool-changes), which is in beta. The following chart also shows sessions with no changes. They aren’t a like-for-like baseline, because they ran at the default effort throughout and two of them compacted a second time:
214On an earlier model, Anthropic measured when to make such a change, on long sessions of the issue-triage agent described in [Trim input and context tokens](https://platform.claude.com/docs/en/about-claude/models/optimizing-for-cost-and-intelligence#trim-input-and-context-tokens)<sup>[18](https://platform.claude.com/docs/en/about-claude/models/optimizing-for-cost-and-intelligence#refs)</sup>. The sessions that made changes started at low effort, then switched to the default effort and added one tool. Making the two changes mid-session cost the most. Making them on the request that triggered the compaction cost nearly as much, because that request still carried the whole conversation and wrote it to the cache again. Making them on the next request, the first after the compaction, cost the least. Accuracy was within run-to-run noise. That model doesn’t run the prefix check. On a model that does, add the tool in a message instead: see [Add, remove, or turn off tools](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking/change-tools-or-instructions#tool-changes), which is in beta. The following chart also shows sessions with no changes. They aren’t a like-for-like baseline, because they ran at the default effort throughout and two of them compacted a second time:
215215 
216216<Frame>
217217 ![Bar chart, cost per triage session: $0.81 USD no changes, $0.95 USD mid-session, $0.92 USD at compaction, $0.75 USD after](https://platform.claude.com/docs/images/cost-intel/compaction-timing.svg)
from line 277
277277* If you use context editing, [clear in a few large batches](https://platform.claude.com/docs/en/build-with-claude/context-editing#context-editing-and-prompt-caching), because each clear costs a cache write.
278278 
279279<Note>
280 Don’t use the prune on Claude Fable 5.2, Claude Mythos 5.2, Claude Fable 5.1, Claude Mythos 5.1, Claude Opus 5.5, Claude Sonnet 5.5, or Claude Haiku 5.5. On these models, if your application rewrites an earlier tool result, that invalidates every thinking block already in the history after the result (see [Keeping the prefix unchanged](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking#prefix-check)), and the request might fail (see [When `prefix_mismatch_behavior` is unset](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking#enforcement)). The prune was measured on an earlier model without [preserved thinking](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking). Use [compaction](https://platform.claude.com/docs/en/build-with-claude/compaction) instead: in the same test, it also cut the cost of the long run. Compaction and [context editing](https://platform.claude.com/docs/en/build-with-claude/context-editing) both run on the server, so neither invalidates thinking blocks. [Send assistant turns back exactly as returned](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking#append-assistant-turns-exactly-as-returned): dropping their thinking blocks costs output tokens on every turn, because Claude [re-creates the reasoning](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking#drop-block-cost).
280 Don’t use the prune on Claude Fable 5.2, Claude Mythos 5.2, Claude Fable 5.1, Claude Mythos 5.1, Claude Opus 5.5, Claude Sonnet 5.5, or Claude Haiku 5.5. On these models, if your application rewrites an earlier tool result, that invalidates every thinking block already in the history after the result (see [What must stay the same, and why](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking/prefix-checks#prefix-check)), and the request might fail (see [What each model does when the prefix check fails](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking/prefix-checks#outcomes)). The prune was measured on an earlier model without [preserved thinking](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking). Use [compaction](https://platform.claude.com/docs/en/build-with-claude/compaction) instead: in the same test, it also cut the cost of the long run. Compaction and [context editing](https://platform.claude.com/docs/en/build-with-claude/context-editing) both run on the server, so neither invalidates thinking blocks. [Send assistant turns back exactly](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking/change-tools-or-instructions#append-assistant-turns-exactly-as-returned): dropping their thinking blocks costs output tokens on every turn, because Claude [re-creates the reasoning](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking/fix-bound-to-a-different-conversation#drop-block-cost).
281281</Note>
282282 
283283### Batch work that can wait
from line 1011
10111011 
10121012 * **October 2026 test, one change to a long conversation:** Measured October 20, 2026, on Claude Fable 5.1, Claude Opus 5.5, Claude Sonnet 5.5, and Claude Haiku 5.5, on the Messages API with no tools, adaptive thinking, each model’s default effort, the 5-minute cache, a cache breakpoint on the system prompt, and [automatic caching](https://platform.claude.com/docs/en/build-with-claude/prompt-caching#automatic-caching). The conversation held about 101,000 tokens: a 20,000-token system prompt, 13 user turns of filler text, the model’s own reply to the first turn with its thinking block, and one-word replies to the rest. Once one request had cached the conversation, a second added one short turn, and each measured request sent that longer conversation with one change. Two conversations per model gave the same result.
10131013 * **October 2026 test, tokens read and written:** With no change, and with a per-message effort change, the request read all 101,000 tokens and wrote none. With a 25-token mid-conversation system message, or a 25-token status line at the end of the newest user turn, it read them all and wrote only the new text. A top-level effort change (to `low` on Claude Fable 5.1 and Claude Sonnet 5.5, to `high` on Claude Opus 5.5 and Claude Haiku 5.5) read the 20,000-token system prompt and wrote 81,000 tokens. The same 25 tokens at the front or the end of the system prompt read nothing and wrote all 101,000. The request after a mid-conversation system message, a top-level effort change, or 25 tokens added to the end of the system prompt read the new prefix; a new status line at the front wrote everything again. A further test on October 21, 2026, on the same four models with conversations of 5,000 tokens, and on all but Claude Fable 5.1 with conversations of 100,000 tokens, all with one-word replies, sent a beta header for the first time mid-conversation, as a first per-message effort change may: that request read everything the request before it had cached, all 54 times. A system message sent with no beta header did the same, all 15 times.
1014 * **October 2026 test, how priced:** The chart gives the prompt side of one request, from its `usage` fields at list prices. The chart’s values, in the order system prompt edit, system message, top-level effort change, and per-message effort change: Claude Fable 5.1 $1.26 USD, $0.026 USD, $1.02 USD, and $0.025 USD; Claude Opus 5.5 $0.50 USD, $0.020 USD, $0.41 USD, and $0.020 USD; Claude Sonnet 5.5 $0.25 USD, $0.010 USD, $0.20 USD, and $0.010 USD. The unchanged request repeated an earlier request byte for byte; a new turn of about 25 tokens adds under $0.001 USD. On Claude Haiku 5.5, whose requests were over 100,000 prompt tokens and so at its [long context prices](https://platform.claude.com/docs/en/about-claude/pricing#long-context-pricing): $0.063 USD for the system prompt edit, $0.052 USD for the effort change, and $0.005 USD for the read. The requests ran on an Anthropic-internal organization whose usage is metered the same way as a customer organization’s. For that organization, the API lets failing thinking blocks through when a request leaves `prefix_mismatch_behavior` unset, so the system prompt edits in these tests were accepted. On an account created on or after August 31, 2026, 00:00 UTC, the same edit gets a 400 error on all four models, because each request sends an earlier thinking block back.
1015 * **November 2026 test, edits after a compaction:** Run November 9, 2026, on Claude Opus 5.5 and Claude Fable 5.2, on the Messages API with adaptive thinking, `high` effort, no caching, one tool defined, `tool_choice` set to `none`, [`prefix_mismatch_behavior`](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking#mismatch-behavior) set to `"error"`, and [compaction at a token threshold](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold) with a trigger of 50,000 tokens. A first request of about 55,700 tokens triggered a compaction, and its reply held a compaction block followed by a thinking block. The next request sent that reply back with one new user turn. Unchanged, it succeeded. With one tool added to `tools`, or with the system prompt reworded, it got the 400 error. In a conversation with no compaction, the same two edits got the 400 error, and so did removing a text block from an earlier user turn. One conversation of each kind per model. On Claude Fable 5.2, the first large conversation’s reply held no thinking block. A second conversation replaced the first, with a harder question, a higher `max_tokens`, and custom compaction `instructions`, and only the second counts. The requests ran on the Claude API.
1014 * **October 2026 test, how priced:** The chart gives the prompt side of one request, from its `usage` fields at list prices. The chart’s values, in the order system prompt edit, system message, top-level effort change, and per-message effort change: Claude Fable 5.1 $1.26 USD, $0.026 USD, $1.02 USD, and $0.025 USD; Claude Opus 5.5 $0.50 USD, $0.020 USD, $0.41 USD, and $0.020 USD; Claude Sonnet 5.5 $0.25 USD, $0.010 USD, $0.20 USD, and $0.010 USD. The unchanged request repeated an earlier request byte for byte; a new turn of about 25 tokens adds under $0.001 USD. On Claude Haiku 5.5, whose requests were over 100,000 prompt tokens and so at its [long context prices](https://platform.claude.com/docs/en/about-claude/pricing#long-context-pricing): $0.063 USD for the system prompt edit, $0.052 USD for the effort change, and $0.005 USD for the read. The requests ran on an Anthropic-internal organization whose usage is metered the same way as a customer organization’s. The requests left `prefix_mismatch_behavior` unset, and the API let their failing thinking blocks through, so it accepted the system prompt edits in these tests. Each request sent an earlier thinking block back. On the Claude API, the same edit can get a 400 error on all four models. See [Prefix checks on thinking blocks](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking/prefix-checks).
1015 * **November 2026 test, edits after a compaction:** Run November 9, 2026, on Claude Opus 5.5 and Claude Fable 5.2, on the Messages API with adaptive thinking, `high` effort, no caching, one tool defined, `tool_choice` set to `none`, [`prefix_mismatch_behavior`](https://platform.claude.com/docs/en/build-with-claude/preserved-thinking/prefix-checks#mismatch-behavior) set to `"error"`, and [compaction at a token threshold](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold) with a trigger of 50,000 tokens. A first request of about 55,700 tokens triggered a compaction, and its reply held a compaction block followed by a thinking block. The next request sent that reply back with one new user turn. Unchanged, it succeeded. With one tool added to `tools`, or with the system prompt reworded, it got the 400 error. In a conversation with no compaction, the same two edits got the 400 error, and so did removing a text block from an earlier user turn. One conversation of each kind per model. On Claude Fable 5.2, the first large conversation’s reply held no thinking block. A second conversation replaced the first, with a harder question, a higher `max_tokens`, and custom compaction `instructions`, and only the second counts. The requests ran on the Claude API.
10161016 * **What was measured:** The triage agent’s long variant from [Trim input and context tokens](https://platform.claude.com/docs/en/about-claude/models/optimizing-for-cost-and-intelligence#trim-input-and-context-tokens), run August 24, 2026, on Claude Sonnet 5 with the 5-minute cache, cost from the usage fields at list prices, five sessions per arm: a no-change arm at the default effort throughout ($0.81 USD per session), and two arms that start at low effort and make the same two cache-breaking changes, a switch to the default effort and one added tool, either mid-session at requests 12 and 17 ($0.95 USD) or together on the first request after the first compaction ($0.75 USD).
10171017 * **Fourth arm:** A fourth arm of six sessions, run August 25, 2026, made the same two changes on the request that triggered the first compaction ($0.92 USD per session): that request’s summarization pass wrote the 81,000-token context to the cache instead of reading it, so that pass cost $0.21 USD against $0.04 USD for the same pass in the boundary arm.
10181018 * **Compaction:** Sessions first compacted at request 21 to 25 (16 of the 21 sessions at request 22), once the prompt passed the 80,000-token compaction trigger, and two no-change sessions compacted a second time near the end. The boundary arm’s lower total than the no-change arm reflects its low-effort requests before the change and those second compactions rather than caching: the two arms’ re-write costs differ by under $0.01 USD.
Feedback