Learning resourcesReviewed · Anthropic

Claude context editing

Context editing is an Anthropic guide for developers managing long Claude conversations, but its selective clearing features are in beta. It explains how to remove older tool results and thinking blocks, manage prompt-cache tradeoffs and preview token counts. Its separate SDK compaction option is deprecated.

Researched 13 Nov 2026

In short.

Context editing is an Anthropic guide for developers building long Claude workflows, but clearing old material can remove useful details and invalidate prompt caches. Its beta API strategies selectively remove tool results or earlier thinking blocks before Claude receives a request, while preserving the application's local conversation history. The guide explains configuration, token previews, response statistics and memory-tool integration. Anthropic recommends server-side compaction for most general context management and deprecates the SDK compaction path described here. Actual savings, task quality and reliability are not assessed.

Researched and written by an AI model and checked by a second AI model. How it works

Covers the complete selected documentation page at [https://platform.claude.com/docs/en/build-with-claude/context-editing.md], including server-side clearing, thinking retention, caching, token counting, memory-tool integration, SDK compaction examples and limitations, and availability and data-handling notices. Linked pages are excluded. Their detailed pricing, contractual terms, model-specific retention requirements and fuller compaction behavior are not established here. All numerical examples remain illustrative; no code or API requests were executed.

The overview

Identity

Context editing is an Anthropic documentation guide about controlling the conversation material sent to Claude. The selected source is [https://platform.claude.com/docs/en/build-with-claude/context-editing.md]. It covers server-side tool-result clearing, thinking-block clearing and a separate client-side summarization feature.

The resource teaches API integration through configuration tables and examples in several languages. It requires developers to integrate the documented features into their applications.

Assessment

The guide is useful when an application needs precise control over which old tool results or thinking blocks remain available to Claude. Its strongest practical detail is the connection between clearing policies, retained information and prompt-cache costs.

Anthropic recommends server-side compaction as the primary approach for most long conversations. Selective context editing serves narrower needs, such as removing bulky file-reading results while protecting results from particular tools. The page supplies no comparative measurements establishing better accuracy, lower latency or net cost savings.

Users

The intended users are developers building agents that accumulate file contents, search results or other tool outputs over many steps. Coding assistants, research agents and workflows producing persistent files or reports are examples discussed on the page.

Beginners need familiarity with API requests, conversation messages and tool calls. Experienced developers get controls for retention thresholds, tool exclusions, thinking preservation and cache behavior. Work requiring exact recall of early details needs particular care when choosing what to clear or summarize.

Capabilities

The clear_tool_uses_20250919 strategy removes the oldest eligible tool results first and replaces them with removal placeholders. Its documented defaults trigger above 100,000 input tokens, retain three recent tool uses and preserve tool-call parameters. Developers can trigger by token count or tool-use count, exclude named tools, clear tool inputs too, and require a minimum token reduction through clear_at_least. If that minimum cannot be met, clearing is not applied.

The clear_thinking_20251015 strategy controls retention of earlier thinking blocks. The token-counting endpoint previews the resulting prompt size. Responses expose applied edits and cleared-token statistics; streaming responses provide these in the final message_delta event. Memory-tool integration can let Claude save important information before clearing.

Using it

Requirements

Server-side clearing requires access to a supported Claude model and the context-management-2025-06-27 beta header. Direct Claude API examples use an API key and the Messages API with a context_management configuration. The page includes HTTP and SDK examples but does not establish minimum SDK versions for the clearing features.

The page lists beta availability through the Claude API, Amazon Bedrock, Amazon Bedrock bedrock-runtime, Claude Platform on AWS, Google-managed Claude Models on Google Cloud and Microsoft Foundry. Platform-specific setup details are in linked pages and are not established by this guide alone.

Mechanism

Server-side editing changes the prompt before Claude receives it. The application continues to maintain its full, unmodified local conversation history. Clearing therefore controls what the model sees on a request; it does not delete the application's stored history.

Including the thinking-clearing strategy without keep retains thinking for one assistant turn, regardless of the model's normal default. Omitting the strategy uses model-specific defaults. A configured turn count includes the turn in progress and turns without thinking blocks. With keep set to one, a request starting a new turn clears thinking from all earlier assistant turns.

Client-side SDK compaction works differently: it requests a summary and replaces the full message history with that summary. The page says server-side edits preserve thinking-block validity on models with preserved thinking, whereas client-side edits to earlier turns can invalidate later thinking blocks.

Setup

For direct API integration, add the documented beta header and place the chosen strategies in context_management.edits. Tool-result clearing can be enabled with its type alone, although explicit trigger, keep and exclusion settings make the retention policy easier to understand. When combining both strategies, clear_thinking_20251015 must appear before clear_tool_uses_20250919.

Set thinking retention explicitly when using multiple model classes because their defaults differ. Before adopting a clearing threshold, use the token-counting endpoint with the same configuration to compare original_input_tokens with input_tokens after editing. Inspect applied_edits in subsequent responses to observe which edits actually occurred.

Example

The guide's advanced example configures a file-editing workflow to trigger tool-result clearing above 30,000 input tokens, keep three recent tool interactions, require at least 5,000 tokens to be cleared and exclude web_search from clearing. Tool-call parameters remain visible unless clear_tool_inputs is enabled.

These are illustrative settings, not measured recommendations. Whether clearing occurs depends on how much eligible content is available after retention and exclusion rules are applied. The page's sample token-counting response shows 70,000 original tokens and 25,000 after editing, but this is documentation output rather than an observed result from an executed request.

Assessment & evidence

Limitations

Selective clearing removes information from Claude's active context. Exclusions and optional memory storage can preserve important material, but the page does not establish that every necessary detail will survive. Beta status and model-dependent thinking defaults also require attention.

The TypeScript and Ruby SDK compaction parameter is deprecated and scheduled for removal in an unspecified future version. The page says Python removed it in v1.0. SDK compaction can overcount context when server-side tools accumulate cache-read usage, causing premature summarization.

When SDK compaction occurs with a tool response pending, it removes the tool-use block before summarization; Claude may reissue the call afterward. The operational effect of repeated calls depends on the application and is not assessed here.

Fit and tradeoffs

The documented controls suggest a good fit when old tool output is bulky and replaceable, while recent interactions or selected tools must remain available. This is a workload-based inference from the clearing mechanism, rather than a demonstrated performance result.

A smaller prompt may leave more context capacity, while aggressive removal can weaken continuity and cache reuse. The useful decision is therefore which information the task can safely stop carrying. The guide provides configuration and visibility into clearing, but no evidence for a universally optimal threshold.

Alternatives

Anthropic recommends server-side compaction for most long conversations and identifies compact_20260112 as the request edit for using it with a tool runner. Its full behavior is documented on a linked page and is outside this source's scope.

The deprecated TypeScript and Ruby SDK compaction path offers client-side summary controls, including a custom summary prompt and a separate summarization model. The memory tool is a complementary option for storing information outside active context. Prompt caching addresses repeated-prefix costs, while clearing addresses the content remaining in context.

Evidence

The evidence is the complete supplied Anthropic Context editing page, including request examples, configuration tables, sample response structures, deprecation warnings and availability notices. These support an explanation of documented behavior and integration requirements.

No code or API requests were executed. The examples do not establish measured accuracy, latency, reliability, savings or successful deployment. Linked documentation, pricing pages and platform-specific instructions were not assessed.

Access & freshness

Costs

Exact prices, feature surcharges and total operating costs are unknown from this page. Clearing can reduce the input context, but tool-result clearing invalidates cached prompt prefixes and incurs cache-write costs when caching is used. Later requests can reuse the newly cached prefix.

Keeping thinking blocks preserves the prompt cache; clearing them invalidates it where clearing occurs. The clear_at_least setting helps avoid cache disruption for a very small reduction. SDK compaction also generates a summary through Claude. Net savings depend on workload and pricing, and no measured savings are supplied.

Rights and data handling

The supplied page does not establish a redistribution license for its text or code examples. Broader API contractual terms and usage rights are not assessed.

Its data-handling table marks context editing as eligible for zero data retention, with an exception for Covered Models, and as not eligible for HIPAA. The linked model-specific retention requirements are outside this source's scope. Eligibility should not be read as a guarantee for every model or deployment. Context edits are described as occurring in real time, while the client retains its full history.

Freshness

The supplied source was captured on 13 November 2026 at 21:05:05.646 UTC. It labels server-side context editing as beta and includes SDK compaction deprecation and Python removal notices.

No explicit page revision date or future TypeScript/Ruby removal version is established. Date-like strategy names and the beta-header identifier identify API options; they do not establish the page's last update date. Changes after capture are unknown.

Practical next steps

Start by deciding whether the application needs selective removal or general conversation summarization. For selective removal, identify essential tool outputs, configure exclusions, set explicit thinking retention and choose a threshold with room below the selected model's context limit.

Before adoption, evaluate representative long conversations for information loss, inspect token previews and applied edits, and measure cache costs alongside token reductions. Confirm current model and platform support and applicable retention terms. Existing users of SDK compaction should assess migration to the documented server-side approach.

Evidence for this report

selected-page.txtselected · checked 2026-11-13