Robots Atlas>ROBOTS ATLAS
Memory

Compaction

2025ActivePublished: 2 September 2026Published
Key innovation
Lets LLM agents run beyond a single context window: instead of a hard limit, the conversation history is summarized and the context is reinitialized from that summary.
Category
Memory
Abstraction level
Pattern
Operation level
Agent runtimeInference
Use cases
Coding agents running long work sessionsLong-horizon agentic tasksMulti-turn search and researchAutonomous agent tool-use loopsConversational assistants with long chat history

How it works

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.

Problem solved

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.

Components

Summarization step

A model call that distills the accumulated conversation history into a concise summary preserving key information.

Compaction prompt

The instruction that governs what the summary keeps versus discards; tuned from maximizing recall toward improving precision.

Context reinitialization

Creation of a new context window seeded with the generated summary, allowing the agent to continue.

Tool result clearing

Removing stale tool calls and results from the context window, complementary to summarization.

Implementation

Implementation pitfalls
Loss of important information from over-aggressive compactionHigh

A summary optimized for precision at the expense of recall may drop facts the agent still needs.

Fix:First maximize the compaction prompt's recall, then iteratively improve precision.

Evolution

Original paper · 2025 · Prithvi Rajasekaran
Effective context engineering for AI agents
Prithvi Rajasekaran, Ethan Dixon, Carly Ryan, Jeremy Hadfield
2025
Anthropic defines context compaction
Inflection point

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.

2025
Context editing and memory tool on the Claude Developer Platform

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%.

Hyperparameters (configurable axes)

Compaction trigger thresholdHigh

How close to the context window limit (in tokens) the compaction step is triggered.

Compaction prompt recall/precision balanceHigh

The trade-off between preserving all relevant information (recall) and eliminating superfluous content (precision) in the summary.

Hardware requirements

Primary

Compaction is an orchestration/inference-level technique independent of specific hardware.