05.02 · Concept
Compaction without losing the thread
Compress a long run so the agent keeps what matters and drops what does not.
Compaction turns a long agent run into a smaller working state that preserves intent, decisions, constraints, tool results, errors and pending work. The aim is continuity, not a neat transcript summary, so future model calls can proceed correctly without carrying every prior message.
What this lesson answers
- how to compact agent context safely
- what should an agent summary keep
- why agent summarisation loses important details
Notes
Compaction is the practice of turning a long interaction history into a smaller state that still lets the agent continue correctly. The goal is not to make a pretty summary; it is to preserve the thread of work: user intent, decisions already made, constraints, open questions, tool results, errors, and commitments the agent must not violate later.
A useful mental model is checkpointing a production incident or a long-running job. You do not keep every log line in the operator handoff; you keep the current diagnosis, known facts, rejected hypotheses, commands already run, and next actions.
Common questions
- What is context compaction for agents?
- Context compaction is the reduction of a long interaction history into a smaller state the agent can still use to continue the task. It keeps durable facts, decisions, constraints, useful tool outputs, known failures and next actions, while dropping chatter and material that no longer affects future behaviour.
- How is compaction different from summarising a conversation?
- A conversation summary is usually prose shaped around what was discussed. Compaction is operational state management. It preserves details because they affect later decisions, such as exact files, API results, user preferences, rejected approaches and unresolved questions. A readable summary can still be a bad compacted context if it loses those anchors.
- What causes agent runs to fail after compaction?
- Failures usually come from missing context, irrelevant context crowding out useful state, or a summary that distorts the thread of work. If the agent repeats failed attempts, violates earlier constraints, forgets tool results or ignores pending commitments, the compacted state has probably dropped or blurred information it needed.
Short definition: what is Compaction without losing the thread?