Case & CodeA FIELD GUIDE TO AI
Start learning
Intermediate

Compaction

Also: context compaction

In plain words

Squeezing a long conversation into a short summary so there is room to keep going. Details can be lost in the squeeze.

The fuller definition

Compaction reduces conversation or task history into a smaller representation so work can continue within context limits.

One illustrative context budget
Instructions
2,000
Sources and history
8,000
Output reserve
4,000
Unused
2,000

A hypothetical 16,000-token budget. Real limits and token accounting depend on the model. Saving a file outside this budget does not mean it is present in the current context, and a passage inside it is not guaranteed equal attention.

A concrete example

A long task is summarized into completed steps, current files, and remaining questions.

The distinction that matters

A summary can omit qualifications. Keep original sources and verify state against actual artifacts.

Related terms

Where it is taught

Give AI a brief it can actually follow

Source and further reading

Anthropic · Context engineering

The definition and example are written for this library. The link gives background, official documentation or legal authority as labelled. Legal scope depends on the jurisdiction and current text; product features depend on release and settings.

Lessons, terms, practical guides and sources ESC