Original URL: https://getagenttools.com/blog/codex-context-window/

# Codex context window: 500K or 272K per model, what /status shows, and when compaction runs

8 Nov 2026Marek.

- codex
- coding-agents
- context-engineering

The Codex context window depends on the model. In Codex CLI 0.166.0 the model catalog gives GPT-6.1 Sol and GPT-6.1 Terra 500,000 tokens. GPT-6 Luna, GPT-6 Sol, GPT-6 Astra and the GPT-5.6 models get 272,000. Codex keeps 95 percent of that for the conversation and starts compaction at 90 percent. The two keys below change the numbers. They go at the top of `config.toml`.

 

```toml
model_context_window = 272000
model_auto_compact_token_limit = 200000
```

  

- **Size.** 500K tokens on GPT-6.1 Sol and Terra, 272K on the other listed models. The API pages for GPT-6.1 Sol and GPT-6 Luna list 1,050,000. Codex caps them.
- **Where to look.** `/status` prints "N% left (used / window)". The footer says "N% context left". `codex exec` ends with "tokens used".
- **Full.** Codex compacts automatically at 90 percent of the window. `/compact` does the same on demand.
- **Override.** `model_context_window` sets the window. The catalog caps it at 872,000 on every listed model, so `1000000` does not give you 1M.
- **My tests.** Three `codex exec` runs and one `codex debug models` read on 31 October 2026. With a 20,000-token window Codex dropped the skill descriptions and still answered.

 

