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.29 | 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. | 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 15% of the window or 16,000 tokens, whichever is larger (models under 32k keep just 15%). 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. The 2.1 default is earlier than the previous 10% reserve. v2.1.1 uses floor(window × 0.15); an explicit compaction.buffer overrides the default. | 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. |
| 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 A subagent can compact earlier with Turning auto-compact off also turns off idle compaction; set 2.1.302 adds an Idle compaction row in /config to turn the idle pass off or back on, alongside the existing idleCompaction setting. Published changes also fix stopping a turn during compaction causing Prompt is too long. Before 2.1.304, suffixes could be parsed as a small integer and clamped to 100K. The 2.1.304 changelog says k and M suffixes now work, with warnings for out-of-range or ignored values. | 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 | 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. | 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 approximate 85% trigger is the default in 2.1, not a universal configured threshold; the 16K minimum advances it on small windows. | 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.29 | 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. In 2.1.301, switching to a smaller model window can first summarize the conversation with the previous model. The release also fixes repeated compaction when a gateway reports a different model name. These are published changes, not a new measured threshold. | Partly Cursor's backend writes the summary, not your local CLI. The CLI sends a summarize action and shows | In 2.1, summary compaction normally sends the whole conversation, including the tail that will be kept, to the summary model so it can reuse the normal prompt cache. It writes a structured checkpoint (Objective, Requirements, Decisions, Work State, Next Move, Relevant Files, Important Context), and later requests combine that summary with recent text reconstructed from metadata.keepID. If the whole request cannot fit, the implementation falls back to the history before the retained tail and then progressively shrinks it. A supported native compaction instead stores its provider replacement window in native.messages. The docs say there is no separate compaction model, but the source does honor a model set on the hidden The summary call no longer stores unused provider replay data. A compaction hook may still supply result.native; native.messages overrides text replay when present. | 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. |
| 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. | 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. Before 2.1.304, /reload-skills was the documented way to restore the catalog after compaction; the 2.1.304 release changes this behavior as described below. 2.1.304 resends the skill list after compaction; /reload-skills sends only new or changed skills. This listing is separate from restoring invoked skill bodies. | 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. | About Since 2.1, newly written summaries reference the first retained message with metadata.keepID instead of duplicating recent text. History reconstructs the text up to the checkpoint; forks remap this reference. Legacy recent text is decoded as metadata.recent. | 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. |
| 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. | 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 | 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 remain stored. In 2.1, a completed summary stores summary text and metadata.keepID referencing the first retained message; history reconstructs the kept text rather than duplicating it in the checkpoint. Legacy compactions retain their text through metadata.recent. Native checkpoints store native.messages. The TUI shows compaction as it starts, streams and ends. | 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.29 | 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. | 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 2.1 replaces SessionCompactionResult.providerState with native. Hook metadata can override keepID; result.native.messages supplies a replacement message window. The obsolete session.compacted event is removed; use session.compaction.started/ended. | 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. | 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.
2.1.304 fixes prompt/context-limit errors after interrupting compaction of a conversation rejected as too long, according to the release notes. | 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. | 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 In 2.0.29, output-token-limit (finish reason length) recovery is separate from context-overflow compaction: source adds continuation guidance and fails after three consecutive length-limited assistant responses (two continuations). In 2.0.30, the summary request and its retry reduce the output-token allowance to fit the actual estimated prompt remaining in the model window. This is summary request budgeting, not a new auto-compaction threshold. | 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 |