When the conversation size approaches the context window limit, a compaction step runs: the model is given a compaction prompt instructing it to distill the history into a concise summary that preserves important facts (decisions, open issues, implementation details) while omitting redundant tool outputs and less relevant messages. The resulting summary seeds a new context window in which the agent continues. Anthropic recommends tuning the compaction prompt by first maximizing recall (capturing every relevant piece of information), then iterating to improve precision by eliminating superfluous content. Compaction is complemented by tool result clearing — removing stale tool calls and results.
A language model's context window is finite, so in long-running, multi-step agentic tasks the conversation history (messages, tool results) grows until the available tokens are exhausted, halting the agent or causing loss of earlier context. Context Compaction addresses this by compressing the history into a concise summary, so the agent retains key information and can keep working.
A model call that distills the accumulated conversation history into a concise summary preserving key information.
The instruction that governs what the summary keeps versus discards; tuned from maximizing recall toward improving precision.
Creation of a new context window seeded with the generated summary, allowing the agent to continue.
Removing stale tool calls and results from the context window, complementary to summarization.
A summary optimized for precision at the expense of recall may drop facts the agent still needs.
In "Effective context engineering for AI agents" (Sep 29, 2025) Anthropic describes compaction as summarizing conversation history and reinitializing the context window from the summary.
Anthropic ships (public beta) context editing, which automatically clears stale tool calls and results as token limits approach; in testing context editing gave a 29% improvement and, combined with the memory tool, 39%.
How close to the context window limit (in tokens) the compaction step is triggered.
The trade-off between preserving all relevant information (recall) and eliminating superfluous content (precision) in the summary.
Compaction is an orchestration/inference-level technique independent of specific hardware.