Compaction

concept · updated Jul 25, 2026

person concept tool org talk claim — click a node to jump to its page; hover an arrow for the relation

Compaction is a context-management technique used in AI coding agents to summarize or compress long conversation histories, allowing threads to remain useful far beyond the limits imposed by a fixed context window.

Role in agent workflows

Jason Liu (OpenAI Codex) highlights compaction as a key reason that conventional advice about managing long agent sessions has become outdated. He notes that compaction works well enough that he now maintains threads that are five weeks old — a duration that would have been impractical under older workflows. 3:30

Specifically, Liu attributes to compaction the obsolescence of the earlier rule of thumb to start a fresh thread after roughly 20 messages. Because the system can automatically summarize and compress accumulated context, continuity across much longer sessions is now feasible without degrading response quality. 6:52

Significance

Effective compaction shifts agent-session management from a user responsibility (manually pruning or restarting threads) to a system-level capability, reducing friction in long-running tasks and enabling persistent, stateful interactions over days or weeks rather than single sittings.