Codex Context Window: Size, Limits & What Happens When It Fills
There is no single universal Codex context-window number. The working context size depends on the active model, client release, and whether your configuration uses default catalog boundaries (such as 272,000 tokens) or scales up to native model specifications (up to 1,050,000 tokens on GPT-6 Astra and GPT-5.6 Sol).
Crucially, your context window is not your plan usage limit. Your context percentage measures active session memory in tokens, while your 5-hour rolling and weekly percentages measure account compute allowance. When a session reaches high context utilization, Codex does not cut you off or mark your subscription quota exhausted—it triggers automatic context compaction to summarize older history so your work can continue seamlessly.
Working token capacity per session. Varies by active model and catalog profile.
Codex automatically condenses older turns before working memory overflows.
Clearing context does not reset your 5-hour or weekly subscription usage meter.
Codex Context Window vs. Codex Usage Limit
The context percentage in the CLI statusline gets read as a subscription limit. It is a different boundary from the account quota reported by /status in the CLI:
| Dimension | Context Window (Working Memory) | Plan Usage Quota (Subscription Allowance) |
|---|---|---|
| What It Governs | How much active conversation history, file content, and tool outputs the model can hold in memory at once. | How much model inference compute your account can consume across all sessions and shared surfaces. |
| Scope | Per conversation/session. Starting a new session resets this meter to 100% available context. | Account-wide. Shared across all CLI sessions, IDE extensions, ChatGPT Work, and Cloud tasks. |
| Unit of Measure | Tokens (e.g., 272,000 or 1,050,000 max capacity; shown as % context remaining). | Percentage of plan allowance remaining (5-hour rolling window and weekly cycle). |
| What Happens at Ceiling | Codex triggers automatic compaction to condense history and keep working. Prompts do not pause. | Prompts pause until the rolling 5-hour or weekly reset time, or unblocked via banked resets or credits. |
| Primary Guide | This guide (/context-window) | Codex Usage Limits by Plan (/limits) |
Running out of context window never burns up your 5-hour limit, and running /compact or starting a new session never gives you more subscription quota. However, repetitive turns with bloated context force the model to re-process large token volumes repeatedly, which accelerates how quickly your plan allowance depletes. See our guide to what counts toward Codex usage.
How Large Is the Codex Context Window?
Three different numbers get quoted as “the context window”, and they are not the same thing: the foundation model's published context, the default catalog window Codex enforces, and the headroom you actually get after runtime reservations.
| Model Variant | Published Model Spec | Codex Catalog Default | Effective Headroom | Auto Compaction | Source |
|---|---|---|---|---|---|
GPT-6 Astra gpt-6-astra | 1,050,000 tokens | 1,050,000 tokens (or 272k in standard pricing profiles) | ~997,500 tokens (95% headroom scaling) | Auto (~90% threshold) | OpenAI Codex Models Reference |
GPT-5.6 Sol gpt-5.6-sol | 1,050,000 tokens | 272,000 tokens (standard catalog default) | ~258,400 tokens (effective working headroom) | Auto (~90% threshold, ~232,560 tokens) | OpenAI Codex Models Reference |
GPT-5.6 Terra gpt-5.6-terra | 1,050,000 tokens | 272,000 tokens (standard catalog default) | ~258,400 tokens (effective working headroom) | Auto (~90% threshold, ~232,560 tokens) | OpenAI Codex Models Reference |
GPT-5.6 Luna gpt-5.6-luna | 128,000 tokens | 128,000 tokens | ~121,600 tokens (effective working headroom) | Auto (~90% threshold, ~109,440 tokens) | OpenAI Documentation |
GPT-5.3-Codex-Spark gpt-5.3-codex-spark | 128,000 tokens | 128,000 tokens | ~121,600 tokens | Auto (~90% threshold) | OpenAI Research Preview Notes |
Model deprecation context: Older GPT-5.4 models retired from Codex with ChatGPT sign-in on August 31, 2026. OpenAI officially instructs developers using saved configurations to migrate to gpt-5.6-terra or gpt-5.6-sol (see our recommended model guide).
Why Codex May Show a Different Number
If an OpenAI announcement advertises a 1,050,000 token context window for GPT-5.6 Sol or GPT-6 Astra, why do Codex CLI telemetry logs or status indicators often show a 272,000 token ceiling? Three structural runtime factors explain this gap:
In OpenAI's developer rate cards, standard per-token pricing applies up to 272,000 input tokens. Requests exceeding 272k tokens incur an extended-context multiplier (2x input and 1.5x output). Codex default client catalogs set 272,000 to keep standard sessions within the baseline pricing bracket.
Codex reserves operational headroom for maximum generated output tokens (max_output_tokens) and compaction execution. A 272,000 raw ceiling yields an effective session working capacity of approximately 258,400 tokens (a 95% multiplier) before auto-compaction triggers.
Codex clients fetch dynamic model capabilities from OpenAI servers upon authentication. If an active subscription tier or runtime surface enforces a conservative catalog profile, manually setting higher numbers in configuration files will be clamped by the runtime to the authorized catalog limit.
What Counts Toward the Context Window?
Every turn of an active Codex session appends data to the model's cumulative prompt. The context window must hold all of the following elements simultaneously:
Base persona instructions, tool schema definitions, environment metadata, and project-specific instructions (such as AGENTS.md or .cursorrules) load into context on turn zero.
Every prompt you submit and every response the assistant outputs remains in working memory for subsequent turns until context compaction occurs.
Standard output and error streams from bash commands (e.g., verbose test runners, build stack traces, package installation logs) accumulate token by token in the active transcript.
Files read by Codex tools during repository inspection, multi-file edits, and diff generation reside in working context as input tokens.
For reasoning models (like GPT-6 Astra and GPT-5.6 Sol), internal chain-of-thought thinking tokens occupy space directly inside the active context window during generation, consuming headroom alongside standard text output.
What Happens When the Context Window Fills?
When an agentic session accumulates thousands of lines of terminal output and code edits, the context window inevitably nears capacity. Here is exactly what happens:
As token consumption hits the compaction threshold (by default around 90% of active capacity, or the value set in model_auto_compact_token_limit), Codex pauses turn execution to run an automated compaction pass.
Codex replaces older conversation turns, bulky tool outputs, and intermediate file contents with a concise summary representation (or encrypted server-side session state). Critical task objectives, architecture decisions, and recent file changes are preserved, while verbose logs and stale file dumps are discarded.
Following compaction, your statusline updates immediately: context utilization drops from ~90% back down to 20%–35%, freeing substantial headroom for new commands, file reads, and completions.
While compaction keeps sessions from hard-crashing on token errors, compaction is inherently lossy. Granular error traces or exact code snippets from 40 turns ago may be omitted from the compacted summary. Furthermore, sessions with multiple successive compactions can suffer from subtle context drift and slower latency. For major architectural changes or completely separate tasks, starting a fresh session (/new in CLI) is generally cleaner and more token-efficient than relying on 4+ compactions in a single thread.
GPT-6 Astra Experimental Context Management
Experimental Opt-InStandard Codex behavior still uses compaction when active context approaches its limit. However, GPT-6 Astra now has an experimental alternative on supported Codex clients: Astra context management.
When enabled, Astra can maintain notes across context windows and search earlier messages and tool results from the same task instead of relying only on repeated summary compaction. This allows the model to retain structured task state and retrieve earlier interaction details across context windows rather than compressing everything into a single lossy summary.
~/.codex/config.toml):- Experimental and off by default: The mode is experimental at launch and disabled by default. It must be explicitly configured in your client settings.
- Supported plan eligibility: Current OpenAI model documentation states that supported users signed in with ChatGPT Plus or Pro can opt in. Business, Enterprise, and API-key sign-in are excluded at launch according to the current model documentation.
- Requires a new task: The user must enable the setting and then start a new task for the feature to take effect.
- No token savings or quota changes: Opting into experimental context management does not provide lower quota consumption, token savings, increased subscription limits, or perfect, lossless memory. Standard compaction remains active across other models and unconfigured sessions.
Manual Compaction (/compact)
You do not have to wait for Codex to reach 90% context before trimming your transcript. You can manually force compaction at any time:
Inside any active Codex CLI session, type /compact and press Enter. Codex will immediately summarize the prior conversation transcript, purge intermediate tool logs, and reclaim available working memory.
- Right after running a verbose test suite or large database dump that added thousands of disposable log tokens.
- Before pasting or introducing a large new file into the conversation to ensure ample headroom for deep reasoning.
- When switching sub-tasks within the same repository without wanting to lose overall environment state.
Advanced Configuration: model_context_window & Auto-Compaction
Codex CLI and desktop environments share a configuration file located at ~/.codex/config.toml. You can customize context sizing and compaction behavior using documented top-level parameters:
Sets the target maximum tokens for the active working context. If omitted, Codex defaults to the active model catalog baseline (e.g. 272,000).
Defines the specific token count that triggers automatic compaction. Leaving some margin below the context ceiling ensures room for completion tokens.
Accepts "total" (evaluates full working context) or "body_after_prefix" (evaluates growth since the last compaction prefix).
Configuring a higher number in config.toml does not magically grant an unsupported model larger context. If the model natively caps at 128k (like Luna) or the upstream catalog clamps the subscription tier to 272k, Codex will respect those runtime constraints.
Context Window vs. “Usage Draining Fast”
Many developers experiencing rapid quota depletion mistakenly assume their context window is “leaking” or that reaching 90% context depleted their subscription allowance.
While having a huge context window and running high-turn agent loops can accelerate quota burn (because processing 200,000 tokens on turn 40 costs far more compute than processing 5,000 tokens on turn 1), they are different meters.
If your 5-hour rolling percentage or weekly quota is plummeting unexpectedly, check our comprehensive diagnostic triage for platform issues, idle drain reports, and tool-loop amplification.
Read Why Is Usage Draining So FastSee exactly which surfaces (Codex CLI, IDE extensions, ChatGPT Work, Excel integration, and Workspace Agents) draw from your shared allowance versus independent model limits.
Read What Counts Toward Codex UsageDoes a Larger Context Window Increase Codex Usage?
Codex Usage First-Party TestTo test whether supplied context size by itself changes observed usage draw, Codex Usage ran a controlled experiment on ChatGPT Plus: the same gpt-5.6-sol model, the same Medium reasoning effort, the same frozen coding task, starting workspace, and instructions, and the same deterministic 112-test grader in a clean isolated Codex environment — with only the amount of supplied input context changed between the two runs. Codex Usage snapshots of the displayed 5-hour and weekly percentages were taken immediately before and after each run.
| Condition | Input Tokens | Deterministic Result | Runtime | Measured 5-Hour Movement |
|---|---|---|---|---|
| Small Context | 171,739 | 112 / 112 | 92.0s | 2 percentage points |
| Large Context+~500K char neutral reference block | 1,113,661 | 112 / 112 | 111.9s | 7 percentage points |
The large-context run supplied about 6.5× more input tokens than the small-context run. That coincided with +5 percentage points of additional observed 5-hour movement (2pp → 7pp) and a runtime about 22% longer, while deterministic correctness was unchanged — both runs passed all 112 tests.
This table reports Codex Usage's own observed measurement, not official OpenAI quota documentation. It reflects one controlled run per condition on ChatGPT Plus with GPT-5.6 Sol at Medium reasoning, with no retries. The 5-hour and weekly meters are displayed in whole percentage points, so any movement below that resolution reads as zero. This result does not establish a token-to-quota conversion rate: it shows that, in this single controlled run, substantially more supplied context coincided with substantially greater observed allowance draw even though task correctness was unchanged. Treat it as one data point, not a formula to apply to your own sessions.
See how this pattern shows up in quota diagnostics on Why Is Usage Draining So Fast and how it interacts with the 5-hour window on the Codex 5-hour limit guide.
Codex Context Window FAQ
Common questions about context sizing, compaction, and how it differs from plan quota:
What is the Codex context window?
The Codex context window is the working memory available to the model during a single conversational session. Measured in tokens, it holds your instructions, user prompts, assistant replies, reasoning tokens, tool interactions, and any file contents or terminal outputs read during that session.
How do I check my Codex context window and remaining percentage?
The Codex CLI keeps a live context-remaining figure in the statusline at the bottom of the terminal. If it is showing roughly 82% left, that is 82% of the session's context window still free, which is working memory rather than subscription quota. You can also run /status inside the CLI to inspect your session telemetry and token distribution. In desktop and web interfaces, context is managed automatically in the background.
What happens when Codex reaches 100% context?
When context approaches capacity (typically around 90% utilization), Codex does not terminate your session or fail. Instead, it triggers automatic compaction, summarizing earlier turns and bulky tool outputs to clear working memory while preserving key decisions and recent state.
Does GPT-6 Astra still use context compaction?
Standard compaction remains relevant and active by default across all models, including Astra. However, eligible Astra users signed in with ChatGPT Plus or Pro can currently opt into experimental context management, which maintains notes across context windows and can retrieve earlier messages and tool results from the same task.
Does /compact reset Codex usage?
No. Running /compact only compresses working memory in your local conversation transcript to free up context window tokens. It has zero effect on your 5-hour rolling quota or weekly subscription allowance, which track model compute across your account.
Does a larger context window give me more weekly Codex usage?
No. Context window and subscription quota are independent mechanisms. A 1M context window allows you to hold more code and conversation history in memory simultaneously, but processing more tokens in that window can actually consume your subscription quota faster.
Can I change model_context_window in Codex?
Yes, you can set model_context_window in ~/.codex/config.toml for models that support larger context (such as setting 1000000 for gpt-5.6-sol). However, this only works if the underlying model and server-side catalog permit that window size; unsupported models will clamp to their maximum allowable ceiling.
Why does Codex show a 272k context window instead of 1M?
Although models like Sol and Terra support 1M+ tokens upstream, Codex client profiles often default to 272,000 tokens. This boundary aligns with OpenAI's standard pricing tier (prompts over 272k tokens trigger higher token rates) and preserves stable memory and latency performance.
Related Quota & Limit Documentation
Check official 5-hour and weekly quota allowances across Free, Plus, Pro, and Business tiers.
Understand Terra, Sol, and Astra presets and how model selection balances capability against token burn.
How rolling 5-hour recovery and weekly plan quota resets work when you reach subscription limits.
- Codex usage dashboard & token history — client telemetry and desktop analytics.
- OpenAI Codex pricing guide — plan costs and seat economics.
- developers.openai.com/codex/models — OpenAI's own model reference.