A conversation keeps growing. The context window does not.
Long-running agents eventually face a bad choice: compress a large block of history all at once, or drop it.
A hard cutoff creates uneven memory. Recent turns remain detailed while everything before the boundary suddenly becomes vague or disappears. Important decisions, file paths, and user preferences can be lost even though the agent still needs them.
Let detail fade gradually with age while preserving every original turn outside the model's context.
Recent turns stay exact. Older turns become progressively coarser.
The full conversation lives in files. The context contains only the live window and the summaries currently active at each tier. Each summary includes a path, so it also acts as an index into the archive.
The same rule repeats at every level.
Choose a window size N. With the default N = 8, a rollup begins when 16 loose turns accumulate. The oldest eight move into a tier-1 directory and a summarizer writes one bounded summary.
When enough tier-1 groups accumulate, the oldest groups roll into tier 2. Tier 2 groups later roll into tier 3. The algorithm is identical at every level and has no fixed maximum depth.
A token safety threshold can trigger an early rollup when one unusually large turn would otherwise overflow the live window.
A summary is a map, not a replacement.
Suppose the agent remembers that an API decision was made months ago but needs the exact endpoint. It follows the path attached to the broad summary, opens the next level, and keeps narrowing until it reaches the original turn.
The agent can also search the session files directly. This matters because summaries are intentionally lossy: they help locate evidence, while the original turn remains the source of truth.
Context grows slowly even when the conversation grows dramatically.
The live window remains roughly constant. Only the number of active summary tiers grows, and it grows logarithmically with the number of turns.
Summarization cost is also amortized. With N = 8, the hierarchy needs about one summarizer call for every seven completed turns over time.
The directory tree is the memory state.
This makes recovery simple: walk the directory tree. A new session starts empty, clearing memory changes the active session rather than deleting history, and a branch creates an independent future from the same past.
What this design solves—and what it does not.
Use lossy summaries for orientation and lossless files for truth. The agent carries a compact map, not the entire territory.