Follow Discord
Sweep 06 Nov 2026 · 01:32Z Build v2.1.319 537 read Stable v2.1.311 Latest v2.1.319 Next v2.1.319 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

context-editing changedbuild-with-claude/context-editing

Nearest release: v2.1.319, 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+31added
Lines−27removed
From line 64 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits26to this page, all time

The whole hunk

from line 64, old and new numbered
/
lines
from line 64
6464 
6565The `clear_tool_uses_20250919` strategy clears tool results when conversation context grows beyond your configured threshold. This is particularly useful for agentic workflows with heavy tool use. Older tool results (such as file contents or search results) are no longer needed once Claude has processed them.
6666 
67When activated, the API automatically clears the oldest tool results in chronological order. The API replaces each cleared result with placeholder text indicating to Claude that it was removed. By default, only tool results are cleared. You can optionally clear both tool results and tool calls (the tool use parameters) by setting `clear_tool_inputs` to true.
67When activated, the API automatically clears the oldest tool results in chronological order. The API replaces each cleared result with placeholder text indicating to Claude that it was removed. By default, only tool results are cleared. You can optionally clear both tool results and tool calls (the tool use parameters) by setting `clear_tool_inputs` to `true`.
6868 
6969### Thinking block clearing
7070 
from line 71
7171The `clear_thinking_20251015` strategy manages `thinking` blocks from earlier assistant turns. This strategy gives you control over thinking preservation: you can choose to keep more thinking blocks to maintain reasoning continuity, or clear them more aggressively to save context space.
7272 
7373<Tip>
74 **Default behavior:** The default varies by model class.
74 **Default behavior:** When a request doesn’t include the `clear_thinking_20251015` strategy, the default varies by model class.
7575 
76 | Model class | Keep all prior thinking | Keep only the last turn’s thinking |
77 | ---------------- | --------------------------- | ------------------------------------------ |
78 | Opus | Claude Opus 4.5 and later | Claude Opus 4.1 and earlier |
79 | Sonnet | Claude Sonnet 4.6 and later | Claude Sonnet 4.5 (deprecated) and earlier |
80 | Haiku | Claude Haiku 5.5 and later | Claude Haiku 4.5 and earlier |
81 | Fable and Mythos | All models | (none) |
76 | Model class | Keep all prior thinking | Keep thinking only for the turn in progress |
77 | ---------------- | --------------------------- | ------------------------------------------- |
78 | Opus | Claude Opus 4.5 and later | Claude Opus 4.1 and earlier |
79 | Sonnet | Claude Sonnet 4.6 and later | Claude Sonnet 4.5 (deprecated) and earlier |
80 | Haiku | Claude Haiku 5.5 and later | Claude Haiku 4.5 and earlier |
81 | Fable and Mythos | All models | (none) |
8282 
83 Use this strategy to override the default. If your code runs across multiple model tiers, set `keep` explicitly rather than relying on the per-model default.
83 Use this strategy to override the default. If your code runs across multiple model classes, include this strategy and set `keep` explicitly rather than relying on the per-model default.
8484</Tip>
8585 
8686An assistant conversation turn might include multiple content blocks (for example, when using tools) and multiple thinking blocks (for example, with [interleaved thinking](https://platform.claude.com/docs/en/build-with-claude/thinking#interleaved-thinking)).
from line 278
278278 messages: [
279279 ['role' => 'user', 'content' => 'Search for recent developments in AI']
280280 ],
281 model: 'claude-opus-5-5',
281 model: Model::CLAUDE_OPUS_5_5,
282282 betas: ['context-management-2025-06-27'],
283283 tools: [
284284 ['type' => 'web_search_20250305', 'name' => 'web_search']
from line 630
630630 'content' => 'Create a simple command line calculator app using Python'
631631 ]
632632 ],
633 model: 'claude-opus-5-5',
633 model: Model::CLAUDE_OPUS_5_5,
634634 betas: ['context-management-2025-06-27'],
635635 tools: [
636636 [
from line 673
673673 client = Anthropic::Client.new
674674 
675675 response = client.beta.messages.create(
676 model: "claude-opus-5-5",
676 model: Anthropic::Model::CLAUDE_OPUS_5_5,
677677 max_tokens: 4096,
678678 messages: [
679679 {
from line 944
944944 
945945The `clear_thinking_20251015` strategy supports the following configuration:
946946 
947| Configuration option | Default | Description |
948| -------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
949| `keep` | Model-specific | Defines how many recent assistant turns with thinking blocks to preserve. Use `{type: "thinking_turns", value: N}` where N must be > 0 to keep the last N turns, or `"all"` to keep all thinking blocks. Opus 4.5+, Sonnet 4.6+, and Haiku 5.5+: all turns. Fable and Mythos models: all turns. Earlier Opus/Sonnet and Haiku through Claude Haiku 4.5: last turn only. |
947| Configuration option | Default | Description |
948| -------------------- | ------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
949| `keep` | `{type: "thinking_turns", value: 1}` | Defines how many recent assistant turns keep their thinking blocks. Use `{type: "thinking_turns", value: N}` where N must be > 0 to keep the last N turns, or `"all"` to keep all thinking blocks. |
950950 
951A request that includes this strategy without `keep` gets `{type: "thinking_turns", value: 1}` on every model, including models whose [per-model default](https://platform.claude.com/docs/en/build-with-claude/context-editing#thinking-block-clearing) keeps all thinking. A request without this strategy gets the per-model default.
952 
953N counts the assistant turn in progress and turns without thinking blocks. A user message that contains only `tool_result` blocks continues the turn in progress. Any other user message starts a new turn. When a request ends with a message that starts a new turn, a value of 1 clears the thinking from every earlier assistant turn.
954 
951955**Example configurations:**
952956 
953Keep thinking blocks from the last 3 assistant turns:
957Keep thinking blocks from the last 3 assistant turns, counting the turn in progress:
954958 
955959<CodeGroup>
956960 ```bash cURL
from line 1669
16651669 'content' => 'Search for the latest developments in quantum error correction and summarize the key breakthroughs.'
16661670 ]
16671671 ],
1668 model: 'claude-opus-5-5',
1672 model: Model::CLAUDE_OPUS_5_5,
16691673 betas: ['context-management-2025-06-27'],
16701674 tools: [
16711675 [
from line 1754
17501754 
17511755## Configuration options for tool result clearing
17521756 
1753| Configuration option | Default | Description |
1754| -------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1755| `trigger` | 100,000 input tokens | Defines when the context editing strategy activates. Once the prompt exceeds this threshold, clearing starts. You can specify this value in either `input_tokens` or `tool_uses`. |
1756| `keep` | 3 tool uses | Defines how many recent tool use/result pairs to keep after clearing occurs. The API removes the oldest tool interactions first, preserving the most recent ones. |
1757| `clear_at_least` | None | Ensures a minimum number of tokens is cleared each time the strategy activates. If the API can’t clear at least the specified amount, the strategy will not be applied. This helps determine if context clearing is worth breaking your prompt cache. |
1758| `exclude_tools` | None | List of tool names whose tool uses and results should never be cleared. Useful for preserving important context. |
1759| `clear_tool_inputs` | `false` | Controls whether the tool call parameters are cleared along with the tool results. By default, only the tool results are cleared while keeping Claude’s original tool calls visible. |
1757| Configuration option | Default | Description |
1758| -------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1759| `trigger` | 100,000 input tokens | Defines when the context editing strategy activates. Once the prompt exceeds this threshold, clearing starts. You can specify this value in either `input_tokens` or `tool_uses`. |
1760| `keep` | 3 tool uses | Defines how many recent tool use/result pairs to keep after clearing occurs. The API removes the oldest tool interactions first, preserving the most recent ones. |
1761| `clear_at_least` | None | Ensures a minimum number of tokens is cleared each time the strategy activates. If the API can’t clear at least the specified amount, the strategy isn’t applied. This helps determine whether context clearing is worth breaking your prompt cache. |
1762| `exclude_tools` | None | List of tool names whose tool uses and results should never be cleared. Useful for preserving important context. |
1763| `clear_tool_inputs` | `false` | Controls whether the tool call parameters are cleared along with the tool results. By default, only the tool results are cleared while keeping Claude’s original tool calls visible. |
17601764 
17611765## Context editing response
17621766 
from line 2044
20402044 messages: [
20412045 ['role' => 'user', 'content' => 'Continue our conversation...']
20422046 ],
2043 model: 'claude-opus-5-5',
2047 model: Model::CLAUDE_OPUS_5_5,
20442048 betas: ['context-management-2025-06-27'],
20452049 contextManagement: [
20462050 'edits' => [
Feedback