Explainer

Harness Engineering: Why AI Agents Need It

Harness engineering is the system built around an AI model that makes agents reliable. OpenAI shipped ~1M lines of code with it, none typed by hand. Here is how it works.

By Ricardo de Jong 9 min read 8:44 video

Watch the explainer

Three engineers at OpenAI shipped about a million lines of production code in five months. None of them typed a line of it. Every function, every test, every CI config was written by AI agents, across roughly 1,500 pull requests. The thing that made it work was not a smarter model. It was everything they built around the model.

That “everything around the model” has a name now: harness engineering. It is the fastest-rising skill in AI development, and it explains why two teams using the exact same model can get wildly different results. This guide covers what a harness is, why agents fall apart without one, how the leading teams build them, and where the whole idea still breaks.

What is harness engineering?

Harness engineering is the practice of designing the system around an AI model so it can build software reliably, not just answer questions. The formula the field has settled on is simple: Agent = Model + Harness. The model supplies the intelligence. The harness is literally everything else, the workflows, constraints, validation loops, tool interfaces, permissions, and memory that make the intelligence useful.

Picture a horse. Powerful, tireless, fast, and with no saddle or reins it runs wherever it wants. That is what an unguided model does, and the polite word for it is vibe coding. The harness is the saddle, bridle, and reins that channel all that raw power toward one destination. You, the developer, are the rider. You do not do the running anymore. You steer.

Model
LLM

The raw intelligence

Harness
  • Workflows
  • Constraints
  • Validation loops
  • Tool interfaces
  • Permissions
  • Memory

Everything around the model

Agent
Useful, reliable
software
Fig. 1 The formula behind the field. Wrap a capable model in workflows, constraints, validation, tools, permissions, and memory, and you get an agent that ships reliable software instead of plausible-looking guesses.

Why do AI agents fail without a harness?

Because raw code generation is the easy part, and it is mostly solved. Models can produce functions, classes, and whole modules on demand. The failure shows up downstream: 69% of teams that use AI coding tools frequently report deployment problems, according to a Harness.io industry survey. Not occasionally. Frequently. The faster you generate code, the more strain everything past generation has to absorb.

Without structure, agents produce what the industry now calls AI slop: inconsistent patterns, ignored conventions, and architectural drift scattered across the codebase. One developer described an agent that found a temporary workaround and copied it five or six times across similar files, treating a hack as the house style. Ripping it out cost more than any feature he shipped that week. The problem was never that the model is too dumb. Smart without structure is just chaos at higher speed.

How does a harness actually work?

Through two kinds of control. Martin Fowler’s team published the clearest framework in April 2026, splitting a harness into guides and sensors. Guides are feedforward controls that steer the agent before it acts: an AGENTS.md file, architecture docs, coding principles, a legible directory layout. They raise the odds the agent does the right thing on the first try. Sensors are feedback controls that observe after it acts: linters, type checkers, test suites, AI code review.

Each control runs in one of two modes. Computational controls are deterministic and fast, like a linter catching a violation the instant it appears. Inferential controls are semantic and slower, like an AI reviewer flagging a subtle design smell that no rule could catch. Weak harnesses lean on one. The strong ones combine all four quadrants, fast checks for the obvious and slow judgment for the rest.

Guides
Feedforward
  • AGENTS.md
  • Architecture docs
  • Coding principles
  • Directory layout
Before the agent acts
Sensors
Feedback
  • Linters
  • Type checkers
  • Test suites
  • AI code review
After the agent acts
Computational Deterministic + fast. A linter catches a violation instantly.
Inferential Semantic + slower. An AI reviewer flags a subtle design issue.
Fig. 2 Fowler's two control mechanisms. Guides shape behavior before the agent acts; sensors catch problems after. Each runs computationally (fast, deterministic) or inferentially (semantic, slower).

What does OpenAI’s harness look like?

It looks like rules the agent physically cannot break. OpenAI enforces strict layered dependencies: types flow to config, config to repository, repository to service, service to runtime, runtime to UI, and never the other way. If an agent tries to import a UI component into the data layer, the harness blocks it at the pre-commit stage before the bad code ever lands.

The clever part is what happens next. The harness does not just reject the code and stop. It parses the error, extracts what went wrong, and feeds that back into the agent loop as an explicit fix instruction. The agent reads the correction and repairs itself. That self-correction loop, error to feedback to fix without a human in the middle, is the beating heart of harness engineering. Documentation is the single source of truth, and it is mechanically enforced rather than politely suggested.

