What each harness does when the conversation outgrows the context window: when it compacts, what it keeps, and how you can steer it.
When it happens
| Question | Codex CLIchecked at 0.162.1 | Claude Codechecked at 2.1.299 | Cursor Agentchecked at 2026.10.12-d47ca18 | OpenCodechecked at 2.0.28 | pichecked at 1.2.0 |
|---|---|---|---|---|---|
| Automatic compaction, and when | Yes. Before each turn, after each model step that needs a follow-up, and when you switch to a model with a smaller window, Codex compares the active context (the last reported input + output token count) to an auto-compact limit of 90% of the model's context window (or
| Yes. Without a configured window, Claude Code compacts as the conversation reaches the model's context limit; models running a native 1M window (Fable, Sonnet 5+, Haiku 5.5, Opus 4.7+) compact at about 967K tokens, and Sonnet 4.6 / Opus 4.6 without Since v2.1.290 it also compacts a terminal conversation of 200K+ tokens left idle about 54 minutes on the one-hour prompt cache, just before the cache expires ( On a model ID it doesn't recognise (such as a gateway alias) it compacts at the window it assumes for that ID; correct it with Subagents compact independently as their own context fills. Source | Yes. When a chat's context window gets close to full, Cursor summarizes older parts of the conversation to make room, and this also happens partway through long tool-calling turns. Cursor does not publish the exact trigger percentage or token count. Its servers decide when to compact, and the The | Yes. Before each model step OpenCode estimates the prompt size and compacts when it reaches the window minus a buffer. The estimate is the provider-reported tokens from the last response plus about 4 characters per token for anything added since. The default buffer is 10% of the window or 16,000 tokens, whichever is larger (models under 32k keep just 10%). The window is the model's input limit if it has one, otherwise its context limit. Models with an unknown window never auto-compact; only a provider rejection triggers it. Source | Yes. Pi compacts automatically when Right after a compaction, Pi ignores the old (pre-compaction) usage figures and estimates the rebuilt context from scratch until the next response arrives. Source |
| Change the trigger or turn it off | Partly Set
| Set the auto-compact window (100K to 1M tokens, capped at the model's window) with The environment variable only accepts a plain integer; A subagent can compact earlier with Turning auto-compact off also turns off idle compaction; set | Not supported No. There is no setting, flag or environment variable to change when automatic summarization triggers or to turn it off. The only lever is a bigger window: pick a larger-context model variant in | Set V2 has no | Set
Turning off auto-compaction also turns off automatic overflow recovery.
|
| Compact by hand | Partly Type | Run | Run | Partly Type The V1 alias | Run
|
| See how full the context is | The TUI footer shows | Run The status line percentage is measured against the model's full window, so it no longer shows when compaction will run once you set a smaller auto-compact window. Source | The prompt bar footer shows how full the context window is as a percentage (set | The TUI prompt footer and the sidebar's Context section show the last response's tokens and the percentage of the model's context window, for example | The interactive footer shows context use as |
What it does
| Question | Codex CLIchecked at 0.162.1 | Claude Codechecked at 2.1.299 | Cursor Agentchecked at 2026.10.12-d47ca18 | OpenCodechecked at 2.0.28 | pichecked at 1.2.0 |
|---|---|---|---|---|---|
| What replaces the conversation | With OpenAI (and Azure Responses) providers, Codex uses remote compaction: it sends the history plus a compaction trigger through the Responses API, and the server-side model returns one encrypted Custom providers can choose with With the | Claude Code sends a separate request to the session's model with the same system prompt, tools and history plus a summarisation instruction, and replaces the message history with the structured summary it returns (you see "Conversation compacted"). The request inherits the session's extended-thinking setting and uses your fallback model chain, but never falls back to a model with a smaller context window. Startup context such as CLAUDE.md and memory is then reloaded from disk around the summary. Source | Partly Cursor's backend writes the summary, not your local CLI. The CLI sends a summarize action and shows | OpenCode summarizes everything except the most recent conversation into a structured Markdown checkpoint (Objective, Requirements, Decisions, Work State, Next Move, Relevant Files, Important Context). It uses the session's model and asks once more if the reply misses the template. Later requests begin with one The docs say there is no separate compaction model, but the source does honor a model set on the hidden | Pi asks the current session model to write a structured checkpoint summary (Goal, Constraints & Preferences, Progress, Key Decisions, Next Steps, Critical Context, plus lists of files read and modified). It sends the older messages as serialized text with thinking blocks removed and each tool result cut to 2000 characters. Pi then appends a When a single long user turn exceeds the kept budget, Pi writes two summaries (earlier history and the start of that turn) and merges them. An extension can supply the summary instead, using any model it likes. Source |
| What survives | Partly Codex rebuilds the initial context after compaction: base and developer instructions, Images in retained messages may be dropped (only their text is kept) when the token budget is exceeded. Source | The system prompt and output style still apply; project-root CLAUDE.md, unscoped rules, auto memory and the plan-mode plan are re-injected from disk, and a fresh git status is read. Claude Code re-reads up to five recently modified files it read or edited (files over 5,000 tokens come back as a path only), re-injects invoked skill bodies capped at 5,000 tokens each and 25,000 total, keeps the task list, and reminds Claude of running background commands and subagents. Path-scoped rules and nested CLAUDE.md files are summarised away until a matching file is touched again, and the skill listing is not re-sent. Recent turns are folded into the summary rather than kept verbatim, except in overflow recovery, which can keep the newest exchanges or your newest prompt word for word. Run | Partly The system prompt, tool definitions, rules, skills, MCP instructions and subagent docs are counted separately from the conversation, so summarization doesn't touch them. Since September 2026 your most recent message is kept word for word after summarization. In CLI 2026.10.12 the session also stores todos, plans and invoked skill blocks outside the summarized turns. Cursor doesn't document exactly how many recent turns or files are kept. Source | About | The system prompt is kept in full: context files such as Skill bodies the model loaded during the conversation are ordinary messages, so older ones are summarised like anything else. Extension state stored in session entries follows the session tree and survives compaction. Source |
| Trimming without summarising | Partly Yes, separately from compaction: each tool or function output is truncated when it is stored in history, to 10,000 tokens by default for bundled models. You can change this with | Yes. As the context fills, Claude Code clears older tool outputs first and only summarises if that isn't enough, and when a request would exceed the image or PDF limits it drops a batch of the oldest images and PDFs. There is no setting to tune or disable this clearing. Source | Not documented Cursor doesn't describe any separate step that trims old tool outputs without summarizing, and there is no setting to control one. The only documented ways to free context are automatic summarization and | Not supported No. V2 has no separate tool-output pruning. | Partly Pi does not prune or clear old tool outputs on its own. The only automatic trimming is that tool results are cut to 2000 characters inside the text sent for summarisation. Extensions can trim without summarising by appending During overflow recovery, Pi itself appends |
| The full history afterwards | Yes. The session rollout under | Yes. The session JSONL in With Transcripts are deleted after | Yes. Each chat's The | Yes. Earlier messages stay stored even when they're no longer sent to the model. The checkpoint is recorded as a compaction message with the summary text and the kept recent text, and the TUI shows the compaction as it starts, streams, and ends. Source | Yes. Sessions are append-only JSONL files under |
Shaping it
| Question | Codex CLIchecked at 0.162.1 | Claude Codechecked at 2.1.299 | Cursor Agentchecked at 2026.10.12-d47ca18 | OpenCodechecked at 2.0.28 | pichecked at 1.2.0 |
|---|---|---|---|---|---|
| Customise the summary or hook in | Set | Pass instructions to Blocking an automatic compaction that was triggered to recover from an overflow makes the request fail with the original error. Source | Partly You can't change the summary prompt. A | Plugins can register OpenCode appends its own summary prompt after the hooks run, so a hook cannot replace it except by supplying | Yes, through extensions. The event payload includes |
| When a request overflows anyway | Partly If a normal request still overflows, the turn ends with "Codex ran out of room in the model's context window. Start a new thread or clear earlier history before retrying." Codex then marks the context as full, so the next turn compacts before sending, but it does not retry the failed request. If the compaction request itself overflows during local compaction, Codex drops the oldest history items one at a time and retries. Codex compacts and retries in the same turn only for Guardian auto-review sessions whose review budget is exhausted. Source | If the API rejects a request as too long ( A single-exchange conversation can't be compacted; the error explains whether your content or the system prompt, tools and attachments fill the request.
| Since v2026.10.08, a session that hits the context limit summarizes and then continues the turn instead of getting stuck. An earlier fix (v2026.09.15) stopped long Claude and GPT turns from re-compacting on every step without freeing any space. Source | If the provider rejects a request as too long, OpenCode compacts, aiming at 70% of the rejected size, and retries once. A second rejection is returned as an error. If the summary request itself is too long, OpenCode sends a flattened text version and shrinks it to 70%, 50%, then 35%, dropping the oldest exchanges, before giving up. With The docs' Settings table says | If the provider returns a context-overflow error, or a response stops early with Recovery is skipped when Custom providers with unusual overflow messages must map them to |