Sweep 22 Sep 2026 · 17:19Z Build v2.1.280 501 read Stable v2.1.267 Latest v2.1.280 Next v2.1.280 Feeds RSS JSON llms.txt Unofficial
One change · api

compaction-threshold changed

build-with-claude/compaction-threshold

Nearest release: v2.1.280, published 15 hours 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+26added
Lines−7removed
From line 2 where the diff opens
First seen 21 Sep 2026 this site's first read of the page
Recorded edits3to this page, all time

## Compatibility

The whole hunk

from line 2, old and new numbered
/
lines
from line 2
22title: Compaction at a token threshold
33url: https://platform.claude.com/docs/en/build-with-claude/compaction-threshold
44description: Have the API summarize older context automatically, inside an ordinary request, when the conversation reaches a token threshold you set.
5featureMetadata:
6 status: beta
7 betaHeader: compact-2026-01-12
8 zdr:
9 eligibility: eligible
10 note: Excludes [Covered Models](https://platform.claude.com/docs/en/manage-claude/api-and-data-retention#model-specific-data-retention-requirements).
11 supportedModels:
12 - claude-fable-5-1
13 - claude-mythos-5-1
14 - claude-fable-5
15 - claude-mythos-5
16 - claude-mythos-preview
17 - claude-opus-5
18 - claude-opus-4-8
19 - claude-opus-4-7
20 - claude-opus-4-6
21 - claude-sonnet-5
22 - claude-sonnet-4-6
23 supportedPlatforms:
24 Claude API: beta
25 Claude Platform on AWS: beta
26 Amazon Bedrock: beta
27 Google Cloud: beta
28 Microsoft Foundry: beta
529---
630 
7## Compatibility
8- Status: Beta
9- [Beta header](https://platform.claude.com/docs/en/api/beta-headers): `compact-2026-01-12`
10- [ZDR](https://platform.claude.com/docs/en/manage-claude/api-and-data-retention): eligible (excludes [Covered Models](https://platform.claude.com/docs/en/manage-claude/api-and-data-retention#model-specific-data-retention-requirements))
11- Supported models: `claude-fable-5-1`, `claude-mythos-5-1`, `claude-fable-5`, `claude-mythos-5`, `claude-mythos-preview`, `claude-opus-5`, `claude-opus-4-8`, `claude-opus-4-7`, `claude-opus-4-6`, `claude-sonnet-5`, `claude-sonnet-4-6`
12- Platforms: Claude API (beta), Claude Platform on AWS (beta), Amazon Bedrock (beta), Google Cloud (beta), Microsoft Foundry (beta)
13 
1431Threshold compaction is the automatic kind of compaction: you set a token threshold on your ordinary requests, and the API summarizes older context partway through a request once the threshold is reached. It is supported alongside on-demand compaction, where you decide when the summary is written (see [Compaction on demand](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand)). To choose between them, see [Choose how to compact](https://platform.claude.com/docs/en/build-with-claude/compaction#choose-how-to-compact).
1532 
1633Compaction extends the effective context length for long-running conversations and tasks by automatically summarizing older context when approaching the context window limit. It also keeps the active context small: as a conversation grows, response quality degrades, so compaction replaces older content with a concise summary.
from line 1701
16841701 puts next_response.content
16851702 ```
16861703</CodeGroup>
1704 
1705In Python, use `client.beta.messages`, as the samples on this page do. If you call `client.messages` and serialize blocks yourself, a plain `model_dump()` adds `text: null` and `citations: null` to the `compaction` block. The API then rejects the request with a 400 error (`Extra inputs are not permitted`). Use `to_dict()` or `model_dump(exclude_none=True)` instead. [Continue from the summary](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand#continue-from-the-summary) gives the same advice for on-demand compaction.
16871706 
16881707When the API receives a `compaction` block, all content blocks before it are ignored. You can either:
16891708