Summarizing history to make room

By Prof. Tom Yeh

Published: 2026-08-19

URL: https://www.byhand.ai/p/library-agents-context-compacting-the-window


Library › Context Problems

-

The Context Window

-

Window Occupancy

-

Growth per Turn

-

Remaining Space

-

Turn Budget

-

Retrieval Footprint

-

Retrieval per Turn

-

Search Rounds

-

Window Sizing

-

Truncation

-

Compaction

-

The Compaction Bill

-

Compacted Retrieval

-

The Compaction Threshold

-

Verbatim Tail

-

Stateless API

-

Retrieval Cost

-

Context Tax

-

Quadratic Cost

-

Cost Forecast

Truncation throws the oldest turns away. Compaction keeps them, but small: the model reads the history and writes a summary that stands in for it. The system prompt is not part of the history and does not get compacted; it is pinned at the front and survives intact. So the window after a compaction is the same system prompt, followed by a summary a fraction of the size, and a great deal of space that was not there before.

Paid members: the worksheet and its printable PDF are below ↓