An agent's context is a transcript, and every tool call appends its full result to it.
A directory listing, a file read or a search result can each be thousands of tokens.
After twenty steps the window is mostly output that stopped being relevant fifteen steps ago.
Two things go wrong at once as it fills up.
Cost and latency rise on every subsequent call, because the whole transcript is reprocessed.
And relevant details get lost in the middle, where attention is weakest.
Compaction is the maintenance step that keeps the run going without simply truncating.
The oldest portion of the history is summarised and replaced by that summary in place.
Recent turns are kept verbatim, since the agent needs precise detail about what it just did.
What the summary must retain is not the narrative but the state.
The original goal, the constraints given, the decisions already made, and the work already completed.
Drop the last of those and the agent will confidently redo a task it finished twenty minutes ago.
Drop a constraint and it will violate an instruction it was given at the start.
Because summaries are lossy, durable facts are better written outside the context entirely.
A scratchpad file or a memory store survives compaction intact and can be re-read on demand.