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.304, published under 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+26added
Lines−194removed
From line 1,393 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 1393, old and new numbered
/
lines
from line 1393
13931393 
13941394You must pass the `compaction` block back to the API on subsequent requests to continue the conversation with the shortened prompt. The simplest approach is to append the entire response content to your messages:
13951395 
1396<CodeGroup>
1397 ```bash cURL
1398 # The response content, including the compaction block, must go back to the
1399 # API as the assistant turn of the next request. Managing that message list
1400 # doesn't translate well to a one-off shell command; see the CLI and SDK
1401 # tabs for the full flow. First request:
1402 curl https://api.anthropic.com/v1/messages \
1403 -H "x-api-key: $ANTHROPIC_API_KEY" \
1404 -H "anthropic-version: 2023-06-01" \
1405 -H "anthropic-beta: compact-2026-01-12" \
1406 -H "content-type: application/json" \
1407 -d '{
1408 "model": "claude-opus-5-5",
1409 "max_tokens": 4096,
1410 "messages": [
1411 {
1412 "role": "user",
1413 "content": "Hello, Claude"
1414 }
1415 ],
1416 "context_management": {
1417 "edits": [
1418 {
1419 "type": "compact_20260112"
1420 }
1421 ]
1422 }
1423 }'
1424 ```
1396<CodeGroup exclude="shell:cURL, shell:CLI">
1397 <CodeGroupItem language="cURL">
1398 This workflow needs more logic than a single shell command. Use the [Claude SDK](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) to run it.
1399 </CodeGroupItem>
14251400 
1426 ```bash CLI
1427 ant beta:messages create \
1428 --beta compact-2026-01-12 \
1429 --transform content \
1430 --format jsonl <<'YAML' > content.json
1431 model: claude-opus-5-5
1432 max_tokens: 4096
1433 messages:
1434 - role: user
1435 content: Hello, Claude
1436 context_management:
1437 edits:
1438 - type: compact_20260112
1439 YAML
1401 <CodeGroupItem language="CLI">
1402 This workflow needs more logic than a single shell command. Use the [Claude SDK](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) to run it.
1403 </CodeGroupItem>
14401404 
1441 # After receiving a response with a compaction block, append it as the
1442 # assistant turn and continue the conversation
1443 ant beta:messages create --beta compact-2026-01-12 <<YAML
1444 model: claude-opus-5-5
1445 max_tokens: 4096
1446 messages:
1447 - role: user
1448 content: Hello, Claude
1449 - role: assistant
1450 content: $(cat content.json)
1451 - role: user
1452 content: Now add error handling
1453 context_management:
1454 edits:
1455 - type: compact_20260112
1456 YAML
1457 ```
1458 
14591405 ```python Python
14601406 client = anthropic.Anthropic()
14611407 messages = [{"role": "user", "content": "Hello, Claude"}]
from line 2330
23842330 ```
23852331 
23862332 ```bash CLI
2387 CURRENT=$(ant beta:messages count-tokens \
2388 --beta compact-2026-01-12 \
2389 --transform input_tokens \
2390 --raw-output <<'YAML'
2333 ant beta:messages count-tokens \
2334 --beta compact-2026-01-12 <<'YAML'
23912335 model: claude-opus-5-5
23922336 messages:
23932337 - role: user
from line 2340
23962340 edits:
23972341 - type: compact_20260112
23982342 YAML
2399 )
2400 
2401 ORIGINAL=$(ant beta:messages count-tokens \
2402 --beta compact-2026-01-12 \
2403 --transform context_management.original_input_tokens \
2404 --raw-output <<'YAML'
2405 model: claude-opus-5-5
2406 messages:
2407 - role: user
2408 content: Hello, Claude
2409 context_management:
2410 edits:
2411 - type: compact_20260112
2412 YAML
2413 )
2414 
2415 printf 'Current tokens: %s\n' "$CURRENT"
2416 printf 'Original tokens: %s\n' "$ORIGINAL"
24172343 ```
24182344 
24192345 ```python Python
from line 2480
25542480 
25552481Here's a complete example of a long-running conversation with compaction:
25562482 
2557<CodeGroup>
2558 ```bash cURL
2559 # curl sends individual requests; maintain the messages array in the
2560 # calling script. See the SDK tabs for the full chat() loop. Single-turn
2561 # request shape:
2562 curl https://api.anthropic.com/v1/messages \
2563 -H "x-api-key: $ANTHROPIC_API_KEY" \
2564 -H "anthropic-version: 2023-06-01" \
2565 -H "anthropic-beta: compact-2026-01-12" \
2566 -H "content-type: application/json" \
2567 -d '{
2568 "model": "claude-opus-5-5",
2569 "max_tokens": 4096,
2570 "messages": [
2571 {
2572 "role": "user",
2573 "content": "Help me build a Python web scraper"
2574 }
2575 ],
2576 "context_management": {
2577 "edits": [
2578 {
2579 "type": "compact_20260112",
2580 "trigger": {
2581 "type": "input_tokens",
2582 "value": 100000
2583 }
2584 }
2585 ]
2586 }
2587 }'
2588 ```
2483<CodeGroup exclude="shell:cURL, shell:CLI">
2484 <CodeGroupItem language="cURL">
2485 This workflow needs more logic than a single shell command. Use the [Claude SDK](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) to run it.
2486 </CodeGroupItem>
25892487 
2590 ```bash CLI
2591 # The CLI handles individual turns; maintain the messages array in the
2592 # calling script. See the SDK tabs for the full chat() loop. Single-turn
2593 # request shape:
2594 ant beta:messages create \
2595 --beta compact-2026-01-12 \
2596 --transform 'content.#(type=="text").text' \
2597 --raw-output <<'YAML'
2598 model: claude-opus-5-5
2599 max_tokens: 4096
2600 messages:
2601 - role: user
2602 content: Help me build a Python web scraper
2603 context_management:
2604 edits:
2605 - type: compact_20260112
2606 trigger:
2607 type: input_tokens
2608 value: 100000
2609 YAML
2610 ```
2488 <CodeGroupItem language="CLI">
2489 This workflow needs more logic than a single shell command. Use the [Claude SDK](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) to run it.
2490 </CodeGroupItem>
26112491 
26122492 ```python Python
26132493 client = anthropic.Anthropic()
from line 2782
29022782 
29032783Here's an example that uses `pause_after_compaction` to preserve the prior exchange and the current user message (three messages total) instead of summarizing them. It keeps their text and tool blocks unchanged, removes the `thinking` and `redacted_thinking` blocks from the preserved assistant turn, and drops that turn if nothing else is left:
29042784 
2905<CodeGroup>
2906 ```bash cURL
2907 # curl sends individual requests; maintain the messages array in the
2908 # calling script. See the SDK tabs for the full chat() loop with
2909 # pause-and-preserve handling. Single-turn request shape:
2910 curl https://api.anthropic.com/v1/messages \
2911 -H "x-api-key: $ANTHROPIC_API_KEY" \
2912 -H "anthropic-version: 2023-06-01" \
2913 -H "anthropic-beta: compact-2026-01-12" \
2914 -H "content-type: application/json" \
2915 -d '{
2916 "model": "claude-opus-5-5",
2917 "max_tokens": 4096,
2918 "messages": [
2919 {
2920 "role": "user",
2921 "content": "Help me build a Python web scraper"
2922 }
2923 ],
2924 "context_management": {
2925 "edits": [
2926 {
2927 "type": "compact_20260112",
2928 "trigger": {
2929 "type": "input_tokens",
2930 "value": 100000
2931 },
2932 "pause_after_compaction": true
2933 }
2934 ]
2935 }
2936 }'
2937 ```
2785<CodeGroup exclude="shell:cURL, shell:CLI">
2786 <CodeGroupItem language="cURL">
2787 This workflow needs more logic than a single shell command. Use the [Claude SDK](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) to run it.
2788 </CodeGroupItem>
29382789 
2939 ```bash CLI
2940 # The CLI handles individual turns; maintain the messages array in the
2941 # calling script. See the SDK tabs for the full chat() loop with
2942 # pause-and-preserve handling. Single-turn request shape:
2943 ant beta:messages create \
2944 --beta compact-2026-01-12 \
2945 --transform 'content.#(type=="text").text' \
2946 --raw-output <<'YAML'
2947 model: claude-opus-5-5
2948 max_tokens: 4096
2949 messages:
2950 - role: user
2951 content: Help me build a Python web scraper
2952 context_management:
2953 edits:
2954 - type: compact_20260112
2955 trigger:
2956 type: input_tokens
2957 value: 100000
2958 pause_after_compaction: true
2959 YAML
2960 ```
2790 <CodeGroupItem language="CLI">
2791 This workflow needs more logic than a single shell command. Use the [Claude SDK](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) to run it.
2792 </CodeGroupItem>
29612793 
29622794 ```python Python
29632795 from typing import Any
Feedback