Compaction and summarisation
Three hours into a coding session, the agent's context window is nearly full. Stop, and the progress is gone; carry on, and the request fails. Compaction rewrites the history into a short, faithful summary so the agent can keep going, as long as the summary keeps the decisions that matter.
In this lesson you'll learn to
- Explain why long sessions outgrow the context window and when to compact, from a token threshold or a task boundary.
- Decide what a summary must keep (goal, decisions, open problems, current state, pointers) and what it can drop.
- Implement compaction with a summarising call that keeps recent turns verbatim, starting from the lightest touch.
- Recognise the risks of lossy summaries and reduce them with tests and state saved outside the context.
Create a free account to open this lesson
It's free. You'll get every free lesson, quizzes that save your progress, daily flashcards and streaks.