What Is Harness Engineering? The Agent Harness, Explained
Harness engineering is designing the loop, tools, context and checks around an AI model. Agent = Model + Harness, explained with guides, sensors and gates.

Harness engineering is the practice of designing the harness around an AI model: the loop, tools, context, permissions and checks that turn a model into an agent. The shorthand is Agent = Model + Harness: if it isn't the model, it's the harness. Mitchell Hashimoto described it in February 2026 as fixing each mistake an agent makes so the agent never makes it again. In practice that means guides that steer the agent before it acts, like AGENTS.md files and skills, and sensors that check its work after, like tests and linters.
The agent harness matters more than most people expect. The AI company LangChain changed only the harness around its coding agent, and the agent moved from the Top 30 to the Top 5 on Terminal Bench 2.0, a benchmark of terminal tasks. Same model, different harness, different agent. The system around a model can matter as much as the model.
Watch the video: https://youtu.be/ChtIYKq9DOg
What is a harness in artificial intelligence?
A harness is everything around the model that lets it act. Vivek Trivedy of LangChain puts it in one line: "If you're not the model, you're the harness." His definition: a harness is "every piece of code, configuration, and execution logic that isn't the model itself". That covers system prompts; tools, skills and MCP servers; bundled infrastructure such as a filesystem, a sandbox and a browser; orchestration logic; and hooks for things like lint checks.
Researchers have also mapped the agent harness from the inside. Paul Barbaste and colleagues studied the source code of eleven production coding harnesses, including Claude Code, Codex CLI and Gemini CLI. They found seven canonical subsystems:
- Agent loop: the cycle of acting, observing the result and acting again.
- LLM integration: the connection to the model.
- Tools and actions: what the agent can do, such as reading files or running commands.
- Memory and context: what the model sees, and what carries over.
- Safety and permissions: what the agent is allowed to do.
- Orchestration: how work is split and handed off.
- Extensibility: the ways you add to the harness.
Not the company called Harness. Harness is also the name of a software delivery platform that automates continuous integration and delivery, which is why people ask whether harness is the same as Jenkins. An agent harness is something else: the runtime around a model.
Is Claude Code harness engineering?
Claude Code is a harness. It is one of the eleven coding harnesses in the source-code study. Give Claude Code a small task and you can watch the harness loop turn: the agent reads the files, makes a plan, calls a tool, edits the code, runs the tests, reads the result, and goes round again until it decides the task is done.
Lilian Weng describes the harness as "the system surrounding a base model that orchestrates execution and decides how the model thinks and plans, calls tools and acts, perceives and manages context, stores artifacts, and evaluates results." Note the word decides: in that loop, the agent decides when it is finished. That matters later.
So Claude Code is the harness, and harness engineering is how you shape it: the instruction files, skills, hooks and tests you give it.
What is harness engineering?
Mitchell Hashimoto, co-founder of HashiCorp, named the practice in passing. In "My AI Adoption Journey" (5 February 2026), under a step called "Engineer the Harness", he wrote that he'd "grown to calling this 'harness engineering'": "anytime you find an agent makes a mistake, you take the time to engineer a solution such that the agent never makes that mistake again." He describes two forms of fix: lines in AGENTS.md, each based on a bad agent behaviour, and real tools, such as scripts that take screenshots or run filtered tests.
Days later, OpenAI published Harness engineering: leveraging Codex in an agent-first world (Ryan Lopopolo, 11 February 2026), the write-up credited with naming the discipline. As Birgitta Böckeler reports, the team worked with "no manually typed code at all". Instead, its engineers built the harness: a knowledge base in the codebase that the agents read, architecture rules enforced by custom linters and structural tests, and agents that run periodically to clean up drift.
With that harness, OpenAI reports, the agents wrote a product of over 1 million lines of code. By autumn the arXiv study could define the field plainly: harness engineering, "named as a discipline in early 2026, is the design and evolution of that runtime."
What are guides and sensors in harness engineering?
Birgitta Böckeler, a Distinguished Engineer at Thoughtworks, gives the most practical frame. In Harness engineering for coding agent users (2 April 2026), she sorts the controls in a harness into two kinds:
- Guides (feedforward): guides "anticipate the agent's behaviour and aim to steer it before it acts". Examples: AGENTS.md or CLAUDE.md files, and skills.
- Sensors (feedback): sensors "observe after the agent acts and help it self-correct". Examples: tests, linters, type checkers and AI code review.
Each control is also either computational or inferential. Computational controls are deterministic and fast, run by ordinary code, like a test. Inferential controls are judged by a model; they are slower and their results are less deterministic.
- Computational: Guides: steer before the agent acts: Code mods, such as OpenRewrite recipes; Sensors: check after the agent acts: Tests, linters, type checkers, structural tests in a hook
- Inferential: Guides: steer before the agent acts: AGENTS.md, CLAUDE.md and skills with coding conventions; Sensors: check after the agent acts: AI code review, a large language model as judge
Source: Böckeler, martinfowler.com.
What is the difference between harness engineering and context engineering?
Context engineering is about what the model sees; harness engineering is about everything around the model. Anthropic calls context engineering "the natural progression of prompt engineering": curating the tokens the model sees while it works. Harness engineering covers the whole runtime, and Lilian Weng counts "workflow design (e.g. loop engineering), evaluation, permission controls, and persistent state management" among its parts.
- Prompt engineering: What it shapes: The instructions given to the model; Source: Anthropic
- Context engineering: What it shapes: The tokens the model sees while it works; Source: Anthropic
- Harness engineering: What it shapes: The whole runtime: loop, tools, context, permissions, checks; Source: Barbaste et al.
- Loop engineering: What it shapes: The outer loops that verify the agent's work and run it again; Source: Barbaste et al., Weng
- Agentic engineering: What it shapes: The wider practice: orchestrating agents and overseeing them; Source: Karpathy, via Turing College
AI researcher Andrej Karpathy proposed the wider term on 4 February 2026: "you are not writing the code directly 99% of the time, you are orchestrating agents who do and acting as oversight."
Agentic engineering is heading toward agents running the whole plan, build and verify loop on their own. Human judgment stays in three places: setting the intent, deciding what counts as done, and making the decisions that need a person.
Where do Claude Code, Codex and Cursor fit?
Claude Code, Codex and Cursor are harnesses that compete to do the work. Above them can sit a control plane: an orchestrator and gatekeeper, independent of any one harness. Levr is one. Levr holds the plans, issues, tests, project context and gates, whichever harness does the work, and works with Claude Code, Cursor and Codex, plus any MCP client.
Where harness engineering breaks: the agent checks its own work
The sensors usually live inside the agent's own loop. The agent writes the test, runs it and reports the result. So the agent can narrow a test until it passes, or report done when nothing ran. Sensors are built to give the agent "a loop for the agent to self-correct before a human even looks at the code", and that same loop is where the agent can pass itself.
Even OpenAI's flagship write-up leaves a gap here. Böckeler: "What I am missing in the write-up is verification of functionality and behaviour." The arXiv study points the same way: it names "verify-on-stop guards" and an outer verification loop above the agent's own cycle as recurring patterns.
The fix: checks written before the work, outside the agent's reach, and decided on evidence. For example, tests the agent can't edit, or a recorded check in a real browser. Pull request CI helps, but it checks the code change, not the task's definition of done.
Where harness engineering breaks again: guides per harness, decisions in a transcript
Each harness keeps its own guides: CLAUDE.md here, AGENTS.md there, different skills and hooks. Hashimoto's own fix is to "update the AGENTS.md (or equivalent)", so a team running several harnesses writes the same lesson again for each one, and ends up with several definitions of done.
The agent's own choices are the second gap. Choices such as which library to use or which schema to adopt scroll away in a transcript, so the hard-to-undo ones can ship before anyone sees them. Karpathy's frame asks people to act "as oversight", but oversight needs a record to look at.
The fix: guidance and a definition of done written once for every harness, and the agent's decisions on the record, with the hard-to-undo ones waiting for a person.
How Levr gates decide done on evidence
Levr uses gates: checks written before the work starts that an agent can't argue its way past. The checks run in your checkout, on your machine or in CI. Every check records the exact command, its exit code and its output, and Levr decides pass or fail from those facts. Nothing passes on the agent's say-so. If zero tests ran, the gate fails, and if a required gate fails, the task can't move to Done.
Some checks need hands on the app. Levr Browser turns your coding agent into a testing agent, in your own browser: the agent opens the app, clicks through it and reads the console, and its screenshots and recordings attach to the Levr issue, test or run they belong to.
How Levr rules write the fix once for every harness
Levr keeps rules: the guidance agents follow, written once in Levr. Every harness can read the rules through Levr's MCP tools, get_rules and manage_rules, whether the work runs in Claude Code, Cursor, Codex or any MCP client. So Hashimoto's fix is written once, for every harness.
A rule an agent proposes stays inactive until a person turns it on. And the same gates hold every harness to one definition of done.
How Levr's decision ledger keeps people in the loop
Levr has a decision ledger: a decision log for agents. Agents record each decision as they work through the record_decision MCP tool, and every issue has a Decisions section sorted by how hard each decision is to undo. A person confirms or overrides a decision in one click, and a plan shows the decisions made on its sub-issues.
When an agent needs approval, the request waits in the issue's Decisions section for a person.
So the harness loop keeps running, the agent's choices stay on the record instead of scrolling away, and people step in for the decisions that need them.
Recap: the harness parts that belong outside any one agent
An agent is a model plus a harness. Harness engineering shapes that harness, with guides before the agent acts and sensors after. The parts that decide done, carry the lessons and hold the decisions belong outside any one agent.
- Guides: What it does: Steer the agent before it acts; Inside one harness: CLAUDE.md, AGENTS.md, skills, one set per harness; In Levr: Rules, written once and read by every harness over MCP
- Sensors: What it does: Check the work after the agent acts; Inside one harness: Tests and linters the agent runs and reports on; In Levr: Gates, decided from command, exit code and output
- Human oversight: What it does: Intent, what counts as done, decisions; Inside one harness: Choices in a transcript that scrolls away; In Levr: The decision ledger, with approvals that wait for a person
Gates verify that the work matches the plan; they don't decide whether the plan was right. That part stays with people.
Better harnesses help more
Better models help. Better harnesses help more. Try Levr free.
