What is it?
Compaction
A reversible way to shrink the context window. Compaction removes information from the running history when that information still exists somewhere else (for example, on disk). A typical example: after an agent writes a 500-line file, the chat history keeps only the file path, not the full file contents, because the agent can always re-read the file if needed. Because nothing is truly lost, compaction is preferred over summarization when possible. See also context offloading.
From the AI agent glossary
Where Compaction is explained
- Prompt Caching and Context ManagementBuilding Coding Agents and Harnesses · Real code: pi will not orphan a tool result
- The Four Moves: Reduce, Offload, Isolate, RetrieveContext Engineering · Move 1: Reduce context
- Tokens, Context Windows, and the Quadratic ProblemBuilding Coding Agents and Harnesses · Real code: OpenCode shrinks the reply to fit
- How Context Goes Wrong: Rot, Pollution, and ConfusionContext Engineering · Context rot: the most important failure to understand
- How Memory Is Built and RetrievedAgentic Memory · The agent loop and context tools: the Claude Agent SDK