UI what users see
Runtime wiring + entrypoints
Service business logic
Repository data access
Config settings
Types the shared base
UI imports Types directly Pre-commit blocks it Error parsed into a fix Agent corrects itself
Fig. 3 OpenAI's layered architecture. Imports may only flow downward. An illegal one is blocked at commit, turned into a fix instruction, and handed back to the agent, which corrects itself and tries again.

The other half is context. Early harnesses dumped every rule and convention into one giant markdown file, which bloated the context window and actually degraded the model’s reasoning. Modern harnesses use progressive disclosure instead: a small root file acts as a table of contents, and the harness pulls in only the specs relevant to the file the agent is touching. The agent gets the right context at the right time, and nothing more.

Harness engineering vs prompt and context engineering

It is the third step in a clear progression, each one widening what the developer designs. In 2024, the skill was prompt engineering: phrasing a single request well. In 2025, it was context engineering: curating the documents, examples, and state the model could see. In 2026, it is harness engineering: building the whole environment the model runs inside, including the loops that let it work unattended for hours.

The difference is scope. A prompt shapes one call. Context shapes one session. A harness shapes an entire autonomous workflow, and it is the first of the three that has to think about failure, recovery, and verification rather than just input.

  1. 2024 Prompt engineering Craft the right input for a single model call.
  2. 2025 Context engineering Curate what information the model sees.
  3. 2026 Harness engineering Design the whole system that runs around the model.
Fig. 4 One discipline, three eras. Each stage keeps the last and adds a wider ring of design: from the words you send, to the context you curate, to the system you build around the model.
DimensionPrompt engineeringContext engineeringHarness engineering
Peak year202420252026
Unit of designOne model callOne sessionA whole workflow
You controlThe wordingWhat the model seesThe entire environment
Main toolsPhrasing, examplesRetrieval, memory, docsGuides, sensors, loops, sandboxes
Handles failure?NoBarelyYes, self-correction
Time horizonSecondsMinutesHours, unattended
Who does itAnyonePower usersEngineering teams

The proof: same model, better harness

The strongest evidence is teams getting big jumps without touching the model at all. LangChain’s DeepAgents coding agent went from 52.8% to 66.5% on Terminal Bench 2.0, climbing from outside the top 30 to the top 5, by changing only the harness. Same model, same weights, better system around it. That is as close to a controlled experiment as this field gets.

It is not a one-off. Datadog’s BitsEvolve initiative wraps an agent in simulation tests against production-like load and feeds the telemetry straight back, and the loop produced a tenfold ingestion speed-up while humans only defined the performance target. And Manus, an agent company that rebuilt its architecture five times in six months, was reportedly acquired by Meta for around $2 billion. The acquisition was for the harness, not the model underneath it.

Datadog · BitsEvolve 10×

ingestion speed-up from an agent that iterates against simulated production load. Humans only set the performance contract.

LangChain · DeepAgents 52.8 → 66.5%

jump on Terminal Bench 2.0, outside the top 30 to the top 5, by changing only the harness. Same model, same weights.

Manus · acquisition $2B

reported price Meta paid for an agent company that rebuilt its architecture five times in six months. The buy was for the harness.

Fig. 5 Three results where the harness did the work. Each team kept the model fixed and changed the system around it, and the numbers moved anyway.

Frameworks vs harnesses, and where MCP fits

Frameworks and harnesses are not the same layer, and conflating them is a common mistake. LangGraph handles stateful workflows, CrewAI does multi-agent orchestration, Mastra targets TypeScript, and Google’s ADK plugs into its cloud. Those are frameworks: the raw materials. A harness is built on top of a framework. Claude Code, OpenAI’s Codex, and LangChain’s DeepAgents are production harnesses, the runtime that actually governs how an agent executes.

The connective tissue is MCP, the Model Context Protocol that Anthropic introduced in November 2024 and the industry adopted. Instead of cramming every tool definition into the context window, agents connect to specialized MCP servers on demand and pull in only the tools they need. That is infrastructure-level thinking applied to agents, and it is what lets a harness stay lean as the number of available tools grows.

Where does harness engineering fall short?

In three honest places. First, the upfront cost is real. Building a proper harness means defining fitness functions, instrumenting observability, standing up sandboxes, and writing custom linters. For a small team still hunting product-market fit, that is premature, and plain vibe coding is the better call until the stakes grow.

