dmesg --follow
[ 68673720.000 ] posts.x: @davidsenra you will love this!  |   [ 68673600.000 ] posts.x: https://t.co/vhJifvV8y9  |   [ 68673600.000 ] posts.x: This Jay-Z documentary, In 8, is exceptional! Nearly 6 hours of intimate conversation between @sc and the brilliant @RickRubin. It’s rare to get such…  |   [ 68662260.000 ] posts.x: Full talk on turning re-prompted fixes into linters, including the OpenAPI drift fix and the skill-writing whack-a-mole:  |   [ 68662260.000 ] posts.x: Re-prompting an agent to fix the same sloppy pattern over and over isn't a workflow, it's a sign the rule should live in code, not in your head…  |   [ 68650020.000 ] posts.x: ↻ @willcb: me: kinda fucked up how many people are offloading their whole lives to muse or instinct or grokbot or whatever claude: yeah  |   [ 68650020.000 ] posts.x: ↻ @iamdevloper: signs you've become the senior dev: you're the only one who understands the deploy script you're the only one who remembe…  |   [ 68649720.000 ] posts.x: Gooooooooood morning! Brazil Oberon Cerrado. Roasted 110 seconds past first crack. Milk chocolate and almond.  |   [ 68647800.000 ] posts.x: @Saanvi_dhillon “Git expert” is a weird flex, though, isn’t it?  |   [ 68610720.000 ] posts.x: @sujee_dev @dkundel @aiDotEngineer Thanks mate!  |   [ 68600580.000 ] posts.x: Full talk on the Codex app server protocol and what you can build on top of the Codex harness:  |   [ 68600580.000 ] posts.x: A lot of engineers assume building their own agent interface means writing their own agent harness from scratch. @dkundel, Developer Experience Lead…  |   [ 68564580.000 ] posts.x: Full talk on why Reducto deleted their all-in-one MCP server and rebuilt it around fewer, state-aware tools and visible agent uncertainty:  |   [ 68564580.000 ] posts.x: A single massive MCP file worked fine as a curated demo and broke the moment Reducto's own team got hold of it. @abhiarya, who works on product…  |  
corey@gallon.me:~/til$

Unlocking Codex's Larger Context Window: 872K Tokens on GPT-5.6

FIGURE 1 ⋅ Unlocking Codex's Larger Context Window: 872K Tokens on GPT-5.6

GPT-5.6 can work with an 872,000-token context window, but Codex starts it at 272,000.

Codex doesn't ask the model how many tokens it can handle. It looks the answer up in a model catalog -- a JSON file (~/.codex/models_cache.json) listing every available model alongside its capabilities. Each entry carries two numbers: context_window, the default, and max_context_window, the most Codex will let you raise it to. For every GPT-5.6 and GPT-6 variant the catalog says 272,000 and 872,000. As far as Codex is concerned, 272,000 is the ceiling unless you tell it otherwise.

Codex profiles let you create named configurations -- a different model, different sandbox rules, different settings -- and switch between them with --profile name. Each profile lives in its own file at ~/.codex/<name>.config.toml, using the same top-level keys as ~/.codex/config.toml. Anything you set in a profile file overrides the matching value in config.toml for sessions launched under that profile.

That includes model_context_window.

The profile that unlocks it

Create ~/.codex/long_context.config.toml:

model = "gpt-5.6-sol"
model_context_window = 1000000
model_auto_compact_token_limit = 800000

Three lines. model_context_window asks for a 1M-token window; Codex clamps the request to the catalog's max_context_window, so you get 872,000. model_auto_compact_token_limit triggers conversation compaction at 800K, leaving headroom before the effective ceiling. The same profile works with gpt-6-sol or any of the other GPT-5.6 and GPT-6 variants.

Launch with:

codex --profile long_context

Verifying it works

Inside the Codex TUI, /status shows the context window size. For a definitive check, inspect the rollout JSON from your session:

latest_rollout=$(
  find ~/.codex/sessions -name 'rollout-*.jsonl' -printf '%T@ %p\n' \
    | sort --numeric-sort \
    | tail --lines=1 \
    | cut --delimiter=' ' --fields=2-
)

jq -r '
  select(.type == "event_msg" and .payload.type == "task_started")
  | .payload.model_context_window
' "$latest_rollout"

This returns 828,400. Codex applies a 95% effective context window, so the runtime ceiling is 828,400 of the catalog's 872,000. Without the profile, the same check returns 258,400 -- 95% of 272,000.

What the override actually buys you

It isn't permission to send a big prompt. The server already accepts one: on my Plus account, a single-turn codex exec on GPT-5.6 took 773,605 input tokens with no override at all. (A single turn of about 1.02 million tokens was rejected with "Codex ran out of room in the model's context window", consistent with the 872K ceiling.)

What the override changes is compaction. Codex compacts the conversation once it nears the window it believes it has, and by default that window is 258,400. To see the difference, I sent a ~314,000-token first turn and then a short follow-up in the same session:

  • Default: Codex compacted the conversation before the second turn, which went out at 274,082 tokens.
  • With the override: no compaction. The second turn carried the whole conversation -- 318,993 tokens.

In a real working session -- long files, long tool output, many turns -- that is the difference between Codex summarizing away your early context at a quarter of a million tokens and keeping it until well past three-quarters of a million.

To reproduce the end-to-end test, build a large input and pipe it to a single turn. Space-separated random digits come out at roughly one token per character, so a 760,000-character file is about 774,000 tokens:

python3 -c "
import random
print(' '.join(str(random.randint(0, 9)) for _ in range(380000)))
" > big_input_file

codex exec --profile long_context --skip-git-repo-check \
  'Reply with only the literal word RECEIVED.' < big_input_file

Then read last_token_usage.input_tokens from the rollout's token_count events to see what the server accepted.

What happened to GPT-5.4 and GPT-5.5

This post originally targeted GPT-5.4, which shipped in the catalog with a 1,000,000-token maximum. That no longer applies: GPT-5.4 has dropped out of Codex's catalog, and requesting it on a ChatGPT account now fails with "The 'gpt-5.4' model is not supported when using Codex with a ChatGPT account."

GPT-5.5 can't be raised. Its catalog entry sets both context_window and max_context_window to 272,000, so the override has nothing to clamp to -- the window stays at 258,400 -- and the server agrees: a ~305,000-token single turn was rejected. If you want a bigger window, use GPT-5.6 or GPT-6.

Why this works now (and didn't for a while)

The override has had a bumpy history:

  • Before Codex 0.134.0, profiles lived inside ~/.codex/config.toml as [profiles.X] tables, and that table parser silently dropped model_context_window (openai/codex#14456). 0.134.0 moved profiles into their own files, where the key worked.
  • By Codex 0.144.4, the override was ignored entirely: sessions reported 258,400 whatever you set.
  • As of Codex 0.156.1, it is honored again, up to each model's max_context_window.

I tested all of this on Codex 0.156.1 with one ChatGPT Plus account. On Pro / Enterprise / API the server-enforced ceilings may differ -- I haven't tested them.

corey@gallon.me:~$ tail -f /writing Attach to the stream. An email when I have something worth sending. Replies encouraged!
corey@gallon.me:~$ ls -lt /til ↑2026-05-28 How I Fixed Handy's Memory Leak Without Knowing Rust
▸2026-05-25 Unlocking Codex's Larger Context Window: 872K Tokens on GPT-5.6 ⋅ you are here
↓2026-05-15 Getting Handy to work in GNOME Wayland (Ubuntu 25.10+)