The number-one hidden cost of a long-running agent is not compute but the context window. An agent that has run dozens of turns has a history stuffed with finished sub-steps, already-read files, and discarded intermediate reasoning — if left unmanaged, it either gets hard-truncated by the window (losing information) or the token bill spirals. OpenAI promoting Compaction to a core concept acknowledges exactly this: compaction is not an optional optimization but a foundational capability for long-running agents. Its placement alongside Conversation state and Counting tokens signals that compression must be co-designed with state management and cost accounting — what to compress, what to keep, and when to trigger are engineering decisions with explicit semantics, not something to leave to the model's 'best judgment'.
For Zero to Pro Agent Harness learners, Compaction is the core case study of the 'memory and context management' chapter: the short-term context window is volatile and hard-capped, while long-term memory should live in a knowledge graph or external store. Choosing a compaction strategy — keep-by-importance, decay-by-time, or let-the-agent-summarize — directly determines a long-running agent's quality and cost curve. For Zero to Codex learners, the most practical habit is watching token consumption: when a long session starts slowing and getting expensive, it's usually not the model but context management falling behind. Understanding Compaction is the dividing line between 'runs once' and 'runs long tasks reliably'.