Second is the evaluator problem: models are bad at grading their own work, so an agent will happily write a test designed to pass rather than one that probes edge cases. Serious harnesses separate the generator from the evaluator, different agents with different roles. Third, and least solved, is what Fowler’s team calls the behavior harness gap. A harness can prove that code is well-structured and passes its tests. It cannot yet prove the software does what users actually need.

How do you start building a harness?

Start with the cheapest controls and add structure only where agents actually slip. A practical first harness is mostly guides and sensors you already half-have. Write an AGENTS.md that states your conventions in plain language. Make the directory structure legible, because your codebase, not your prompt, is the agent’s real context. Then turn on the sensors: linters, type checkers, and a test suite the agent must pass before anything merges.

From there, the field has converged on a three-loop mental model. The outer loop is project level: capture intent, define the architecture, set the constraints. The middle loop is task level: break work into discrete pieces, each with clear acceptance criteria. The inner loop is the agent’s own plan-act-verify cycle inside a single task. Separate the agent that writes from the agent that judges, keep humans on intent and review, and you have the skeleton of a real harness.

The bottom line

Harness engineering is the recognition that in 2026, the model is a commodity and the system around it is the moat. The intelligence is mostly bought off the shelf; the constraints, feedback loops, and guardrails are what you actually build. OpenAI put it plainly: building software still demands discipline, but the discipline now shows up in the scaffolding rather than the code.

The model is the horse. The harness is the reins, the saddle, the bridle. And you are the rider. You do not run anymore. You steer.

Watch the 9-minute explainer

Frequently asked questions

What is harness engineering?

Harness engineering is the practice of designing the system around an AI model so it can build software reliably. The formula is Agent = Model + Harness. The model is the intelligence; the harness is the workflows, constraints, validation loops, tools, permissions, and memory that channel it toward a coherent goal.

How is harness engineering different from prompt engineering?

Prompt engineering (2024) crafts the input for a single model call. Context engineering (2025) curates what the model sees. Harness engineering (2026) designs the entire environment the model operates in, including the feedback loops and guardrails that let an agent run for hours and correct its own mistakes.

Why do AI agents fail without a harness?

Raw code generation is mostly solved, but 69% of frequent AI coding users report deployment problems. Without structure, agents produce inconsistent patterns, ignore conventions, and copy temporary workarounds everywhere. The model is smart enough; smart without structure is just faster chaos.

What is the difference between guides and sensors?

In Martin Fowler's framework, guides are feedforward controls that steer the agent before it acts, like an AGENTS.md file or architecture docs. Sensors are feedback controls that observe after it acts, like linters, type checkers, and tests. The best harnesses combine both.

Does harness engineering replace developers?

It changes the job, not the headcount to zero. The discipline shifts from writing code to designing the environment the agent works in: the constraints, fitness functions, and review gates. You stop being the typist and become the architect who steers, delegates, and reviews.

Do I need a harness for a small project?

Often no. Building a proper harness means defining fitness functions, sandboxes, and custom linters, which is real upfront cost. For a startup chasing product-market fit, plain "vibe coding" is genuinely the better call until the codebase and stakes are large enough to justify the scaffolding.

Sources

  1. OpenAI · "Harness Engineering: Leveraging Codex in an Agent-First World" (Feb 2026) · retrieved 2026-06-05
  2. Martin Fowler · "Harness Engineering for Coding Agent Users" (Apr 2026) · retrieved 2026-06-05
  3. Anthropic · "Harness Design for Long-Running Apps" · retrieved 2026-06-05
  4. InfoQ · "OpenAI Introduces Harness Engineering with Codex" · retrieved 2026-06-05
  5. Harness.io · State of AI-assisted software delivery (AI velocity report) · retrieved 2026-06-05
  6. DEV Community · "Agent Harnesses: Why 2026 Isn't About More Agents" · retrieved 2026-06-05
  7. Anthropic · "Introducing the Model Context Protocol" (Nov 2024) · retrieved 2026-06-05
</>

Ricardo de Jong

Creator of Devsplainers

Ricardo de Jong makes Devsplainers, turning complex developer and AI topics into short animated videos and written companions. Each article is built from the same research and script behind the video. No hype, no jargon walls.

The newsletter

Liked this? Get the Take-Outs.

One email every Tuesday: a spicy take on a trending dev topic, video out-takes, and the tool of the week. Free.

Subscribe
<devsplainers>