OpenAI tracker

What is GPT-5.1-Codex-Max, and how can a coding agent work for hours without running out of memory?

· By Robert Scales · 5 min read

Short answer

GPT-5.1-Codex-Max is a coding model OpenAI released on November 19, 2025, for its Codex agent, built for long jobs such as large refactors and deep debugging. It is the first OpenAI model trained to use compaction, summarizing and trimming its own working history when its memory fills up so it can keep going, and OpenAI says it has seen it work on a single task for more than 24 hours.

Yesterday, November 19, 2025, OpenAI introduced GPT-5.1-Codex-Max, the latest model behind Codex, its coding agent. A coding agent is an AI that does not just suggest a line of code but carries out a programming task: it reads the project, edits files, runs tests and repeats until the job is done.

The new model is designed for the long end of that work: reorganizing a whole project, chasing a stubborn bug through many files, or running an agent loop for hours. Its main new trick has a plain name, compaction, and it addresses one of the most common reasons AI agents give up halfway.

What OpenAI released

GPT-5.1-Codex-Max is available now in every Codex surface: the command-line tool, the extension for code editors, Codex cloud and Codex code review. Subscribers to the Plus, Pro, Business, Edu and Enterprise plans of ChatGPT can use it, and it now takes over from GPT-5.1-Codex as the model Codex picks unless you choose another. Access through the API, for developers who use Codex with their own key, is promised soon.

OpenAI's comparison with the previous Codex model:

TestNew model, extra-high effortPrevious Codex model, high effortWhat it checks
SWE-bench Verified77.9%73.7%Fixing real bugs from open-source projects
SWE-Lancer IC SWE79.9%66.3%Freelance-style software jobs
Terminal-Bench 2.058.1%52.8%Tasks done through a command line

The model also uses fewer tokens. A token is a small chunk of text, and reasoning models spend "thinking tokens" working through a problem before they answer. At the same medium effort setting, OpenAI says Codex-Max beats the previous model on SWE-bench Verified while using 30% fewer thinking tokens. According to The Decoder, OpenAI also measured real tasks finishing 27 to 42 percent sooner. Fewer tokens means lower cost and less waiting.

There is also a new Extra High reasoning setting ("xhigh") for jobs where speed does not matter. OpenAI still recommends medium for daily work. Two smaller firsts: this is the first OpenAI model trained to work in Windows environments, and its training included tasks meant to make it a better partner inside the Codex command-line tool.

How compaction works

Every language model has a context window: the amount of text it can hold in view at once, including your instructions, the files it has opened, the commands it ran and their output. On a long task, that history piles up. When the window is full, a model normally has to stop, or it starts losing track of what it was doing.

Compaction is a way around the wall. When a Codex session approaches the limit, GPT-5.1-Codex-Max automatically condenses its own history. It keeps what matters, such as the goal, the plan, the decisions made and the current state, and drops details it no longer needs, like the full output of a test run that already passed. It then continues in a fresh window, and repeats the cycle as often as the task requires.

An analogy: imagine writing a thesis in a notebook with a fixed number of pages. When the notebook fills, you write a careful one-page summary of everything so far, start a new notebook with that summary on page one, and carry on. You lose the scribbles, not the thread.

What is new is that the model was trained to work this way across many windows, rather than having summaries bolted on afterward. OpenAI says this lets it stay coherent over millions of tokens in one task, and that in internal tests it worked on tasks for more than 24 hours, fixing failing tests and revising its approach until it succeeded.

A worked example

Here is the kind of long job the model is designed for, written as an instruction to Codex:

Prompt
Migrate this project from our old logging library to the standard one.
Work folder by folder. After each folder, run the full test suite and fix
any failures before moving on. Keep a NOTES.md file with what you changed,
what is left and any decisions I need to make. Do not touch the payments
folder; list the changes it would need instead.

The notes file gives both you and the agent a record that survives compaction. Running tests after each step lets the agent check its own work. The final line keeps the riskiest part in human hands.

Try it: Take a coding task you have been putting off and rewrite it as a work order like the one above: the goal, the order of steps, how to check each step, and one thing the agent must not do.

Why it matters

Long tasks are where coding agents have struggled most, and the length of a single session has been a hard ceiling. A model that can manage its own memory moves that ceiling much higher. OpenAI also shares internal numbers: 95% of its engineers use Codex every week, and they ship roughly 70% more pull requests, proposed code changes, since adopting it.

Longer autonomy brings risks, and OpenAI addresses them. It calls Codex-Max its most capable cybersecurity model so far, though below the "High" level in its Preparedness Framework, the internal rulebook for serious risks, and it is adding safeguards ahead of that level. Codex runs in a sandbox by default: it can only write files in its workspace, and internet access is off unless you turn it on, because web content can carry prompt injection, hidden instructions that try to hijack the agent. The Decoder points out a practical tension: the more code an agent writes, the harder it is for people to review and understand it later.

How should you hand a long coding task to GPT-5.1-Codex-Max?

Start with a clean project under version control, so every change can be inspected and undone. Describe the goal, the steps and how success is measured, ideally with tests that already exist. Ask the agent to keep a running notes file, which helps you follow along and helps the agent stay oriented after compaction.

Leave the sandbox on unless the task truly needs the internet, and use the medium reasoning setting first; switch to Extra High only for hard problems where time is not an issue. Check in from time to time: Codex records the commands it ran and the test results, so you can see what happened.

Finally, review before you merge. OpenAI's own advice is to treat Codex as an extra reviewer, not a replacement for a human one. Read the changes, run the tests yourself and deploy only what you understand.

Sources

  1. Building more with GPT-5.1-Codex-Max — OpenAI, November 19, 2025
  2. OpenAI releases GPT-5.1-Codex-Max to handle engineering tasks that span twenty-four hours — The Decoder (Matthias Bastian), November 19, 2025

Get the free Guide to Artificial Intelligence

Sign up for the weekly newsletter and receive the free guide: what changed in AI this week, one lesson, one prompt to try. Unsubscribe in one click.

How we handle your address

Back to top

Display

Your choices are saved in this browser only. No data is sent.

Text size
100%
Colours
Reading
More settings
Accessibility statement