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-on-demand changed

build-with-claude/compaction-on-demand

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+23added
Lines−6removed
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 on demand
33url: https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand
44description: Ask Claude to summarize a conversation when your application chooses, then continue from the summary.
5featureMetadata:
6 status: beta
7 betaHeader: compact-2026-09-04
8 supportedModels:
9 - claude-fable-5-1
10 - claude-mythos-5-1
11 - claude-fable-5
12 - claude-mythos-5
13 - claude-mythos-preview
14 - claude-opus-5
15 - claude-opus-4-8
16 - claude-opus-4-7
17 - claude-opus-4-6
18 - claude-sonnet-5
19 - claude-sonnet-4-6
20 supportedPlatforms:
21 Claude API: beta
22 Claude Platform on AWS: beta
23 Amazon Bedrock: not available
24 Google Cloud: beta
25 Microsoft Foundry: beta
526---
627 
7## Compatibility
8- Status: Beta
9- [Beta header](https://platform.claude.com/docs/en/api/beta-headers): `compact-2026-09-04`
10- 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`
11- Platforms: Claude API (beta), Claude Platform on AWS (beta), Microsoft Foundry (beta); not available on Amazon Bedrock, Google Cloud
12 
1328With on-demand compaction, your application decides when a conversation is summarized: you send one request with the `compaction` parameter, and Claude returns a summary in place of a reply.
1429 
1530## How on-demand compaction works
from line 766
751766</CodeGroup>
752767 
753768The check on `stop_reason` comes before the code looks for the block; [Handle a missing summary or an error](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand#when-no-summary-comes-back) says why. The history is replaced, not appended to: the returned message replaces every message the request carried, under the rules in [Continue from the summary](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand#continue-from-the-summary). When no summary comes back, the loop keeps its history and asks again after the next turn.
769 
770The SDK [tool runner](https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-runner) in Python, TypeScript, C#, Go, and Java can send the compaction request for you. When you decide to compact, call `compact_before_next_turn()` on the runner (`compactBeforeNextTurn()` in TypeScript and Java, `CompactBeforeNextTurn()` in C# and Go). Once the current turn and its tool calls finish, the runner sends the compaction request and replaces its history with the returned message. Create the runner with the `compact-2026-09-04` beta, because the runner doesn't add it. The runner builds the request from its own parameters and leaves `context_management` out. If those parameters include `stop_sequences`, a `tool_choice` of type `any` or `tool`, or a structured-output `output_config.format`, the API rejects the request with a 400 error. [Request a summary](https://platform.claude.com/docs/en/build-with-claude/compaction-on-demand#request-a-summary) explains why. The runner refuses to compact while its `context_management` has a compaction edit, so use one kind of compaction on a runner.
754771 
755772### When to compact
756773