Agentic AI AcademyAgentic AI Academy

Models, Reasoning Effort & Compaction

Picking the right brain and managing long-horizon context

Intermediate 14 minBuilderDecision-maker
What you'll be able to do
  • Be able to read the Codex model catalog and decode the naming convention (plain vs -codex vs -mini vs -spark vs -max)
  • Be able to select a model three ways — the -m/--model flag, model = in config.toml, and /model in-session — and explain when to leave it unset
  • Be able to set reasoning effort with model_reasoning_effort and reason about the minimal→xhigh ladder and its latency/quality trade-off
  • Be able to explain why each model has a different default effort and why xhigh is model-dependent
  • Be able to distinguish a model's API context window from the effective window Codex actually uses, and opt into a larger one
  • Be able to explain compaction — how Codex prunes its own history to span multiple context windows on a single long-horizon task
At a glance

Codex runs on a family of swappable models, and two dials decide how it thinks: which model you pick and how much reasoning effort you give it. This lesson covers the model catalog and its naming convention, the three ways to select a model, the reasoning-effort levels and their per-model defaults, and the context mechanics — why Codex caps the effective window at 400K and how compaction lets a single task run across millions of tokens for hours. Because model names and defaults rot fast, you'll learn the durable concepts and where the live truth lives.

  1. 1Two dials that decide how Codex thinks
  2. 2The catalog and its naming convention
  3. 3Selecting a model — three ways
  4. 4Reasoning effort: how hard the model thinks
  5. 5Defaults are per-model (and volatile)
  6. 6Context: effective window, and compaction

Two dials that decide how Codex thinks

Before any model names, fix the mental model, because the names will change but the model won't: Codex's intelligence is governed by two independent dials.

  1. Which model runs the agent — the brain you put in the loop. Frontier brains reason harder and handle bigger, gnarlier tasks; smaller brains are faster and cheaper.
  2. How much reasoning effort that model spends per turn — how long it thinks before acting. Even one model behaves very differently at low versus xhigh.

Think of it like hiring: picking the model is choosing who does the work; setting effort is telling them how carefully to think it through. A junior who deliberates carefully can beat a senior who rushes — and vice versa. You tune both to the job.

A third concern rides alongside these two: context — how much the model can hold in its head at once, and what happens when a long task overruns it. That's where compaction comes in, and it's what turns Codex from a one-shot assistant into something that can grind on a migration for hours. We'll take the dials first, then context.

One hard truth up front, because this is the fastest-moving corner of the whole Codex product: exact model names (the gpt-5.x strings), the recommended default, per-model effort defaults, and context-window numbers change every few weeks. Everything concrete in this lesson is a June 2026 snapshot. Learn the mechanisms — they're stable — and check the live models page for today's values.

Key insight

Model × effort, not model alone

Two knobs, set independently: the model is which brain runs the loop; reasoning effort is how hard that brain thinks per turn. A mid model at high effort can outperform a frontier model at low effort. Tune both to the task.

Watch out

These facts will rot

Model identifiers, the default model, effort defaults, and window sizes change on a weeks-long cadence. Treat the specifics here as a snapshot and trust the live page — https://developers.openai.com/codex/models — for the current catalog.

The catalog and its naming convention

Codex exposes a small family of models. The identifiers below are the strings you pass to -m / --model / model =, and this is the June 2026 snapshot — names rot, so confirm against the live models page.

Model identifierWhat it's forNote
gpt-5.5Newest frontier model — complex coding, computer use, knowledge work, researchThe recommended default ("for most tasks, start with gpt-5.5")
gpt-5.4Flagship frontier for professional work, industry-leading codingOpt into a true 1M window (see context section)
gpt-5.4-miniFast, efficient mini for responsive tasks and subagents~30% of gpt-5.4 cost — the current small model
gpt-5.3-codexIndustry-leading agentic coding for complex software engineering400K context
gpt-5.3-codex-sparkText-only, ~1000 tok/sec near-instant iterationResearch preview (Pro only), 128K context
gpt-5.2Previous general-purpose model, kept for API-key workflowsLegacy compatibility

The naming convention is the durable part — once you can read a suffix, you can place a model you've never seen:

  • plain gpt-5.x — general frontier model (coding + computer use + knowledge work).
  • -codex — that generation further optimized for agentic coding in Codex: long-horizon work, big refactors/migrations, terminal use, Windows.
  • -minismaller, faster, cheaper; great for subagents and responsive tasks.
  • -sparktext-only, ultra-low-latency research-preview variant for real-time iteration.
  • -max (historical) — long-horizon variant natively trained for compaction; the suffix is retired but the capability lives on in newer models.

