Codex Engineering
How OpenAI builds a coding agent people actually use — simple loop, serious systems
← AI Agents · Graph engineering · Harness tips · CLI for agents · Codex mobile apps · OpenAI × HF security · God agent vs team
Source
Talk circulated on X via @0xMovez (9 Aug 2026) — ~25 min OpenAI engineer presentation on Codex (OpenAI’s coding agent), plus Q&A. Speaker works on Codex; venue framing matches an ML-for-systems style conference talk (references prior-year colleague talk on Olympiad-level models).
Editorial note: the viral post frames the lecture as “graph engineering” and cites dramatic internal usage lines. Prefer the transcript: this is Codex systems engineering — agent loop, environments, tools, durability, review, safety — not a multi-node workflow design course. Full cleaned transcript at the bottom.
In one sentence
Keep the agent loop dumb and open; put the hard work into environments, terminal tools, patches,
AGENTS.md, review quality, and safety training — so the same intelligence that wins contests
shows up as a product people run all day.
Capability context (why 2025 mattered)
| Signal | Claim from the talk |
|---|---|
| SWE-Bench Verified | ~500 GitHub-issue → PR tasks. GPT-4o era ~30–40%; with reasoning / test-time compute, approaching ~80–90% (near bench limits). |
| METR time horizon | Not just “did it finish?” — how long / hard a task the model can hold. Exponential-looking progress; Codex models on the frontier. |
| Contests | Same underlying reasoning stack: gold-level IOI / IMO-class results, perfect score at ACM ICPC finals — “that intelligence at your fingertips” in CLI / cloud. |
| Real-world SE | Speaker’s frame: only ~2025 did models become meaningfully useful for day-to-day software engineering, not just contests. |
Benchmarks still mostly measure correctness via tests. The talk’s later half is about everything else: style, modularity, review signal-to-noise, collaboration with humans, safety.
Product surfaces
| Surface | Notes from talk |
|---|---|
| CLI | Released ~April (year of talk); simple npm install. |
| IDE | Same agent stack in the editor. |
| Cloud / ChatGPT | Cloud product ~May; create environments at chatgpt.com/codex-style product path (speaker: “chatgpt.com slash codecs” in audio — product is Codex cloud). |
| Open source agent | openai/codex on GitHub — core loop, prompts, tool specs shared so outsiders can match product behavior. |
| API | Models in API; speaker noted a Codex max-class model landing “yesterday” relative to the talk. |
Internal + external adoption (as stated)
- ~95% of technical staff at OpenAI use Codex.
- Codex reviews 100% of PRs created at OpenAI.
- External usage (daily messages to Codex) ~20× since GPT-5 (Aug) — described as the first OpenAI model specifically trained for coding-agent scenarios.
Treat viral “85% / hundreds of agents / graph engineering” lines as distribution copy unless you hear them in the video. The numbers above are what the transcript actually supports.
The simple agent loop
Core infrastructure is intentionally thin — “ultimately a single for loop”:
developer instructions
+ tool specs (function calling)
+ environment / user context
+ user task
↓
model reasons → tool call (shell / MCP / …)
↓
tool result back into context
↓
repeat until done Serving via Responses API (or local GPT-OSS models). Open-sourced prompts and tool specs so the public agent can match the product path. Philosophy: you do not need a complex multi-agent framework to hit contest-level and real-repo performance if the model + tools + env are right.
That is the useful contrast with graph engineering: graphs earn their place when work needs specialized lanes, fan-out, and human gates; Codex’s default unit is still one strong agent in a tight loop.
Three hard problems (ML × systems)
| Area | What they optimize |
|---|---|
| Environments | Same training-env knobs shipped as Codex cloud: container image, deps, internet off by default, selective enable, enterprise filtration concerns, injection-hardened model behavior. |
| Tools + loop | Opinionated tool set; terminal as bread-and-butter; sandbox policies; patch format + constrained sampling; model-controlled token/latency budgets per tool call. |
| Behavior + durability | AGENTS.md adherence, review quality, style/best practices (beyond unit tests), collab training so agents don’t stomp user edits, safety (injection, malware, jailbreaks). |
Environments = training infra as product
- Start from a container image (often Docker) with preinstalled or user-provided deps.
- Network off by default; selective internet — enterprise concern is data exfil and bad deps.
- Training and product share the same knobs so “what the model saw in RL” matches “what users run.”
Tools philosophy: terminal first
For most coding tasks the terminal is enough: read/write files, run tests, review, commit. Not universal — but the majority of the software inner loop lives there.
Exec / terminal tool knobs
- Model can set how many tokens of tool output it wants to see and how long a call may run (cost ↔ latency).
- Those tradeoffs are learned via RL, not only hardcoded policies.
- Sandbox by default on macOS/Linux — file + network restricted so the agent cannot casually trash
$HOME.
With that loop + exec tool, they claim strong TerminalBench results (not only pure code: start servers, download media, etc.).
Why not raw git diffs for edits?
| Format | Upside | Downside |
|---|---|---|
| Git diffs | Huge pretraining prior | Line numbers hard for autoregressive prediction up front |
| Custom patch | Git-diff-like headings/context, no line numbers; simple grammar → constrained sampling → always-valid syntax | Custom surface area (they document for developers) |
AGENTS.md — contributor guide for agents
Shared push (with other companies) to standardize a repo file that tells agents: structure, build/test commands, style, how to open a PR — then enforce adherence.
- Models are often good at writing these files (speaker: research-class models do well out of the box).
- Trick: deploy agents against open-source repos to bootstrap a decent AGENTS.md automatically.
Same idea as human CONTRIBUTING.md, aimed at the agent — and the practical bridge to harness / repo-level instructions you already use on this stack.
Beyond “tests pass”
Unit-test correctness is only one slice of engineering. Real failure modes:
- Style and “looks AI-written” patterns leaking into the codebase
- When to DRY vs when duplication is fine
- Modularity, comments, overly defensive code
Codex is also positioned as a code reviewer: @Codex on GitHub PRs;
all OpenAI PRs reviewed this way; serious issues caught early. Alignment blog post referenced for
review-focused model work.
Review = precision vs recall
Bad tools waste more time than they save. The product problem is not “flag everything” — it is signal-to-noise: push the precision/recall curve up, not just pick a point on a bad curve.
Safety (coding-agent specific)
- Prompt injection via user text, filesystem files, and dependencies — not only chat.
- Adversaries probing malware generation and exploit use → active mitigation.
- General jailbreak / model safety training (system card linked in talk).
- Collaborative editing: during training, simulate another “user” model editing the same files so the agent learns not to stomp concurrent human changes.
Related on this site: OpenAI × Hugging Face agent incident notes (why evals + agent tooling need security scrutiny).
What’s next
| Technique | Idea | Product hook |
|---|---|---|
| Parallel test-time compute | More attempts → smooth accuracy scaling (pass@k style) | Codex cloud: request multiple responses per task |
| Compaction | Model summarizes its own work; claim up to ~100× context compression | Long sessions without drowning in tokens |
| Flywheel | Better Codex → faster research tooling → better training tasks → better Codex | Self-review, agent-generated training envs; company AGI acceleration goal |
Q&A highlights
| Question | Answer gist |
|---|---|
| How reconcile RL, safety, human-collab alignment at scale? | Prefer methods that scale; train concerns together where possible; north star is real product usage, not only synthetic verifiers. |
| Is compaction just lossy summary — do we need new ideas? | Room for better strategies; today the model chooses what goes in the summary and improves that skill under training. |
| How do verifiers scale with parallel attempts? | Actively worked on (user-side verification scaling still open). |
| Are tool token budgets personalized per user? | Shown mechanism is per tool call / command type (e.g. noisy tests → tighter caps), not per-user RL personalization. |
Map: Codex engineering vs graph engineering
| Topic | This page (Codex) | Graph engineering |
|---|---|---|
| Unit of work | One agent, simple tool loop | Explicit multi-step graph of specialized jobs |
| Parallelism | Often multi-sample attempts (same task, N tries) | Parallel specialized lanes (research / skeptic / merge) |
| Quality control | Reviewer model, precision/recall tuning, AGENTS.md | Separate writer vs checker nodes + human gate |
| State | Repo + env + context; compaction for long runs | Shared files/notes across graph nodes |
| When to use | Coding agent product / harness design | When one chat cannot own research + judgment safely |
Steal for your stack
- Write / enforce an AGENTS.md (or project equivalent) — structure, test commands, PR norms.
- Prefer terminal + sandbox over a pile of half-baked tools until a tool is clearly better.
- Separate author from reviewer (even if both are models).
- Optimize review for signal-to-noise, not volume of nits.
- Treat environments as first-class: network defaults, deps, reproducibility.
- When stuck, try N attempts or multi-sample cloud runs before redesigning the whole agent.
- Use compaction / summarization deliberately on long sessions — and check what the summary forgot.
Related
Full talk transcript
Cleaned from the circulated video / auto-captions for readability (not a professional transcript). Names and product terms may be misheard in audio (e.g. “SweeBench” → SWE-Bench, “codecs” → Codex, “ShadGBT” → ChatGPT). Prefer the speaker’s slides/video for figures.
Thank you all for being here. The room is a lot larger than it was the last time I was here, six years ago, so I'm very grateful for that.
As mentioned, I work on Codex, which is OpenAI's coding agent. One thing that stands out for context: looking at last year's ML for Systems Conference, my colleague Ahmed was here talking about how OpenAI models were starting to get capable enough to really get gold at the IOI or Olympiad-level competitions. But I think it's only really this year in 2025 that we started to reach the point where these models could actually start to do real-world software engineering work in a way that was very meaningful for users — which many of you have probably already experienced.
This chart shows a benchmark called SWE-Bench Verified. This is from fine people at Princeton, many of whom are at the conference working on much better and newer benchmarks, but SWE-Bench is still a great example. If you're not familiar: it's a benchmark of 500 tasks from open-source issues in GitHub repos, and the models need to produce the pull request that resolves the issue.
Even last year, around June, when GPT-4o came out, the models were still not very good at this task — starting around, I think, between 30 and 40%. But just in the last year, the progress has been pretty incredible. A lot of it's been driven by developments in test-time compute, as we heard in the previous presentation. With these reasoning models, the progress has really taken off. The models can resolve almost twice as many issues as before; we're really nearing the 80 to 90% mark, which is probably pretty close to the limits as far as this benchmark goes.
Looking at this METR time-horizon graph — shared around a lot recently — it's not just about completion, but also about the length and difficulty of the tasks models can achieve. It's almost like an exponential curve: the rate of progress in how difficult the tasks models can solve is increasing over time. I think the Codex models are actually pushing the frontier of that right now.
Going back to the IOI thing: this year the models achieved some very impressive feats — not just gold at the IOI, but also the IMO, and a perfect score at the ACM ICPC finals. This is actually the same underlying reasoning model that powers Codex. So when you use Codex — and I hope you try it if you haven't already — you're getting this level of intelligence and reasoning at your fingertips, whether that's on the computer or in the cloud.
Codex was released — the CLI was released earlier this year, in April. You can install it right away; it's a simple npm install. It's also available in the IDE, and as the cloud product in ChatGPT, which was released in May. What's cool is that the same underlying open-source agent — we've released it on GitHub as openai/codex — is open source. All that core logic is the same underlying agent infrastructure that powers the different product surfaces. We're releasing that to the public so anyone can achieve kind of the same level of performance that we do.
The models are also available in the API. I think the 5.1 Codex max model just became available in the API yesterday. And we're really starting to see adoption take off both internally and externally. There's no better evaluation than real-world usage. Something like 95% of technical staff at OpenAI make use of Codex. Codex reviews 100% of pull requests created at OpenAI. Externally, usage as measured in daily messages to Codex has increased about 20× since GPT-5 was released in August — which was kind of the first OpenAI model specifically trained to be good at these coding-agent scenarios.
What's under the hood of the Codex agent? We've intentionally kept the core agent infrastructure — the loop that powers the agent — extremely simple. The nice part is it's open source. There are links at the bottom; you can go to the repo and check these out. We've open-sourced the prompts, the tool specs, all of that.
When you start a task, in the prompt you basically have the developer instructions, a set of function-calling tools we provide to the agent, the environment / user's environment context, and of course the prompt the user gave us. Then we have what is ultimately quite simple: a loop where the model receives that prompt, reasons about what to do next, and almost always makes a tool call — running a command, or using an MCP if you've provided a Model Context Protocol tool. Afterwards we provide the agent the results of that tool call. This whole process repeats until completion.
Essentially a single for loop. We use the Responses API, or you can also run the GPT-OSS models locally. You just repeat this in a loop until the task is complete. Ultimately that's all you need to achieve both these incredible performances at competitions and solving real-world software engineering tasks.
Underneath that simple loop, there's a lot going on. I want to provide a high-level overview of some of the challenges we've solved — interesting because it's at the intersection of ML and systems. First: high-quality environments, not just for training the models but also to serve them as part of the Codex cloud product. Second: a lot of thought goes into the tools the agent gets. Third: constraints around model behaviors, durability, and what it means to have a coding agent users actually want to use — not just things that are incredibly capable but otherwise hard to work with.
Environments. If you go to the Codex cloud product, you can create your own environment. The cool thing is we've taken the same infrastructure that powers our training environments and shipped it as the Codex cloud product. A lot of the knobs you see when you create a Codex environment as a user are the exact same types of things we use during training. You start with a container image, usually a Dockerized container; it might contain a mix of pre-installed dependencies, but users can also provide their own.
Security matters. By default, most containers have internet access disabled, but users can selectively enable internet. Many enterprises have concerns around data filtration, or accidentally installing bad software or bad dependencies from the internet. It's important to have those knobs, and also dedicated training so the model is less vulnerable to that type of injection.
Tools and agent loop. We have a fairly opinionated take on what tools you should give the agent. Our philosophy is that the terminal is the bread and butter of what Codex uses to accomplish most tasks. We do think that for a lot of things, the terminal is kind of all you need. That's not true for all tasks, of course, but we find it true for the majority. You can read files, write files, run tests, review and commit changes — the fundamental inner loop of the software development cycle.
Below is roughly the interface we use for the exec / terminal tool. A couple of callouts: we expose knobs that let the model control how much token usage any tool call takes and how long that tool call is allowed to take. The model has fairly fine-grained control over this cost and latency tradeoff, and through reinforcement learning the model can almost learn by itself how to best optimize that.
Another philosophy: enable sandboxing by default. On macOS and Linux there are sandboxing primitives where you can execute processes in a pseudo-sandbox where file and network access is tightly restricted by default. My colleague Fouad has an excellent talk about considerations that went into this design. On macOS you can define sandboxing policies, similarly on Linux; we have a fairly well-thought-out set so the agent can't just delete your home directory without explicit permission — unless you wanted that for some reason.
With the terminal tool alone, there's a benchmark called TerminalBench where the agent has to do various things — not just pure coding tasks, but start a server, download videos from the internet, and so on. With that simple agent loop and a relatively simple interface to execute commands, we're already able to achieve state-of-the-art performances on these real-world tasks that require interaction with a computer.
One interesting anecdote: you would think models can just use Git to apply patches or edit code. It's actually a pretty interesting design space — how do you provide models tools to edit files? Git diffs have a big advantage: they're well represented in the pretraining data. One downside is that Git diffs contain a lot of references to line numbers, which make it very difficult — basically impossible — to predict up front in an autoregressive manner. So we have a custom patch format; we've shared that with our developers. It's basically a simplified version of the Git diff format, no line numbers, but still the same approximate format: headings, context, and the patch itself at the core. During serving, the grammar of the patch syntax is extremely simple, so you can use constrained sampling to ensure the model always generates a syntactically valid patch.
Behavior and durability. This is a big and important piece of what makes coding agents useful in the real world. One thing we've worked with other companies to try and standardize is the concept of AGENTS.md — basically a readme for agents, the same way we have contributor guides for humans. The idea is we provide the model with guidelines around code structure, build and test commands, style guidelines, how to make a PR in the repo — and we actually enforce that the model adheres tightly to these instructions.
One interesting thing: the models are actually very good at creating these files. For example, a model like OpenAI research-class models is quite good at that out of the box. One trick: for many open-source repositories, it's possible to get a pretty good AGENTS.md out of the box just by deploying our own agents to do that.
I touched on the benchmarks earlier, but one limitation of a lot of the current set is that they only capture correctness as measured by the ability to pass the reference unit tests. In the real world there's so much more to software engineering than correctness: coding style, engineering best practices, when not to repeat yourself versus when it's okay to duplicate code — a very nuanced decision — how to structure code to be modular, even usage of comments, overly defensive programming patterns. When it doesn't go right — this picture on the right is actually from a Twitter comment — sometimes models are prone to doing things that look a bit AI. If we don't do our jobs right, that kind of leaks out. It's best to try and mitigate these types of things.
Another interesting thing: Codex is actually a great code reviewer by itself. On GitHub, if you are connected to Codex, you can just @Codex and ask it to review your PRs. As I mentioned earlier, all PRs at OpenAI are reviewed this way. There's been a surprising number of actually quite serious issues that have been flagged early as a result. We've published a blog post recently on the new OpenAI alignment blog, which I recommend checking out. There's been a lot of work that's gone into making the models very good at code review.
One concern specifically for code review — if you've used other code review tools — is a very delicate tradeoff between precision and recall, or the signal-to-noise ratio. If you flag things that are not true issues, that often wastes more time than you actually save the user. You have this very delicate tradeoff between precision of the flagged issues versus being able to flag the actual issues that occur in practice. We've worked a lot to really tune that — not just find the right spot on the curve, but also push the curve upward, as you can see in this plot.
There's a lot of safety training that goes into our models — not just Codex, but all OpenAI models. Some things specific to coding agents: prompt injections, not just through user input, but also files in the filesystem or even dependencies, where developers might try to sneak in attacks against LLM agents. One area adversaries in the wild are actually using or trying to use these models today is generating malware or trying to exploit cybersecurity risks — we actively work to mitigate that. Also jailbreaks and general model safety training.
One interesting callout from our system card: cool techniques we can use to make the models more collaborative. Previously we saw models prone to stepping over user changes if you're editing a file at the same time as the coding agent. You end up with conflicts that step over each other's work. We actually simulated during training users — another model would be inserted in the loop and make changes at the same time as the original model. By doing so, you can simulate cooperating with the user on your laptop and make sure the model behaves responsibly when there are conflicting changes.
What's next. One thing from the previous presentation that's very relevant for coding agents: using parallel test-time compute to improve performance. We published this number with the Codex-1 model — a bit old, but the trend still holds — the more attempts you give these models, you get a pretty smooth scaling curve in accuracy. The model might not solve the problem the first try, but if you give it four tries or eight tries, the probability of a correct solution increases quite a lot. We've actually exposed that in the Codex cloud product: when you provide a task, you can ask for multiple responses.
Another interesting technique is to extend the context of these models via compaction. The model can summarize its work, often compressing the tokens used in the context by up to a hundred times.
To close: the best part about working on Codex is that as we get a better Codex, it makes the future of Codex models better — faster to develop, whether through better tooling for the research side or faster development on the Codex product. Codex can start to review its own code; Codex agents can even help us make more tasks in training environments; and ultimately our purpose as a company toward our goal of accelerating progress toward AGI.
That's all I have. Thank you for listening.
Q&A
Mertz (BrowserUse): There are many components to training — safety, aligning with real-world usage, RL on typical tasks. How do you reconcile all of these at scale? You can generate a lot of test cases you can run and verify, but the same is not true for safety or alignment for collaborating with humans. Is it all combined into one pipeline, or stages separately?
Speaker: We're all about things that scale well. As much as possible we try to address all of these things at the same time. Ultimately our north star is aligning these things with how the tools are used in the real world — capturing how people actually use the product in practice and making sure the training reflects that real usage.
Eileen (ETH Zurich): Do you think there's a problem with this compaction method? Do we need new solutions? I assume it's some kind of summary — what do we put into the summary? Do we miss relevant information? Are you rethinking strategies?
Speaker: There's definitely room for more sophisticated strategies, but we find this approach works well. One of the powerful things is that it's basically the model that decides what to put in the summary. Over the course of training, the model gradually learns how to do this on its own, which is pretty interesting to see.
Shabas Patel (Best Buy): When you're talking about parallel test-time compute scaling, how do you plan to do the verifiers so they can also scale at the same time? As a user, how can you scale the verification process?
Speaker: I think that's an area that we're actively looking into.
Pranav (startup): You mentioned the token consumption is dynamic — the model learns how to consume more tokens or less. Is that applied at a global level or personalized for every user based on their coding patterns? How many tokens does it consume — personalized per user? RL on a per-user level?
Speaker: The one I showed specifically is at the tool-usage level. When a model runs a command, it can control the maximum number of tokens it should see from that tool call. It depends on the command: if you're running a test command, you might see a lot of output, and it might make sense for the model to be a little more restrictive about how many tokens should be seen from the result.
Cool. Thanks.
Comments
Approved comments appear below. Log in once with GFAVIP — it applies across the whole site. GFAVIP login
View comments archive