Codex Drops Summary Compaction for Fresh Context Windows

Three pull requests already merged into the openai/codex repository's main branch lay out the direction for reworking Codex's context window management: when a session outgrows its window, the system no longer generates a summary to compress history — instead, it opens a brand-new window and keeps working. The capability is gated behind a feature flag called Feature::TokenBudget and hasn't officially launched yet.

The current approach is summary-based compaction. When the window is nearly full, the system asks the backend to condense the prior conversation into a summary and swaps it in for the raw history. That approach carries two fixed costs: generating the summary itself burns tokens, and compression is lossy — API contracts, file paths, and trade-offs settled a few turns earlier can all get smoothed over in the condensing process. Anyone who has run long tasks with Codex knows this failure mode well: the model forgets a rule it agreed to two hours ago, and answers confidently anyway.

Letting the model ask for a fresh page itself

Step one was #27488, merged June 11 under the title "Add new context window tool." It gives the model a new_context tool available only to the model itself — the author's description calls it an "escape hatch" for when the current window stops being useful.

The request is logged under AutoCompactWindow and consumed after sampling; the very next request in the same turn lands in the new window. That new window starts from a compaction checkpoint with no summary — it keeps only the initial context, and the prior conversation history doesn't carry over.

Manual cleanup takes the same path

Step two was #29743, merged June 23. It folds manual and automatic compaction into a single lifecycle called compact_token_budget: once token budget is turned on, compaction no longer asks the backend for a summary — it loads a completely fresh initial context locally instead.

The engineering restraint shows in the details: externally visible behavior stays intact. The compact hook still fires as usual, and the ContextCompaction lifecycle event still gets emitted. In other words, clients that depend on these events don't need to change anything — only the implementation underneath is swapped out.

History and notes tools handle what gets pulled back

The first two steps only solved "throwing away." #39827, merged August 21, is what adds "pulling back." The PR description is blunt about it: token-budget sessions need a way to recover prior conversation context and preserve working state across window switches.

It adds two sets of tools. The history tools list windows and entries, read a given entry, and search within session content. The notes tools list, read, search, append to, and write persistent notes. Calls go through the Codex backend and require an OpenAI provider plus backend authentication, and the whole thing sits behind another feature flag: features.token_budget.use_history_notes_history.

Several throttles were built in at the engineering level: output is handled with truncation awareness, and request parameters have bounds. Automated review comments centered on a 10,000-token cap for plaintext results, parameter-binding limits on note operations, and a suggestion to roll the feature out in stages.

What's actually being replaced

Summary compaction and new-window-plus-retrieval are, at bottom, two different memory strategies. The former is implicit lossy compression — the model doesn't know what it lost and has no way to get it back. The latter is an explicit, stateless restart — the model knows the old content still exists somewhere and goes and looks it up when it needs it.

The cost just moves to a different place. Lossy compression fails quietly. A window switch fails as "didn't look something up when it should have" or "looked it up but got the wrong thing" — the former is hard to debug, the latter at least shows up in the logs. For agents running long tasks, an observable failure beats a silent one.

The money saved is the other side of the benefit. A summary requires a model call, and that expense repeats itself over and over in a long session; a window switch doesn't trigger that call, and retrieval only fetches entries when they're actually needed. For heavy users burning through their quota every day, that's real money.

One thing worth being clear about is the pace: a merged PR isn't the same as a shipped feature. All three changes still sit behind feature flags, and automated review is still recommending a staged rollout. From the first version of the tool in June to the history-and-notes work completing in August, OpenAI has spent more than two months on this path — and the repository's record doesn't say when, or for whom, the flag gets flipped on.

Sources: three merged pull requests in the openai/codex repository, CocoLoop, GitHub automated review comments; tool names, feature-flag names, and merge status cross-checked against the repository record.