Skip to content
Agent YAP

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

  1. Prompt Caching and Context ManagementBuilding Coding Agents and Harnesses · Real code: pi will not orphan a tool result
  2. The Four Moves: Reduce, Offload, Isolate, RetrieveContext Engineering · Move 1: Reduce context
  3. Tokens, Context Windows, and the Quadratic ProblemBuilding Coding Agents and Harnesses · Real code: OpenCode shrinks the reply to fit
  4. How Context Goes Wrong: Rot, Pollution, and ConfusionContext Engineering · Context rot: the most important failure to understand
  5. How Memory Is Built and RetrievedAgentic Memory · The agent loop and context tools: the Claude Agent SDK

Every term, A to Z