Context editing is a technique for managing a model's context window by removing or shrinking parts of the conversation history that are no longer needed. Anthropic added a feature of this name to the Claude API in 2025. It automatically clears older tool results or thinking blocks once the history passes a configured size.
Long-running AI agents tend to fill the context window as tool results pile up. Unlike compaction, which replaces the whole history with a summary, context editing removes only selected parts of it. Because it alters earlier parts of the history, it can invalidate the prefix stored by prompt caching.