Context

Compaction

Also called: summarization

Compaction is condensing older conversation history into a summary to reclaim context-window space while keeping the important gist. It is lossy by design.

James Phoenix
Understanding Data Updated July 2, 2026

Compaction is when an agent takes a long stretch of conversation and replaces it with a shorter summary. The point is to reclaim room in the context window. Rather than carry every message, every file dump, and every command output verbatim, the agent condenses the older part of the history into a few paragraphs of "here is what we did and decided" and drops the raw detail.

Why you need it

A window is finite, and a busy session fills it fast. Once you are near the limit you have two options: lose the oldest messages entirely, or compress them. Compaction is the compress option. Done well, it keeps the thread of what matters (the goal, the key decisions, the current state) while shedding the bulky, finished detail that is no longer pulling its weight.

The tradeoff

Compaction is lossy on purpose, and that is the risk:

  • What survives is whatever the summariser judged important, in its words.
  • What vanishes is the exact wording, the specific line numbers, the subtle constraint you mentioned once.

If the summary drops a detail you were relying on, the agent will act as if you never said it. That is the failure mode to watch for. When it happens on its own it is called autocompact, and sometimes the cleaner move is clearing the window entirely and starting from a crisp restatement of the task.

Tip
Before a big compaction, pin the things you cannot afford to lose (the spec, the current plan) somewhere durable, so a lossy summary cannot quietly erase them.

Related terms

Building with AI agents?

This dictionary is part of how I think about agentic engineering. If you want the same thinking applied to your codebase, that is what I do.

See how I can help