Dev tools

Harness Engineering: What an Agent Harness Is

Harness engineering explained: what an agent harness is, its parts, agent harness examples, how it compares with context engineering, and how to build one.

By OmniAI Editorial · Nov 20, 2026 · 13 min read

Harness engineering is the work of designing everything around an AI model that turns it into a reliable agent: the tools it can use, the instructions and context it sees, the permissions it has, the tests and checks that verify its work, and the feedback loops that stop mistakes from repeating. That surrounding system is called the agent harness. The short formula many practitioners use is agent = model + harness, and for coding agents in particular, the harness often matters as much as which model you pick.

This guide explains what harness engineering is, where the term came from, the parts of an agent harness, real agent harness examples, how it differs from prompt and context engineering, and how to build a harness step by step.

What Is Harness Engineering?

What is harness engineering, in simple terms? A model on its own only sees the text it's given and produces text back. It can't run your tests, read your files, remember yesterday's decisions or check whether its code compiles. The harness supplies all of that:

  • Instructions: project rules, conventions and goals.
  • Context: the right files, documents and data at each step.
  • Tools: shell commands, APIs, browsers, search, databases.
  • Guardrails: permissions, sandboxes and approval steps.
  • Feedback: tests, linters, type checks and reviews that tell the agent when it's wrong.
  • Memory: notes and state that carry over between steps and sessions.

Harness engineering is designing, testing and improving that system so the agent produces good work consistently, not just in a lucky demo.

Where the Term Came From

The word "harness" had long been used for the code that runs a model through a test or a task. It took off as a discipline in early 2026:

  • In February 2026, OpenAI published "Harness engineering: leveraging Codex in an agent-first world", describing a five-month internal experiment in which a small team built a product of roughly a million lines of code without writing source code by hand. Engineers spent their time designing environments, specifying intent and building feedback loops for Codex agents. They wrote that their hardest challenges now centred on "designing environments, feedback loops, and control systems."
  • Developer Mitchell Hashimoto had written about engineering the harness around coding agents shortly before, and Thoughtworks' Birgitta Böckeler suggested his post may have inspired the term.
  • Böckeler's analysis on Martin Fowler's site described a harness as the tooling and practices "to keep AI agents in check", made of guides (which steer the agent before it acts) and sensors (which check what it did), each either computational, like a linter, or inferential, like an AI reviewer.

Anthropic uses the same language: its Claude Agent SDK is described as built on the agent harness that powers Claude Code, offered so developers can build other agents on the same loop, tools and context management.

The Parts of an Agent Harness

ComponentWhat it doesCoding agent example
InstructionsTell the agent the rules and goalsAGENTS.md or CLAUDE.md with commands and conventions
Context managementChoose what the model sees and whenSearching the repo, summarizing long sessions
ToolsLet the agent actShell, file edits, test runner, browser, MCP servers
Permissions and sandboxLimit what it can breakAsk before running commands; no network access
Verification (sensors)Check the workUnit tests, type checks, linters, builds
Architectural constraintsKeep the design consistentStructural tests that enforce layer boundaries
Memory and stateCarry knowledge across stepsPlan files, progress notes, decision logs
ObservabilityLet humans see what happenedLogs, traces, diffs, cost tracking
Human checkpointsKeep people in controlPlan approval, code review before merge
CleanupFight drift over timePeriodic agents that fix stale docs and rule violations

You don't need all of these for every agent. A small internal tool might need instructions, two tools and a test; a production agent that changes customer data needs much more.

A grey rounded block drawn in ink inside a larger light rounded frame, with three small ink-outlined squares on the frame's edges and one orange square on the right edge.
The model sits inside a harness of instructions, tools, checks and limits.

Harness Engineering vs Context Engineering vs Prompt Engineering

The three terms nest inside each other:

Prompt engineeringContext engineeringHarness engineering
Question it answersHow do I phrase this request?What should the model see at each step?What system does the agent work inside?
ScopeOne model callEverything in the context window across callsContext plus tools, permissions, checks, memory and feedback loops
Typical outputA better promptRetrieval, memory and summarization strategyA working agent environment with tests and guardrails
Who does itAnyone using AIDevelopers building AI appsTeams running agents on real work

Our guide to context engineering covers the middle layer in depth. Harness engineering adds the parts that act and verify: if context engineering decides what the agent knows, harness engineering also decides what it can do and how its work gets checked.

Agent Harness Examples

A coding agent harness