The lineup churns: as of June 2026 the entire gpt-5.1 family, gpt-5.1-codex-max, gpt-5.1-codex-mini, and gpt-5.2-codex have been retired from Codex, and the old codex-mini line is superseded by gpt-5.4-mini. If a tutorial tells you to run gpt-5.1-codex-max or codex-mini, treat it as historical and check the live page.

Don't confuse this family with the other two "Codexes": the 2021 Codex language model (a GPT-3 code variant, behind the original Copilot, deprecated 2023) and today's 2026 Codex agent. The gpt-5.x models here are the brains inside the 2026 agent — a completely different thing from the 2021 model that shares the name.

Tip

Decode the suffix, place the model

-codex = tuned for agentic coding · -mini = small/fast/subagent · -spark = ultra-low-latency preview · -max = compaction-trained (historical). Read the suffix and you can slot a brand-new model into the family without docs.

Watch out

Old names in old tutorials

gpt-5.1*, gpt-5.1-codex-max, gpt-5.2-codex, and codex-mini are retired from Codex as of June 2026. Seeing them in a guide is a signal the guide is stale — verify the current roster at developers.openai.com/codex/models.

Selecting a model — three ways

There are exactly three places to set the model, ordered from most local to most global. Pick by how long you want the choice to stick.

1. Per-launch, with a flag — for one thread or one codex exec run:

bash
codex -m gpt-5.5                                   # short form
codex --model gpt-5.4                              # long form
codex exec --model gpt-5.4-mini "fix the failing tests"   # headless

2. As your default, in ~/.codex/config.toml — sticks across every session until you change it:

toml
model = "gpt-5.5"

3. Mid-session, with /model — switch the brain inside the current thread without restarting. /model also lets you adjust reasoning effort in the same place. (In the IDE extension, use the model selector under the input box.)

text
/model            # opens the picker: choose model + effort for this thread

The precedence is the usual config story: a flag beats config.toml, and an in-session /model overrides both for that thread. Reach for the flag when you want a one-off ("this one task needs the big brain"), config when you have a steady preference, and /model when you're mid-task and realize you under- or over-provisioned.

One genuinely useful default-management trick: if you sign in with a ChatGPT account, the docs advise leaving model unset. With no model = line, Codex automatically tracks OpenAI's recommended default (today gpt-5.5) and you'll silently inherit the next recommended model when it ships — no config edit, no stale pin. Hard-coding model = "gpt-5.5" freezes you on that name even after it's superseded. Unset = always current.

Tip

Leave `model` unset to ride the default

On a ChatGPT account, omitting model = lets Codex track the recommended default automatically — you inherit each new recommended model with zero config changes. Only pin a specific model when you have a deliberate reason to freeze it.

Example

Right-sizing in practice

Daily driving on gpt-5.5 (unset), you hit a hairy distributed-systems bug. Type /model, bump to the frontier brain at higher effort for that thread, solve it, then /model back down for the routine cleanup afterward. The session never restarts.

Reasoning effort: how hard the model thinks

The same model can think briefly or deliberate at length. That's the reasoning-effort dial, set in ~/.codex/config.toml (or via /model in-session, or --config on the CLI). It only applies to models that use the Responses API — which the current gpt-5.x line does.

toml
model = "gpt-5.5"
model_reasoning_effort = "high"   # minimal | low | medium | high | xhigh

The ladder, from least to most thinking:

EffortWhen to use it
minimalNear-instant, trivial edits where any deliberation is wasted latency
lowEfficient reasoning for simple, well-specified tasks
mediumThe balanced interactive daily driver — the sweet spot for most work
highComplex agentic tasks needing hard reasoning, where you'll trade latency for quality
xhighThe hardest asynchronous tasks and evals that test the bounds of intelligence

More effort means more reasoning tokens, slower turns, and higher cost — but better answers on genuinely hard problems. It is not a free "make it smarter" switch; on an easy task, high effort just burns time and tokens for no gain. The skill is matching effort to difficulty: medium for the bulk of interactive work, high when you feel the model thrashing on something genuinely hard, xhigh for a long background task where you'll walk away anyway.

