AI

Context compaction

A long conversation or agent trace is summarised and the window restarted from the summary, so the loop can continue past the context limit.

The trade is irreversible and invisible to the model: after compaction the summary is the history, so an agent cannot report what was dropped and instead repeats work or reopens settled decisions. Clearing stale tool results is the lighter-touch version, and logging every compaction with its token counts is what makes the failure debuggable.

Explained in depth

Implemented by

Related concepts