The best-documented agent harness examples come from software teams using Claude Code, Codex or similar agents:

  • Instructions in a short AGENTS.md file: how to install, test and lint, plus project rules. Our guide to AGENTS.md shows what to include.
  • Fast feedback: the agent runs unit tests and type checks after each change and gets clear error messages.
  • Mechanical rules: custom linters and structural tests that fail when code breaks architecture rules. OpenAI's team enforced one-way dependencies between layers this way.
  • Docs as a map: a structured docs folder with design notes and execution plans, kept up to date and checked in CI.
  • Permissions: the agent can edit files and run tests freely but must ask before installing packages or touching production config.
  • Review: humans or a second agent review every pull request before merge.
  • Cleanup: scheduled agents that find outdated docs and rule violations.

A customer support agent harness

  • Tools to look up orders and issue refunds up to a limit.
  • Policy documents in context for each request.
  • A hard rule that refunds above the limit go to a human.
  • Logs of every action for audit.
  • Evaluation against a set of real past tickets before each change.

A research agent harness

  • Web search and document retrieval tools.
  • A requirement to cite a source for every claim.
  • A checker that verifies citations exist and support the claims.
  • A token and time budget per task.

Reusable skills are becoming a standard part of harnesses too. Our guide to agent skills explains how packaged instructions and scripts let agents load expertise only when needed.

How to Build an Agent Harness

  1. Start with the task and how you'll check it. Before adding tools, define what "done and correct" means and how a machine can test it.
  2. Write short, specific instructions. Commands, conventions and red lines. Long manuals get ignored or crowd the context.
  3. Give the minimum tools needed, each with clear names, descriptions and error messages.
  4. Add fast verification. Tests, linters, type checks or validators the agent runs after every change. Clear failure messages are what let agents fix their own mistakes.
  5. Set permissions and a sandbox. Decide what the agent may do without asking, what needs approval, and what it can never do.
  6. Add human checkpoints where errors are costly: approving plans, reviewing merges, confirming payments.
  7. Observe everything. Log steps, tool calls, costs and outcomes so you can see where the agent struggles.
  8. Treat failures as harness bugs. When the agent makes a mistake, ask what was missing: an instruction, a tool, a test or a constraint. Fix the harness so the mistake can't repeat, as OpenAI's team put it: "When the agent struggles, we treat it as a signal."
  9. Clean up regularly. Remove stale instructions and tools; prune what the agent doesn't use.

Harness Engineering in Claude Code and Codex

If you use a coding agent such as Claude Code or OpenAI Codex, you're already building a harness, whether you call it that or not. The main levers:

LeverClaude CodeOpenAI Codex
Project instructionsCLAUDE.mdAGENTS.md
Reusable expertiseSkillsSkills and plugins
Extra toolsMCP serversMCP servers
PermissionsPermission modes and allow/deny rules/permissions, sandbox and command rules
Automatic checksHooks that run commands at set points, such as after each editYour test and lint commands, run by the agent; CI
Parallel workSubagentsSubagents and cloud tasks

A practical starting harness for a coding agent:

  1. A short instructions file with install, test and lint commands and five to ten project rules.
  2. Tests that run in under a minute for the area being changed.
  3. A linter and formatter the agent runs before finishing.
  4. Permissions that let it edit and test freely but ask before installing packages or running anything that touches external systems.
  5. Code review on every pull request.

A Harness Engineering Example: Before and After

Here's how harness engineering works in practice on a small team using a coding agent.

The problem: the agent kept importing database code directly into API handlers, breaking the team's layered architecture. Reviewers caught it, but it came back in every second pull request.