Two wrinkles worth knowing:

  • xhigh ("Extra High") is model-dependent. It was introduced with the compaction-trained gpt-5.1-codex-max for non-latency-sensitive work; not every model supports it. If a model doesn't, the value won't apply.
  • There's a naming seam between surfaces. The CLI config documents the lowest tier as minimal; the API model pages call it none ("no reasoning"). They're effectively the same floor — treat the CLI list (minimal | low | medium | high | xhigh) as authoritative for Codex.

A related cosmetic key controls how much of the model's thinking you see:

toml
model_reasoning_summary = "auto"   # auto | concise | detailed | none

This adjusts the reasoning-summary detail (or disables it) — it changes the display, not how hard the model thinks.

Key insight

Effort is a dial, not a brightness slider

High effort helps only when the task is genuinely hard. On easy work it adds latency and token cost with no quality gain. Default to medium, reach for high/xhigh only when you can feel the model struggling or you're running async.

Note

minimal vs none — same floor

The CLI config lists the lowest tier as minimal; the API model pages call it none. They're the same idea (least/no reasoning). Use the CLI's minimal | low | medium | high | xhigh as the authoritative Codex set.

Defaults are per-model (and volatile)

Here's the gotcha that trips people: each model ships with its own default reasoning effort. Two models that look interchangeable can behave very differently out of the box because one defaults to heavier thinking than the other.

ModelEffort levels it supportsDefault (June 2026)
gpt-5.5none, low, medium, high, xhighmedium
gpt-5.4none, low, medium, high, xhighnone
gpt-5.3-codexlow, medium, high, xhighmedium is the recommended starting point

So if you switch from gpt-5.5 to gpt-5.4 and don't set model_reasoning_effort, you've quietly dropped from medium thinking down to none — the model will feel faster but shallower, and you might wrongly conclude "gpt-5.4 is dumber." It isn't; you changed the effort dial by changing models. When you switch models, set effort explicitly unless you specifically want the new model's default.

These defaults are exactly the kind of volatile fact that rots — OpenAI tunes them per model and per release. The two facts that don't rot:

  1. The config key is model_reasoning_effort, set in ~/.codex/config.toml (or /model).
  2. Effort is per-model, so the default you get depends on which model you ran.

For the actual numbers, the live API model pages (e.g. the gpt-5.5 page) state each model's supported levels and default — that's the source of truth, not this table.

You can always see what you're running: /status shows the active model and effort in the session (something like gpt-5.5 medium · …), so a quick /status confirms whether a model switch silently changed your effort.

Watch out

Switching models can change your effort silently

gpt-5.5 defaults to medium; gpt-5.4 defaults to none. Swap models without setting model_reasoning_effort and you inherit the new model's default — which may be much lower. Set effort explicitly after a model switch, and run /status to confirm.

Context: effective window, and compaction

The third concern is context — the working memory the model reasons over. Two things surprise people here.

1. The window Codex uses is smaller than the model advertises. gpt-5.5 and gpt-5.4 advertise roughly 1,050,000-token windows in the API, but Codex defaults the effective window to 400,000 tokens — even for those 1M-token models. (gpt-5.3-codex is natively 400K; gpt-5.3-codex-spark is 128K.) You opt into a larger window explicitly in config:

toml
model = "gpt-5.4"
model_context_window = 1000000           # raise the usable window
model_auto_compact_token_limit = 512000  # token threshold that triggers auto-compaction

