Log in

Codex field guide · September 16, 2026

Codex Context Window: Compact Without Losing the Task

Distinguish working context from account usage, create a durable checkpoint, and choose the right continuity command before a long task starts repeating itself.

TM
Tony MartinsSeptember 16, 2026
12 min read
Protect the task state
codex://active-contextpressure 78%
Working set
instructions · files · tools · decisions
/compact
Carried forwardsummary + checkpointnext action remains explicit
Outside the transcriptdurable task state

Direct answer

Compact the conversation. Preserve the task somewhere durable.

The Codex context window is the active model's finite working set—not the complete saved transcript and not your account usage limit. Use /status to inspect the live session. Codex can compact a long chat automatically; /compact requests a concise replacement for earlier turns so the same job can continue with more room.

Before that boundary, record the objective, completed work, decisions, changed files, proof, blockers, and exact next action. Compact when the objective is unchanged, fork when the approach branches, and start new when the job changes. If you want guided durable artifacts and cleaner tool output around that native workflow, install Supercode for Codex.

01

Name the surfaces

The context window is one of four different kinds of state

“Context” is often used for the working set, the saved chat, the usage meter, and repository knowledge. They have different lifetimes. Compaction changes only one of them directly.

model-visible now

Active context

Instructions, conversation, selected files, tool results, and generated text in the current working set.

product history

Saved transcript

The stored chat can be resumed or inspected even when every old item is no longer active verbatim.

separate allowance

Account usage

Plan and rate-limit consumption across work. Compacting or starting new does not reset this meter.

repository truth

Durable state

Plans, specs, ADRs, task notes, code, tests, and evidence that another session can read again.

Official definition

OpenAI defines model_context_window as the context-window tokens available to the active model. The stable answer is therefore not one permanent number for “Codex.” Inspect the model and working session you are actually using.

02

The inputs

What fills the Codex working set

A repository task consumes context before any code is written. Durable instructions, the conversation, file contents, search results, build logs, screenshots, tool schemas, and the agent's own output all compete for the active surface.

The expensive pattern is not a large repository by itself. It is repeatedly importing broad material without narrowing the next decision. A 20,000-line log with one useful stack frame creates pressure. Re-reading five architecture documents before every small edit does too.

01
Instructions

Durable rules and the active task prompt

02
Repository

File excerpts, search results, and documentation

03
Tools

Commands, logs, test output, screenshots, and schemas

04
Reasoning trail

Decisions, rejected alternatives, and generated text

Active window
Inspect the payload, not the clock.

One command can return megabytes; many concise decisions can remain manageable.

03

The boundary

What Codex compaction actually does

OpenAI documents /compact as replacing earlier turns with a concise summary that frees context while retaining critical details. Its best-practices guide says Codex also compacts long chats automatically.

BeforeRaw turns + tool results

The full active history approaches the current model's working limit.

Summarizemanual or automatic
AfterSummary + recent work

The same chat continues, but earlier model-visible material has changed form.

That makes compaction a continuity mechanism—not a cache clear, quota reset, or new objective. Operationally, treat the boundary as lossy. A summary must choose what to retain; an obscure constraint, failed command, rejected alternative, or exact next file may receive less detail.

This is an inference from summarization, not a claim that Codex always forgets those facts. Manual compaction is easiest to recover at a phase boundary: after diagnosis, after an accepted plan, or after implementation and before validation.

04

The first diagnostic

Inspect pressure with /status before changing anything

codex
/status
modelactive selectioncontextcurrent token usageworkspacedirectory + writable rootsexecutionapproval + sandbox

Read the live result in order. Confirm the model first, because the working capacity and catalog defaults can differ. Then verify actual token pressure, the repository, and the execution boundary. A permissions interruption can look like lost state when the real blocker is access.

Next inspect the pattern: repeated large-file reads, duplicated logs, several objectives in one chat, or an interrupted turn whose durable repository state is unclear. Do not tune the automatic threshold first. Moving the boundary cannot fix an undefined objective or noisy input.

05

The recovery artifact

Write this checkpoint before /compact

The record should be short enough to scan and concrete enough to resume. Save it in the repository when the work must survive another chat, another executor, or another day.

## Task checkpoint

Objective:

Done:

Decisions and constraints:

Changed files:

Validation evidence:

Open blockers:

Next action:
Weak

“Continue the refactor.”

Recoverable

Update SessionStore.resume() to use the validated cursor, then run SessionStore.spec.ts.

A useful checkpoint records why alternatives were rejected and names the proof already collected. After saving it, ask Codex to read the file and confirm the next action before compacting. The artifact does not eliminate summarization risk; it gives recovery an authoritative source.

