OpenAI's Harness Engineering Playbook - What It Means for Securing Codex Agents
- Harness engineering is OpenAI's name for the work of designing the environment around coding agents: instruction files, versioned docs, tools, custom linters, observability and review loops. In a February 11, 2026 write-up, OpenAI described building an internal product over five months with no manually written code, all of it written by Codex.
- OpenAI reports about a million lines of code and roughly 1,500 merged pull requests, at about 3.5 PRs per engineer per day, with a short (~100-line)
AGENTS.mdacting as a map into a structureddocs/directory, and with most review handled agent-to-agent. - Every harness layer is also a control point: instruction files are policy anyone with commit access can change, tools carry credentials, skills and MCP servers extend what the agent trusts, review feedback and logs are untrusted input, and low merge gates make the audit trail the main record.
- The good news: OpenAI's own patterns, rules enforced by linters and structural tests, disposable per-worktree environments, and versioned, CI-checked instructions, are also strong security practice. Security teams should add their invariants to the same mechanisms.
- Start by inventorying the harness, not just the agent: instruction files, skills, MCP servers, hooks and CLIs on every endpoint, plus scoped agent identities and human gates on sensitive paths.
The short version: OpenAI's harness engineering write-up is the clearest public account yet of what changes when coding agents, not people, write the code. A small OpenAI team spent five months shipping an internal product in which every line was written by Codex, and found that the real engineering work moved into the scaffolding: the instruction files, docs, linters, tools, observability and review loops that the agents run inside. That scaffolding is now where a large share of your security and governance decisions live, whether or not anyone wrote them down as security decisions.
We have looked at harnesses from the vendor side before, in OpenAI's Agents API, where the harness moved behind an API call, and in the Claude Code harness, where it is a tree of local files. This post is about the harness a team builds for itself inside its own repository, and what security teams should ask of it.
What OpenAI means by harness engineering
The article, published by Ryan Lopopolo of OpenAI's technical staff on February 11, 2026, describes an experiment with one hard rule: no manually written code. The first commit landed in late August 2025, and Codex CLI generated even the initial scaffold and the first AGENTS.md. OpenAI reports that after five months the repository held roughly a million lines of code, about 1,500 pull requests had been opened and merged, and three engineers (later seven) were averaging about 3.5 PRs per engineer per day. The team estimates it built the product in about a tenth of the time hand-written code would have taken. These are OpenAI's own figures for one internal product.
The headline idea is that humans steer and agents execute. When Codex got stuck, the fix was almost never to prompt harder. Engineers asked what capability was missing and how to make it both legible and enforceable for the agent, then had Codex build it. That loop of missing tool, new tool, better agent is the harness.
The building blocks of an agent-first harness
Stripped down, the article describes five layers that OpenAI's team built around Codex:
| Harness layer | What OpenAI built | Why it matters for governance |
|---|---|---|
| Instructions | A short AGENTS.md, roughly 100 lines, used as a table of contents that points into a structured docs/ directory | Every file the agent is told to read is part of its effective policy |
| Knowledge | Design docs, execution plans, a tech-debt tracker and a SECURITY.md kept in the repo as the system of record, checked by linters and a recurring doc-gardening agent | Agents treat repo text as truth, so who can change that text matters |
| Tools | The standard CLI tools such as gh, local scripts, repository-embedded skills, Chrome DevTools Protocol access for UI testing, and a per-worktree log and metrics stack queried with LogQL and PromQL | Each tool is a capability, and often a credential, the agent holds |
| Guardrails | Custom linters and structural tests that enforce layered architecture, structured logging, schema naming and file size limits, with error messages written as fix instructions for the agent | Mechanical rules apply to every run, which is exactly what policy should do |
| Feedback and review | Codex reviews its own change, requests further agent reviews, answers feedback and loops until reviewers are satisfied; humans may review but are not required to | The review gate is now mostly agent-to-agent |
A few details stand out. The team found that one giant AGENTS.md failed: it crowded out the task, turned every rule into noise, went stale fast and could not be checked mechanically. Moving to a short map plus versioned docs made the instructions reviewable. The app could be booted per git worktree so each change got its own isolated instance, with logs and metrics torn down when the task finished. OpenAI says single Codex runs regularly work on one task for more than six hours, often overnight. And the repository has minimal blocking merge gates: pull requests are short-lived, test flakes are often handled with re-runs, and agents often squash and merge their own pull requests.
OpenAI is careful to say this setup depends heavily on the structure and tooling of that one repository and should not be assumed to generalize without similar investment. It is a field report, not a product specification.
Why the harness is now a security boundary
None of the article is framed as a security paper, and OpenAI does not report any incident. But read with a security lens, nearly every harness decision is also a control decision. Five stand out.
1. Instruction files are policy, and they are writable. Codex builds its instructions by reading AGENTS.md files from the Codex home directory and from the project root down to the working directory, with closer files appearing later in the combined prompt, and an AGENTS.override.md can replace the normal file at any level. OpenAI's team pushes more and more context into the repo on purpose, because anything outside it does not exist for the agent. The flip side is that anyone who can land a change in an instruction file, a doc the map points to, or an execution plan can steer every future agent run. When agents also write those files, as they do in OpenAI's setup, you need a record of what changed and who or what changed it.
2. Tools carry credentials. An agent that drives gh, pushes branches, queries observability data and answers review comments is acting with real tokens. The article does not detail how those credentials are scoped, so treat that as a question to answer for your own harness: which identity does the agent use, what can that identity merge or deploy, and is it shared with a human account. The lethal trifecta of private data, untrusted content and an outbound channel is easy to assemble by accident when the agent has a CLI with a write token.
3. Skills and MCP servers widen the tool surface. OpenAI mentions repository-embedded skills and skills for working with DOM snapshots, screenshots and navigation. Every skill or MCP server added to make the agent more capable is also a piece of third-party or team-written code the agent will trust. The skills supply chain deserves the same approval step as any other dependency.
4. Agents read untrusted text. An agent that handles review feedback, bug reports and log output is reading content other people control. That is the entry point for prompt injection, and we have seen it used against coding agents in CI, including a case where a branch name became a command injection against Codex and attacks where PR titles and comments steered several coding agents. OpenAI's harness article does not describe an injection, but the more autonomy a harness grants, the more it matters where untrusted text enters.
5. Review and merge moved to agents. When humans are not required on each pull request and agents can merge their own work, the audit trail, not the approval click, becomes the main record of what happened. OpenAI is explicit that low gates are a deliberate throughput trade-off that would be irresponsible in a low-throughput environment. Security teams should decide which paths, such as auth, CI configuration, release tooling and the instruction files themselves, keep a human gate regardless.
What the harness gets right from a security view
It would be wrong to read the article only as a list of risks. Several of its patterns are good security engineering:
- Rules enforced in code, not prose. Custom linters and structural tests apply to every run at once. Policy that lives in a lint rule cannot be skipped because the agent missed a sentence.
- Isolated, disposable environments. One app instance and one observability stack per worktree, torn down when the task ends, keeps one change from contaminating another and limits what a single run can see.
- Versioned, checked instructions. A short map plus docs in git, validated by CI, is far easier to review and diff than a sprawling prompt or a wiki page.
- Parse at the boundary. OpenAI requires Codex to validate data shapes at boundaries instead of guessing, which removes a whole class of subtle bugs agents tend to build on.
- Continuous cleanup. Background Codex tasks scan for deviations from the team's "golden principles" and open small refactoring pull requests, replacing the Friday cleanup sessions that used to take 20% of the week.
The lesson for security teams is to join this work, not fight it. The same mechanisms that keep an agent-written codebase coherent can carry security invariants: a lint rule that blocks secrets in logs, a structural test on auth boundaries, a required human reviewer on changes to AGENTS.md.
A governance checklist for teams building agent harnesses
- Inventory the harness, not just the agent. For every coding agent in use, know its instruction files, skills, MCP servers, hooks, plugins and CLIs, on laptops as well as in CI.
- Treat instruction files as code owners' territory. Put
AGENTS.md, override files,docs/entry points and execution plans under code ownership with a human review requirement. - Give agents their own scoped identity. Separate agent tokens from personal ones, scope them to the repository and actions they need, and keep release and deploy rights out of reach of agent jobs.
- Pick the tightest sandbox that works. Codex runs locally with network access off by default, inside an OS-enforced sandbox plus an approval policy. Widen either deliberately and per task, not globally.
- Mark where untrusted text enters. Issues, comments, review feedback, tickets and logs are all inputs. Know which agent runs read them and what those runs can reach.
- Keep human gates on sensitive paths. Low merge friction elsewhere is a reasonable choice; CI config, auth, secrets handling and the instruction tree are not where to save minutes.
- Log decisions, not just outcomes. Codex can export OpenTelemetry events such as tool decisions and results, with prompt text redacted unless you opt in. Route agent activity to the same place as the rest of your security telemetry.
Where Symphony and orchestration fit
OpenAI has since open-sourced Symphony, an orchestrator that picks up issues from a tracker, gives each one its own workspace and keeps a Codex session working on it. Orchestration like that multiplies harness runs rather than replacing the harness: the repository's instructions, tools and guardrails still decide what each run can do. That makes getting the harness right more important, not less.
How Anomity helps govern agent harnesses
Anomity does not read your AGENTS.md, your docs or your prompts. It collects metadata only, with secrets redacted on the endpoint, which fits the question most teams actually have: what is installed, where, and what changed.
- See the harness across the fleet. The unprivileged Endpoint Sensor for Windows, macOS and Linux inventories AI agents, MCP servers, extensions, plugins, skills, secrets, hooks and CLIs on every managed endpoint, including Codex CLI and the other coding agents your developers run. Cloud discovery adds Google Workspace and GitHub OAuth grants held by AI apps.
- Enforce at the hook. Where an agent exposes a hook, such as Claude Code
PreToolUseor Codex CLI, Anomity can allow, deny or log a tool call before it runs. - Keep the record. Additions, changes and decisions land in a 90-day audit trail and route to your SIEM, Slack, email or Jira. Anomity is SOC 2 Type II and complements Network, EDR, DLP and GRC controls rather than replacing them.
Harness engineering makes agents faster by giving them more context, more tools and fewer gates. You can't govern what you can't see, so the first step is seeing that harness on every machine. Book a 30-minute demo to see it on your own fleet.
Frequently asked questions
What is harness engineering?
Harness engineering is the term OpenAI used in a February 11, 2026 article for building the environment that lets coding agents such as Codex do reliable work. Instead of writing code, engineers design the scaffolding: a short AGENTS.md that points into versioned docs, custom linters and structural tests, tools the agent can call, per-task observability, and agent review loops. When the agent fails, the team asks what capability is missing and has the agent build it.
How much code did OpenAI's team build this way?
OpenAI reports that over about five months the repository grew to roughly a million lines of code and about 1,500 pull requests were opened and merged, with three engineers (later seven) averaging about 3.5 pull requests per engineer per day. The team estimates it took about a tenth of the time hand-written code would have. These are OpenAI's figures for one internal product, and OpenAI warns the approach depends on that repository's structure and tooling.
Why does OpenAI keep AGENTS.md short?
OpenAI found that one large AGENTS.md crowded out the actual task, made every rule look equally important, went stale quickly and could not be checked mechanically. Its team uses a file of roughly 100 lines as a table of contents that points to a structured docs directory, with linters and a recurring doc-gardening agent keeping that knowledge base current.
What are the security risks of an agent harness?
OpenAI's article does not report a security incident, but each harness layer is a control point. Instruction files and the docs they point to steer every agent run, so write access to them is a form of policy control. Tools such as gh carry credentials. Skills and MCP servers add code the agent trusts. Review comments, issues and logs are untrusted text that can carry prompt injection. And when agents review and merge their own pull requests, the audit trail becomes the main record of what happened.
How should teams secure AGENTS.md and other instruction files?
Treat them like code that controls behavior. Put AGENTS.md, any AGENTS.override.md files, the docs they reference and execution plans under code ownership with a required human reviewer, track every change, and remember that Codex merges instruction files from the Codex home directory and from the project root down to the working directory, so a file on a developer laptop can matter as much as one in the repository.
Is harness engineering related to Harness, the CI/CD company?
No. In OpenAI's article, harness engineering refers to engineering the environment around an AI coding agent: its instructions, tools, guardrails and feedback loops. It is not about any vendor product of the same name.
How does Anomity help with this?
The Anomity Endpoint Sensor inventories AI agents, MCP servers, extensions, plugins, skills, secrets, hooks and CLIs on every managed endpoint, so you can see the harness each coding agent runs with across the fleet. Where an agent exposes a hook, such as Claude Code PreToolUse or Codex CLI, Anomity can allow, deny or log a tool call before it runs. Changes and decisions land in a 90-day audit trail routed to SIEM, Slack, email or Jira. Anomity collects metadata only, redacts secrets on the endpoint, and complements EDR, DLP, network and GRC controls.