How the Claude Code side works, with the 33 edits I wasted after compaction, is in my [Claude Code context window](https://getagenttools.com/blog/claude-code-context-window/) post. This one is Codex.

 

## What is the Codex context window size?

 

Per the catalog my Codex CLI 0.166.0 install fetched, GPT-6.1 Sol and GPT-6.1 Terra have a `context_window` of 500,000 tokens. GPT-6 Luna, GPT-6 Sol, GPT-6 Astra and the three GPT-5.6 models have 272,000. Every visible model carries a `max_context_window` of 872,000. I read them with `codex debug models` on 31 October 2026.

 

The API docs say something else. The [GPT-6.1 Sol page](https://developers.openai.com/api/docs/models/gpt-6.1-sol) lists a 1,050,000 token context window and adds that the model "uses a default context window of 500K tokens in Codex and ChatGPT Work". The [GPT-6 Luna page](https://developers.openai.com/api/docs/models/gpt-6-luna) lists 1,050,000 too and says nothing about Codex. Codex gives it 272,000. The November models follow the same split in Codex CLI 0.169.0: 272,000 on [GPT-6.2 Astra](https://getagenttools.com/blog/gpt-6-2-astra/) and 500,000 on GPT-6.2 Sol.

 

One cut comes after the catalog number. In the source, `effective_context_window_percent` is 95 for every model. For a 272,000 model the usable window is 258,400 tokens. That is where the "258k" people search for comes from, I think. For GPT-6.1 Sol it is 475,000. A [context window](https://getagenttools.com/blog/what-is-an-ai-context-window/) is the full budget. The usable window is what you can fill.

 

## How do I check how much context is left in Codex?

 

Type `/status` in the TUI. The [slash commands page](https://learn.chatgpt.com/docs/cli/slash-commands) says it will "display session configuration and token usage". In the 0.166.0 source the line reads "N% left (used / window)". The footer shows "N% context left".

 

The percent is not used divided by window. In `token_usage.rs` the TUI treats the first 12,000 tokens as a baseline and does not count them. I did not open the TUI to see what it shows. The [Codex statusline](https://getagenttools.com/blog/codex-statusline/) items `context-used`, `context-remaining` and `context-window-size` draw from the same data.

 

Outside the TUI you get a count, not a percent. `codex exec` prints "tokens used" and one number at the end. On my Mac a one-word reply cost 9,996, my installed skills included. With `--json` the last event was `turn.completed` with `input_tokens` 22,279, `cached_input_tokens` 12,288 and `output_tokens` 5. The plain number is input minus cached input, plus output.

 

## What happens when the Codex context window is full?

 

Codex compacts. The docs describe `/compact` as "summarize the visible chat to free tokens". In `openai_models.rs` the auto-compact limit is 90 percent of the resolved window. In the default `total` scope the code clamps `model_auto_compact_token_limit` to that 90 percent. In the `body_after_prefix` scope, `context_window.rs` takes the config value as it is.

 

So on GPT-6.1 Sol the summary starts at 450,000 tokens. On a 272,000 model it starts at 244,800. The 95 percent usable window is a second, hard cap in `context_window.rs`.

 

What compaction keeps is a summary. `compact.rs` builds a new history from a summary with a fixed prefix, your user messages, and the initial context Codex rebuilds. If the summary request itself overflows, Codex logs "Context window exceeded while compacting; removing oldest history item" and retries with less. `codex exec` prints "context compacted" when it happens. I did not reach that line in my tests. The `compact_prompt` key overrides the summary prompt. `codex features list` on 0.166.0 shows `async_compaction` and `context_management` as under development and off. opencode compacts with 15 percent of the window left by default, covered in [opencode context window](https://getagenttools.com/blog/opencode-context-window/).

 

## How do I set the Codex context window in config.toml?

 

Set `model_context_window` at the root of `config.toml`. The [config reference](https://learn.chatgpt.com/docs/config-file/config-reference) defines it as "context window tokens available to the active model".

 

The override has a ceiling. In `model_info.rs` Codex takes the smaller of your value and the model's `max_context_window`. On 0.166.0 that is 872,000 for every listed model. Write `1000000` and you get 872,000. Whether the endpoint accepts that much, I did not test.

 

Going small works and has a side effect. My third `codex exec` run used `-c model_context_window=20000` on 31 October 2026 at 12:36 CET. Codex printed a warning: "Exceeded skills context budget. All skill descriptions were removed". The reply was still "ok", at 2,227 tokens used instead of 9,996. `skills.max_context_tokens` defaults to 2 percent of the window, so 20,000 leaves about 400 tokens for the skills catalog. "Too small" in Codex looks like that.

 

## How does the Codex context window compare with Claude Code's?

 

Codex gives you 500K or 272K tokens by model and compacts at 90 percent of that. Claude Code starts at 200K, goes to 1M on some models, and lets you move the trigger with `autoCompactWindow`. After compaction Claude Code reloads named files from disk. Codex rebuilds its initial context and keeps a summary.

 

|  | Codex CLI 0.166.0 | Claude Code |
| --- | --- | --- |
| Default window | 500K on GPT-6.1 Sol and Terra, 272K on the other listed models | 200K, 1M on models that support it |
| Live view | `/status`, footer, status line items | `/context`, status line script |
| Auto compaction | 90% of the window, clamped in `total` scope | At the model limit, or `autoCompactWindow` |
| Manual | `/compact` | `/compact` with a focus |
| Window override | `model_context_window`, capped at 872K | `[1m]` suffix, `CLAUDE_CODE_MAX_CONTEXT_TOKENS` |
| After compaction | Summary, user messages, rebuilt initial context | Summary plus files reloaded from disk |

 

I did not find a reload list in the Codex docs. Continuing a session later is covered in [Codex resume](https://getagenttools.com/blog/codex-resume/). Copilot CLI compacts earlier, near 80 percent, and picks its window by model and tier, covered in [Copilot CLI context window](https://getagenttools.com/blog/copilot-cli-context-window/).

 

## Frequently asked questions

 

### Does Codex have a 1M context window?

 

Not in Codex CLI 0.166.0. The API page lists 1,050,000 tokens for GPT-6.1 Sol and GPT-6 Luna. The Codex catalog gives them 500,000 and 272,000. An override is capped at 872,000. The cap is in the catalog and the source, not in the docs.

 

### Why does Codex show 258k context?

 

272,000 times 95 percent is 258,400. The catalog gives GPT-6 Luna, GPT-6 Sol, GPT-6 Astra and the GPT-5.6 models 272,000 tokens. The source keeps 95 percent of it. The same cut gives 475,000 on GPT-6.1 Sol.

 

### Does codex exec compact the context?

 

The code path is the same. The exec output has a "context compacted" line for it. I have not seen it fire. My three runs were one-word prompts.

 

### What does "Exceeded skills context budget" mean?

 

The skills catalog did not fit its budget, 2 percent of the window. Codex removed the descriptions and went on. I got it by setting `model_context_window` to 20,000.

 

## The verdict

 

I use Codex every day as a worker next to Claude Code. Remember 500K on GPT-6.1 Sol and Terra, 272K on the other listed models, with compaction at 90 percent. Do not chase 1M with `model_context_window`. The cap is 872K. Approval and sandbox flags: [Codex dangerously skip permissions](https://getagenttools.com/blog/codex-dangerously-skip-permissions/).

 

Sources, read on 31 October 2026: the Codex [config reference](https://learn.chatgpt.com/docs/config-file/config-reference), [advanced config](https://learn.chatgpt.com/docs/config-file/config-advanced) and [slash commands](https://learn.chatgpt.com/docs/cli/slash-commands) pages, the [GPT-6.1 Sol](https://developers.openai.com/api/docs/models/gpt-6.1-sol) and [GPT-6 Luna](https://developers.openai.com/api/docs/models/gpt-6-luna) model pages, and [openai/codex](https://github.com/openai/codex) at tag `rust-v0.166.0`. The catalog values and the runs are from my Mac.

Put this into practice

[See the tool list](https://getagenttools.com/tools/)[Train your team](https://getagenttools.com/#training)