Prompt engineering fix (didn't hold): the team added "don't import the database in handlers" to the task prompt. It worked when someone remembered to include it.

Harness engineering fix:

  1. Instruction: a rule in the project instructions file explaining the layers and why they matter.
  2. Sensor: a lint rule that fails the build when a handler imports the database module, with an error message that names the allowed alternative.
  3. Feedback loop: the agent runs lint before finishing, sees the failure and fixes it itself.
  4. Cleanup: a weekly check for any remaining violations in older code.

The result: the mistake stopped reaching review, because the agent caught and fixed it on its own. That's the core idea: turn a recurring review comment into an instruction plus an automatic check.

How to Measure a Harness

Measure the outcomes the harness is meant to improve:

MetricWhat it tells you
Task success rateShare of tasks the agent completes correctly without human rework
Review reworkHow often reviewers request changes, and for what reasons
Repeat mistakesWhether the same error appears after you added a check for it
Time to greenHow long from task start until tests and checks pass
Cost per completed taskTokens and compute spent per successful result
Human interventionsHow often the agent has to ask or be stopped

Track these before and after each harness change, the same way you'd measure the effect of a code change.

Don't Overbuild the Harness

A harness can become its own maintenance burden. Practitioners warn that few agents need every component, and that heavy scaffolding written for older, weaker models can get in the way of newer ones. Some guidelines:

  • Add a component only when you've seen a failure it would prevent.
  • Prefer deterministic checks (tests, linters) over extra AI judges when possible.
  • Revisit the harness when you upgrade models; some workarounds become unnecessary.
  • Measure outcomes, such as task success rate, review rework and cost per task, rather than how sophisticated the harness looks.

Böckeler also raised open questions: whether harnesses will become templates that teams fork and struggle to keep in sync, whether harnesses work best on codebases designed for them, and how much effort it's worth spending to retrofit older, messier systems.

Three light rounded boxes drawn in ink in a row connected by ink arrows, with a curved ink arrow looping from the last box back to the first and an orange dot on the loop.
Every agent failure is a chance to add the missing instruction, tool or check.

Common Harness Engineering Mistakes

  • Instructions that are too long. A huge instructions file crowds the context and gets partly ignored. Keep it short and move details into documents the agent can open when needed.
  • Checks with unhelpful errors. A failing test that says only "assertion failed" teaches the agent little. Error messages that explain the rule and the fix let it correct itself.
  • Too many tools. Every tool adds choices and room for mistakes. Give the agent the few it needs, with clear names and descriptions.
  • No sandbox. Letting an agent run any command on a developer's machine or in production is a risk. Start restrictive and open up deliberately.
  • Relying on AI judges for everything. An AI reviewer can catch some problems, but deterministic checks such as tests, types and linters are cheaper and more reliable where they apply.
  • Never pruning. Harnesses accumulate rules and tools written for older models or old problems. Review them when you upgrade models.
  • Measuring activity instead of outcomes. Lines of code or number of tasks started say little; correct, merged work does.

Harness Engineering as a Job

"Harness engineer" is starting to appear in job descriptions at companies building AI agents. The role usually blends software engineering, testing and AI skills: designing tool interfaces, writing evaluation suites, building sandboxes and permission systems, and monitoring agents in production. If you already write good tests, clear developer documentation and reliable CI pipelines, you have most of the foundations.

Agent Framework vs Agent Harness

An agent framework is a software library that helps you build agents, with building blocks such as model calls, tool definitions and memory. An agent harness is the complete working environment around a specific agent: its instructions, tools, permissions, tests, checks and feedback loops, tuned for a particular job. You might use a framework to build a harness, but the harness also includes things no framework provides, like your project's tests, your architecture rules and your review process. Two teams using the same framework can end up with very different harnesses, and very different results.

FAQ

What is an agent harness?

An agent harness is everything around an AI model that makes it work as an agent: instructions, context management, tools, permissions, tests and other checks, memory and logging. The model provides intelligence; the harness provides the environment and guardrails.

What is harness engineering in simple terms?

It's the work of building and improving the system around an AI model so it can do real tasks reliably. Instead of only writing better prompts, you give the agent the right tools, information, limits and automatic checks.

Is harness engineering the same as context engineering?

No. Context engineering is about what information the model sees. Harness engineering includes context engineering but also covers tools, permissions, verification, memory and feedback loops.

Who coined harness engineering?

The term spread in early 2026, through Mitchell Hashimoto's writing on coding agents and OpenAI's February 2026 post about building a large product with Codex agents. Thoughtworks' Birgitta Böckeler then analysed the idea on Martin Fowler's site.

Do I need harness engineering for a simple chatbot?

Not much. A chatbot that only answers questions mostly needs good context. Harness engineering becomes important when an agent takes actions, such as editing code, changing data or using external tools, where mistakes have consequences.

All articles

Read next

Language

EnglishEnglish · en TürkçeTurkish · tr DeutschGerman · de العربيةArabic · ar

Account

Enter your email. We’ll send you a sign-in link and a 6-digit code. No password needed.

Sign in

Theme

Language

Show our email address

To keep spam out of our inbox, please confirm your own email first. We will send you a 6-digit code.

We send codes only to these providers: gmail.com, googlemail.com, outlook.com, hotmail.com, live.com, msn.com, proton.me, protonmail.com, pm.me, icloud.com, me.com, mac.com, yahoo.com, aol.com, gmx.de, gmx.net, web.de, t-online.de, yandex.com, omniai.blog