Follow Discord
Sweep 22 Oct 2026 · 04:32Z Build v2.1.308 527 read Stable v2.1.308 Latest v2.1.308 Next v2.1.308 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

compaction-threshold changedbuild-with-claude/compaction-threshold

Nearest release: v2.1.307, published an hour after this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Recorded here
Lines+17added
Lines−17removed
From line 263 where the diff opens
First seen 21 Sep 2026 this site's first read of the page
Recorded edits15to this page, all time

The whole hunk

from line 263, old and new numbered
/
lines
from line 263
263263 
264264 response = client.beta.messages.create(
265265 betas: ["compact-2026-01-12"],
266 model: "claude-opus-5-5",
266 model: Anthropic::Model::CLAUDE_OPUS_5_5,
267267 max_tokens: 4096,
268268 messages: messages,
269269 context_management: {
from line 483
483483 
484484 response = client.beta.messages.create(
485485 betas: ["compact-2026-01-12"],
486 model: "claude-opus-5-5",
486 model: Anthropic::Model::CLAUDE_OPUS_5_5,
487487 max_tokens: 4096,
488488 messages: messages,
489489 context_management: {
from line 704
704704 
705705 response = client.beta.messages.create(
706706 betas: ["compact-2026-01-12"],
707 model: "claude-opus-5-5",
707 model: Anthropic::Model::CLAUDE_OPUS_5_5,
708708 max_tokens: 4096,
709709 messages: [
710710 { role: "user", content: "Help me build a Python web scraper" },
from line 1037
10371037 
10381038 response = client.beta.messages.create(
10391039 betas: ["compact-2026-01-12"],
1040 model: "claude-opus-5-5",
1040 model: Anthropic::Model::CLAUDE_OPUS_5_5,
10411041 max_tokens: 4096,
10421042 messages: messages,
10431043 context_management: {
from line 1055
10551055 
10561056 response = client.beta.messages.create(
10571057 betas: ["compact-2026-01-12"],
1058 model: "claude-opus-5-5",
1058 model: Anthropic::Model::CLAUDE_OPUS_5_5,
10591059 max_tokens: 4096,
10601060 messages: messages,
10611061 context_management: {
from line 1070
10701070 
10711071#### Enforcing a total token budget
10721072 
1073When a model works on long tasks with many tool-use iterations, total token consumption can grow significantly. You can combine `pause_after_compaction` with a compaction counter to estimate cumulative usage and gracefully wrap up the task once a budget is reached.
1073When a model works on long tasks with many tool-use iterations, total token consumption can grow significantly. You can combine `pause_after_compaction` with a compaction counter to estimate cumulative usage and gracefully end the task once a budget is reached.
10741074 
10751075This example appears in the SDK languages only: its value is the budget-tracking logic around the request. The raw request combines the `trigger` from [Trigger configuration](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold#trigger-configuration) with `pause_after_compaction` from [Pausing after compaction](https://platform.claude.com/docs/en/build-with-claude/compaction-threshold#pausing-after-compaction).
10761076 
from line 1330
13301330 
13311331 response = client.beta.messages.create(
13321332 betas: ["compact-2026-01-12"],
1333 model: "claude-opus-5-5",
1333 model: Anthropic::Model::CLAUDE_OPUS_5_5,
13341334 max_tokens: 4096,
13351335 messages: messages,
13361336 context_management: {
from line 1617
16171617 
16181618 response = client.beta.messages.create(
16191619 betas: ["compact-2026-01-12"],
1620 model: "claude-opus-5-5",
1620 model: Anthropic::Model::CLAUDE_OPUS_5_5,
16211621 max_tokens: 4096,
16221622 messages: messages,
16231623 context_management: {
from line 1631
16311631 
16321632 next_response = client.beta.messages.create(
16331633 betas: ["compact-2026-01-12"],
1634 model: "claude-opus-5-5",
1634 model: Anthropic::Model::CLAUDE_OPUS_5_5,
16351635 max_tokens: 4096,
16361636 messages: messages,
16371637 context_management: {
from line 1648
16481648When the API receives a `compaction` block, all content blocks before it are ignored. You can either:
16491649 
16501650* Keep the original messages in your list and let the API handle removing the compacted content
1651* Manually drop the compacted messages and only include the compaction block onwards
1651* Manually drop the compacted messages and only include the compaction block onward
16521652 
16531653On Claude Fable 5.1, Claude Mythos 5.1, Claude Opus 5.5, Claude Sonnet 5.5, and Claude Haiku 5.5, thinking blocks from before a `compaction` block aren't carried forward, so the summary is all the model has of that earlier work. If you write your own `instructions`, tell the model what the summary must retain; see [Tell the model what to preserve in compaction summaries](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-fable-5-1#tell-the-model-what-to-preserve-in-compaction-summaries).
16541654 
from line 1959
19591959 
19601960 stream = client.beta.messages.stream(
19611961 betas: ["compact-2026-01-12"],
1962 model: "claude-opus-5-5",
1962 model: Anthropic::Model::CLAUDE_OPUS_5_5,
19631963 max_tokens: 4096,
19641964 messages: messages,
19651965 context_management: {
from line 2229
22292229 
22302230 response = client.beta.messages.create(
22312231 betas: ["compact-2026-01-12"],
2232 model: "claude-opus-5-5",
2232 model: Anthropic::Model::CLAUDE_OPUS_5_5,
22332233 max_tokens: 4096,
22342234 system: [
22352235 {
from line 2454
24542454 
24552455 count_response = client.beta.messages.count_tokens(
24562456 betas: ["compact-2026-01-12"],
2457 model: "claude-opus-5-5",
2457 model: Anthropic::Model::CLAUDE_OPUS_5_5,
24582458 messages: messages,
24592459 context_management: {
24602460 edits: [{ type: "compact_20260112" }]
from line 2740
27402740 
27412741 response = client.beta.messages.create(
27422742 betas: ["compact-2026-01-12"],
2743 model: "claude-opus-5-5",
2743 model: Anthropic::Model::CLAUDE_OPUS_5_5,
27442744 max_tokens: 4096,
27452745 messages: messages,
27462746 context_management: {
from line 3300
33003300 
33013301 response = client.beta.messages.create(
33023302 betas: ["compact-2026-01-12"],
3303 model: "claude-opus-5-5",
3303 model: Anthropic::Model::CLAUDE_OPUS_5_5,
33043304 max_tokens: 4096,
33053305 messages: messages,
33063306 context_management: {
from line 3331
33313331 
33323332 response = client.beta.messages.create(
33333333 betas: ["compact-2026-01-12"],
3334 model: "claude-opus-5-5",
3334 model: Anthropic::Model::CLAUDE_OPUS_5_5,
33353335 max_tokens: 4096,
33363336 messages: messages_after_compaction,
33373337 context_management: {
from line 3375
33753375 Learn about context window sizes and management strategies.
33763376 </Card>
33773377 
3378 <Card title="Session memory compaction cookbook" icon="book" href="https://platform.claude.com/cookbook/misc-session-memory-compaction">
3378 <Card title="Session memory compaction recipe" icon="book" href="https://platform.claude.com/cookbook/misc-session-memory-compaction">
33793379 Explore a practical implementation that manages long-running conversations with instant session memory compaction using background threading and prompt caching.
33803380 </Card>
33813381</CardGroup>
Feedback