That 1,000,000 + 512,000 pair is the documented way to run a true 1M window with gpt-5.4. (There's an open request to expose the same opt-in for gpt-5.5, which still defaults to 400K in Codex despite its 1M API window.) The relevant keys:

  • model_context_window — context-window tokens available to the active model.
  • model_auto_compact_token_limit — token threshold that triggers automatic history compaction (unset = model defaults).

2. Compaction lets one task outlive a single window. This is the headline capability. When Codex nears its context limit, it automatically compactsprunes its own history while coherently preserving the most critical context — giving itself a fresh window, then repeats this process until the task is done. A single task can thus span multiple context windows and millions of tokens.

This was first natively trained into the compaction-tuned -max model and carried forward into the current line. It's why Codex can run genuinely long-horizon work: OpenAI observed these models iterating autonomously for more than 24 hours — fixing test failures, retrying, and delivering a result — on a single task. You can also tune the compaction prompt itself with compact_prompt (inline) or experimental_compact_prompt_file (path), and trigger it manually with the /compact slash command.

The mental model: a fixed window is a desk that only holds so many papers. Compaction is the agent periodically summarizing the stack into a tight set of notes, clearing the desk, and carrying on — so the task isn't capped by the window. All the numbers here (1.05M, 400K, 512K) are volatile; the models page and config reference hold the live values, and issue #19464 tracks the 1M opt-in.

Key insight

Effective window ≠ API window

Even a 1M-token model runs at a 400K effective window in Codex by default. To use the full window you must opt in with model_context_window (+ model_auto_compact_token_limit). Don't assume a model's advertised size is what Codex is actually using — check /status.

Example

Why a 12-hour migration doesn't run out of room

On a sprawling framework upgrade, Codex fills its window, compacts the history into a tight summary, gets a fresh window, and keeps editing/testing — repeating for hours. The migration isn't bounded by one window because compaction lets the task span many of them.

Try it: Tune the dials: model, effort, and watch compaction

Goal: feel how the two dials and compaction change Codex's behavior, and learn to read the live truth instead of trusting hard-coded names. 1) Check the live catalog. Open https://developers.openai.com/codex/models and note today's recommended default and the current identifiers — compare them to this lesson's June 2026 snapshot and spot any drift. 2) Inspect your session. In a small repo run codex, then /status; record the active model and reasoning effort. 3) Switch a dial deliberately. Use /model to change effort (e.g. medium → high) on a moderately tricky task — like "refactor this module and explain the trade-offs" — and notice the turn gets slower but more thorough. Run /status again to confirm the change. 4) Catch the silent-default trap. With model_reasoning_effort unset, switch models with /model (or codex -m <other>), run /status, and observe how the effort changed just because you changed models. Then set model_reasoning_effort explicitly in ~/.codex/config.toml and confirm it now holds across the switch. 5) Reason about context. In config, leave a comment recording your model's effective window (check /status / the API page) and write the two-line opt-in (model_context_window + model_auto_compact_token_limit) you'd use to raise it — you don't have to run a 1M task, just articulate the recipe. 6) Write three sentences: which effort level felt right for your task and why, what happened to effort when you switched models, and in your own words what compaction does for a long-horizon run. This builds the instinct to right-size the brain and the thinking to the job — and to never trust a hard-coded model name over the live page.

Key takeaways

  1. 1Two independent dials govern how Codex thinks: which model runs the loop (the brain) and how much reasoning effort it spends per turn (how hard it thinks) — tune both to the task.
  2. 2Decode the naming convention: plain gpt-5.x = frontier general, -codex = agentic-coding-tuned, -mini = small/subagent, -spark = ultra-low-latency preview, -max (historical) = compaction-trained. As of June 2026 gpt-5.5 is the recommended default and the gpt-5.1 family plus gpt-5.2-codex are retired.
  3. 3Select a model three ways — the -m/--model flag (per-launch), model = in config.toml (default), and /model in-session — and on a ChatGPT account, leave model unset to automatically track the recommended default.
  4. 4Reasoning effort (model_reasoning_effort = minimal|low|medium|high|xhigh, Responses-API models only) trades latency and cost for quality; defaults are per-model (gpt-5.5 = medium, gpt-5.4 = none), so switching models can silently change your effort, and xhigh is model-dependent.
  5. 5Codex caps the effective context window at 400,000 tokens even for ~1M-token models; opt into more with model_context_window + model_auto_compact_token_limit.
  6. 6Compaction prunes the agent's own history to give it a fresh window and repeats until done — letting a single task span multiple windows, millions of tokens, and 24+ hour autonomous runs. All model names and numbers are volatile: cite developers.openai.com/codex/models for live values.

Quiz

Lock in what you learned

Check your understanding

0 / 4 answered

1.You're on a ChatGPT-account Codex login and want to automatically use OpenAI's current recommended model without editing config every time a new one ships. What should you do?

2.A developer switches from gpt-5.5 to gpt-5.4 mid-project without touching model_reasoning_effort and complains the new model "feels shallower." What is the most likely cause?

3.Your task uses gpt-5.5, which advertises a ~1,050,000-token window in the API, yet Codex behaves as if it has far less room. Why, and how do you get more?

4.Codex runs a large migration for hours, repeatedly nearing its context limit yet continuing coherently rather than truncating or stalling. Which mechanism makes this possible?

Go deeper

Hand-picked sources to keep learning