06

The command router

Compact, fork, new, or resume?

Choose the command from the relationship between the old work and the next objective. They are continuity tools, not interchangeable ways to “clear context.”

/compact
Same objective · same approach · working set under pressure

Continue the coherent task with summarized earlier history.

/fork
Same history · genuinely different approach

Explore an alternative in a new chat ID while preserving the original.

/new
Different objective · same repository

Start with a clean working set instead of carrying irrelevant decisions.

/resume
Return to a saved coherent task

Reload the saved transcript and continue from its existing history.

OpenAI recommends one chat per coherent unit of work—not one chat per repository or one per day. A bug investigation and its fix can be one unit. An unrelated feature should not inherit that debugging trail merely because it touches the same codebase. Resuming restores a saved chat; it does not imply that every historical item becomes active verbatim at once.

07

The failure path

Recover when Codex starts repeating itself

Some users have reported version- and environment-specific loops around compaction, reconnects, and repeated file reads. Those reports expose useful failure shapes; they do not prove that the current client normally behaves that way.

Repeated reads are the signal. The cause could be a regression, an interrupted stream, broad instructions, missing phase state, or a tool that floods the transcript. The next proof should separate those possibilities rather than assume one.

  1. 01
    Stop adding work

    Do not queue another objective into an ambiguous session.

  2. 02
    Inspect the session

    Record the model, workspace, current pressure, and execution policy.

  3. 03
    Check durable state

    Use Git status and focused tests to separate narration from actual changes.

  4. 04
    Write the checkpoint

    State what is proved, what is unknown, and the smallest next action.

  5. 05
    Route continuity

    Compact, fork, or start new according to the objective—not frustration.

  6. 06
    Reproduce before tuning

    Capture the current client and minimal inputs before changing thresholds.

08

The control plane

Advanced controls are not the first fix

Codex exposes real context controls, but arbitrary numbers copied from another model or release can create a second problem. Keep the current catalog defaults unless you have a reproducible reason, a measured change, and a rollback.

ControlWhat it changesMaturity
model_context_windowAvailable context tokens for the active modelUsually catalog-driven
model_auto_compact_token_limitThreshold that triggers automatic history compactionUnset uses model defaults
model_auto_compact_token_limit_scopeCount total active context or growth after a carried prefixAdvanced tuning
context management experimental modeUse notes and searchable history instead of one repeated summaryOff by default · gated
PreCompact / PostCompactRun lifecycle hooks around manual or automatic compactionAutomation only

Experimental context management

The current reference describes notes plus searchable history instead of repeatedly compressing everything into one summary. It is explicitly experimental, off by default, and currently account-gated. Evaluate it; do not describe it as the universal default.

Compaction hooks

PreCompact and PostCompact can distinguish manual from automatic triggers. Teams can record telemetry or enforce a local process, but hooks add operational complexity and can stop the transition. They are not required for normal continuity.

09

The product boundary

Where Supercode fits—and where it does not

Native Codex owns the model window, /status, /compact, automatic compaction, forks, saved chats, and experimental context management. Supercode does not expand that window or guarantee perfect recall.

If those adjacent layers match your workflow, install Supercode for Codex and keep the native continuity decision explicit. The useful outcome is less avoidable input and more recoverable project knowledge—not a larger advertised window.

10

The preflight

Codex context continuity checklist

  • I used /status to inspect the live session instead of assuming a universal limit.
  • I can name the one coherent objective this chat owns.
  • Large files and tool output are narrowed to the evidence needed for the next decision.
  • The objective, completed work, constraints, files, proof, blockers, and next action are recorded.
  • I chose /compact, /fork, /new, or /resume for the actual continuity problem.
  • I verified repository state before trusting a resumed narrative.
  • I left advanced thresholds at their defaults unless I can reproduce and measure a reason to change them.
  • I marked experimental context management as experimental.
  • I did not confuse context capacity with account usage.

The goal is not to avoid compaction forever. It is to keep the task recoverable when the active window changes.

Primary evidence and dated reports

Sources and freshness

Codex commands, configuration, hooks, and experimental availability can change. Primary mechanics were reviewed on September 16, 2026. GitHub reports are directional examples from specific environments, not prevalence evidence.

The next useful action

Make the project state easier to recover

Add guided repository artifacts, bounded project context, and tool-output hygiene around the native Codex continuity workflow. The model window and compaction mechanism remain under Codex control.

Install Supercode for Codex
TM

Research and editorial review

Tony MartinsChief of Research at Supercode. Field notes on context engineering, agent workflows, and recoverable systems beyond the demo.
Back to top