OpenAI publishes new GPT-5.1 Codex-Max guide with major upgrades for agentic coding
OpenAI has released a detailed new guide for GPT-5.1 Codex-Max, the company’s latest developer-focused model aimed at more capable autonomous coding agents. The document outlines how developers can migrate existing harnesses, optimize prompts, and take advantage of new tools — all while benefiting from notable improvements in reasoning efficiency, long-running workflows, and Windows/PowerShell support.
A more efficient, more autonomous Codex
One of the biggest highlights: Codex-Max now matches GPT-5.1-Codex performance on SWE-Bench Verified while using roughly 30% fewer “thinking” tokens. OpenAI says developers should run the model at medium reasoning for typical interactive sessions, and switch to high or xhigh for the most involved tasks.
The model also pushes further into agentic territory. According to the guide, GPT-5.1 Codex-Max can now sustain multi-hour autonomous trajectories, enabling extended refactors, code generation, or multi-step repair jobs without losing context.
Another noteworthy change is first-class compaction support, OpenAI’s system for condensing long conversations into encrypted context items. This allows agents to work continuously for hours without hitting context limits — a critical upgrade for large-codebase work.
And for developers working on Windows? The new model brings stronger PowerShell behavior and improved handling of Windows-specific tooling.
Migration: mostly painless
If you're already using a Codex harness, OpenAI says you’ll likely need only light updates. Harnesses built for other GPT-5 models or third-party systems may need more work, but the company points developers to the open-source codex-cli reference agent on GitHub as the canonical implementation.
OpenAI’s recommended migration checklist includes:
- Refresh your prompt using the Codex-Max starter template. It emphasizes autonomy, persistence, tool-first workflows, and frontend quality — and warns against boilerplate like up-front planning requests that can prematurely halt the model.
- Upgrade your tools, especially adopting the preferred
apply_patchimplementation. - Review the codex-cli repo for harness patterns and customization strategies.
Prompting: built for real-world, end-to-end code
The new starter prompt — now available on GitHub — is designed to bias agents toward shipping working code. It encodes best practices around autonomy (implement → test → refine → explain), defensive coding, type safety, and consistent project conventions.
OpenAI calls out several prompt behaviors developers should rely on:
- Prefer dedicated tools (
git,rg,apply_patch, etc.) over raw shell. - Batch and parallelize tool calls whenever possible using
multi_tool_use.parallel. - Persist on a task until completion unless explicitly blocked.
- Keep changes DRY and avoid overly broad exception handling.
- Use structured plans, updating them thoughtfully as tasks progress.
The tools: apply_patch takes center stage
A major theme in the guide is OpenAI’s push toward more reliable code-editing workflows. The company strongly recommends using the Responses API’s native apply_patch tool, which comes with reference implementations and examples in the Cookbook and Agents SDKs.
Other tool updates include:
- shell_command: now with clearer best practices and improved PowerShell invocation.
- update_plan: enforces a single
in_progressstep to keep agents orderly. - view_image: allows attaching local files for visual inspection.
- Parallel tool calling: recommended for reading large codebases quickly, with guidance on ordering function calls to stay in-distribution.
OpenAI also outlines limits for tool output — roughly 10k tokens — and recommends a beginning/end retention strategy when truncation is necessary.
Compaction: continuous coding without context resets
For long-running agents, compaction is the key enabler. The guide describes a workflow where developers:
- Run a normal
/responsescall, - Invoke
/responses/compactonce context grows large, - Store the returned encrypted content,
- Inject it into future
/responsescalls.
This approach effectively extends the working memory of Codex-Max, letting autonomous agents maintain state across hours-long sessions.
Where to dive deeper
OpenAI has published full prompt text, migration steps, technical details, and example code in the official guide, now available in the Cookbook.
🔗 GPT-5.1 Codex-Max prompting and integration guide https://cookbook.openai.com/examples/gpt-5/gpt-5-1-codex-max_prompting_guide