Start here

What Is Harness Engineering? [Complete AI Guide]

What is harness engineering in AI? A plain guide to agent harnesses, their six parts, a worked coding-agent example and how to start building one.

Abhishek Ashtekar presenting an agent control board beside What Is Harness Engineering text.
On this page
  1. What is harness engineering?
  2. What is an agent harness?
  3. Where the term harness engineering came from
  4. Why the harness changes results
  5. The six parts of an agent harness
  6. A worked example: fixing the streak bug properly
  7. Harness engineering vs prompt and context engineering
  8. Common mistakes in harness engineering
  9. When do you need harness engineering?
  10. How to start with harness engineering
  11. Learn harness engineering with my book
  12. Frequently asked questions
  13. Final thoughts
  14. Sources and further reading

The short answer

Harness engineering is the practice of designing everything around an AI model so it can work as a reliable agent. That covers the context it reads, the tools it calls, the permissions that limit it, the progress it saves and the checks that prove the work is done. The model does the reasoning. The harness decides what that reasoning can touch.

If you keep hearing the word "harness" and nobody stops to explain it, this guide is for you. I will show you what an agent harness contains, why it changes the result and how to start with one small task. This is about AI agents only. It has no link to the Harness software company or to the wire harnesses in cars, even though both show up when you search for the phrase.

The guide follows one example from start to end. Suppose you ask a coding agent to fix the weekly streak counter in a habit-tracker app. The agent edits a function, writes a confident summary and says the task is done. You open the app, skip a day on purpose, and the streak still shows the wrong number.

The model was able to fix that bug. It failed because nobody told it how the app defines a week, and no test ran before it claimed success. A harness closes that gap with the right facts, a test and a rule that the agent must show the test result.

What is harness engineering?

Harness engineering is the work of designing, testing and improving the system that wraps an AI model and lets it act. That system is the agent harness. Vivek Trivedy of LangChain sums it up in The Anatomy of an Agent Harness with a short formula: "Agent = Model + Harness". In his definition, every piece of code, configuration and execution logic that is not the model belongs to the harness.

The harness runs. Harness engineering is the habit of improving it. Mitchell Hashimoto, the co-founder of HashiCorp, describes that habit in plain terms. When an agent makes a mistake, you build a fix so that it never makes the same mistake again. Keep doing that for a few months and your harness will hold more knowledge about your project's weak points than any single prompt.

Four terms come up again and again, and it helps to keep them apart:

Term What it is Example from the streak task
Model The language model that reads text and predicts the next action or answer Any hosted or local large language model (LLM)
Agent harness Everything around the model that lets it act: instructions, tools, sandbox, state, loop rules, checks Claude Code, Codex CLI, or a 200-line Python loop you wrote
Agent The model and the harness running together on a task "Fix the streak bug and prove it with a test"
Harness engineering The practice of designing and improving the harness Adding a missed-day test after the agent claimed a false success

What is an agent harness?

An agent harness is the software layer that turns a model's words into controlled actions. The model asks to read a file or run a command. The harness decides whether that request is allowed, carries it out and hands the result back, and the model then chooses its next step.

People often mix this up with a framework. Google Cloud's explainer, What is an agent harness?, draws a clear line between the two. An orchestration framework helps a developer write agent code. The harness is the runtime environment where the agent does its work. Google also calls the harness a security checkpoint between the model and your other systems, because it enforces the permission boundaries.

You will rarely build a harness from nothing. Claude Code and Codex CLI arrive with a harness that their makers built. Birgitta Böckeler of Thoughtworks explains what is left for you in her martinfowler.com article, Harness engineering for coding agent users. The company that builds the coding agent owns one layer. You build an outer harness for your own project with instruction files, scripts, tests and permission settings.

That outer layer is where most people begin. It is also what a developer usually means by "my harness": the AGENTS.md file, the custom commands, the hooks and the test scripts that they have wrapped around a vendor's agent.

Where the term harness engineering came from

The word "harness" is much older than AI agents. Software teams have used "test harness" for decades to mean the code that runs a program under controlled conditions. Anthropic was already calling its Claude Agent SDK a "general-purpose agent harness" in November 2025, in Effective harnesses for long-running agents.

The full phrase spread in February 2026, and no single person owns it. Each of these write-ups added something:

  • Mitchell Hashimoto gave the habit its name on 5 February 2026. His post My AI Adoption Journey has a step called "Engineer the Harness", and his fixes were small. Some were single lines in AGENTS.md, each one written after a bad agent behaviour. Others were scripts, such as one that ran a filtered set of tests.
  • OpenAI showed how far the idea can go, six days later. In Harness engineering, Ryan Lopopolo describes five months in which Codex wrote every line of an internal product. The repository grew to about a million lines and roughly 1,500 merged pull requests. The engineers wrote none of that code. They spent their time making the repository, its documents and its logs easy for the agent to read, so that each new task started from a clear map of the project.
  • LangChain measured the effect on a benchmark, and I will come to that in a moment.
  • Birgitta Böckeler gave us useful words in April 2026. Guides steer an agent before it acts, and sensors check its work afterwards.

Definitions still differ a little from one company to the next. Treat any single diagram as a way to think about the subject, because there is no industry standard yet.

Why the harness changes results

The same model can give you very different results, and the clearest example I know comes from LangChain. In its post Improving Deep Agents with harness engineering, published in February 2026, the team took one coding agent from 52.8% to 66.5% on Terminal Bench 2.0. GPT-5.2-Codex was the model in both runs. What changed was the harness, including how much reasoning the model used at each stage.

You might expect something clever. The changes were ordinary engineering:

  1. A checklist step stopped the agent before it exited and made it verify its work against the task.
  2. A startup step mapped the working directory, so the agent knew where things were.
  3. Time warnings told the agent to finish up and switch to verification as the budget ran low.
  4. A loop detector counted edits to the same file and told the agent to rethink its approach.

The model was no smarter at the end. It could see more of its surroundings, and it had to check its work against the task before it was allowed to stop and report that it had finished. Give two teams the same model, and the team with the better working environment will be the one that trusts its agent.

None of this guarantees a correct answer. A good harness limits the damage and catches mistakes early. You still need realistic test tasks, and you still need a person to look when a mistake would be expensive.

The six parts of an agent harness

Look inside a vendor's coding agent or a small script on your laptop and you will find the same six jobs. This table shows the question each part answers, and what tends to break when nobody has answered it.

Part Question it answers Example in the streak task What breaks without it
Instructions and context What is the task, and what does the agent need to know now? AGENTS.md, task brief, the streak file, sample records The agent solves the wrong problem or guesses the rules
Tools What can the agent do beyond writing text? Read a file, edit a file, run the tests The agent describes a fix it cannot apply or check
Permissions and sandbox Where may it act, and what needs approval? A separate git branch, no access to production data A wrong command reaches real data or systems
State and memory How does progress survive a restart or a full context window? A progress file and a git commit after each step The agent repeats finished work or loses its place
Loop control When should it continue, retry, ask a person or stop? A 25-step limit and a repeat-action check Runaway cost or endless retries of a failing command
Verification and traces How do you know the work is done, and how do you debug a failure? A missed-day test and a saved log of tool calls "Done" means the agent felt confident

Instructions and context

Instructions tell the agent what to do and what finished looks like. Context gives it the facts it needs now, such as the right files, earlier decisions and the output of its last tool call. It is tempting to hand over everything you have. Resist it. More context often makes the result worse, because the facts that matter get lost among the ones that do not. OpenAI's team kept its AGENTS.md to about 100 lines and used it as a map to deeper documents, so the agent opened the detail only when it needed it.

Tools

A tool lets the agent do something outside the chat. The model asks for a tool call, and your code decides whether to run it and what to send back. A good name and description help the model choose the right tool. They cannot enforce anything, so put your checks in the code that runs the call.

Permissions and sandbox

When you write a rule in a prompt, you are asking the agent to behave. When you put the rule in the layer that runs its actions, you can refuse. You need both, and you should always know which one you are relying on. A disposable copy of your work protects you from a bad edit. Credentials limited to the task protect your other systems, and an approval step protects you from anything you cannot undo.

State and memory

Long tasks do not fit in one sitting, for people or for agents. In Anthropic's setup for long-running work, the first session writes a progress file, a startup script and a first git commit. It also writes a list of features in JSON, with each one marked as failing. Every later session reads the progress file, works on one feature and marks it as passing only after it has tested that feature.

Loop control

An agent chooses an action, looks at the result and chooses again. Something has to decide when that ends. A step limit is the simplest answer, and in most first harnesses it is the only one you need. A time budget and a check for repeated actions catch what a step limit misses.

Before you build a loop at all, read Anthropic's guide to building effective agents. It recommends the simplest solution that works, and it points out that a fixed workflow gives you more predictable results when the task is well defined.

Verification and traces

Böckeler sorts the controls in a harness into guides and sensors. Some sensors are computational, such as tests and linters. They are fast and give the same answer every time, so run them on every change. Others are inferential, such as a second model that reviews the work. Traces are the last piece. They record each step, and you will read them when you need to find the moment a run went wrong.

A worked example: fixing the streak bug properly

Let us go back to the habit-tracker app. The first attempt was a model and a one-line request. Here is the same task with a small outer harness around the same model:

  1. Write a task brief: a week runs Monday to Sunday, and a missed day resets the streak to zero.
  2. Point the agent at the streak file, the habit data model and two sample records, one with a missed day.
  3. Give it three tools: read a file, edit a file and run the test suite.
  4. Run it on a separate git branch with no access to production data or deploy commands.
  5. Add a test that feeds a missed-day record into the streak calculation and expects zero.
  6. Accept "done" only with passing test output, and stop the run after 25 steps.
  7. Save the full trace, so you can find the exact step behind any failure.

Once this works, keep the lasting rules in a short project file. The next task then starts with them already in place:

markdown
# AGENTS.md (habit-tracker)

- Streak logic lives in src/streaks.py. Weeks run Monday to Sunday.
- Run tests with: pytest tests/test_streaks.py -q
- Never edit files in data/production/.
- A task is done only when the relevant tests pass. Paste the output.

You did not touch the model. You gave it better information, a smaller space to work in and something it had to prove. If it fails in a new way next month, you add one more rule or check. That is the loop Hashimoto describes.

To see step 6 run, download streak_gate.py. It is a short Python script in which a scripted agent says "done" three times, and only the test decides when the fix counts. I explain how it works in my answers to common harness engineering questions.

Harness engineering vs prompt and context engineering

These three are layers of one system. Prompt engineering shapes the instructions, and context engineering decides what the model sees at each step. Harness engineering contains both of them and adds the part that acts: tools, permissions, saved state, loop control and verification.

I take one task through all three, with a table of symptoms for each, in the harness vs prompt vs context engineering comparison.

Common mistakes in harness engineering

Most beginners make the same mistakes in their first harness. Watch for these:

  • Fixing every failure in the prompt. A sentence such as "never touch production" is a request. A blocked path in the tool code is a boundary.
  • Trusting the agent's own "done". The agent's summary is not proof. Require test output or another check you can read.
  • Loading too much context. A huge instruction file pushes out the facts the agent needs for the current step.
  • Adding controls with no named failure. Each rule or check should answer a failure you saw or can describe.
  • Changing many things at once. If you change the model, the prompt and the tools together, you cannot tell which change helped.
  • Skipping traces. Without a record of each step, you can only guess at the cause of a failure.

The guide to why AI agents fail maps these and other symptoms to the harness part that is usually missing.

When do you need harness engineering?

You need it as soon as an AI system takes actions instead of only answering questions. If a chatbot drafts an email and you read it before you send it, a good prompt will do. If an agent edits files, calls APIs or runs for an hour while you are in a meeting, you want a harness around it. These are the signs I look for:

  • The agent can change files, records or anything outside the chat window.
  • A task takes more than a few steps or more than one session.
  • A wrong action would cost money or damage data.
  • You check every result by hand because you cannot tell when it is right.
  • The same mistake comes back after you correct it in chat.
  • You want to compare two models or two setups fairly.

The signs are the same outside coding. Suppose the habit-tracker team asks an agent to write each user's weekly progress email. It needs the right records, a tool to draft the message, a rule that it may not send anything without approval and a check that every number in the email matches the data.

If none of the signs sound familiar, a clear prompt may be enough for now. If two or more do, the time you spend on a harness will usually come back to you.

How to start with harness engineering

Start with one small task that you can check yourself. Add a control only when you can name the failure it prevents. A harness full of rules that nobody understands is as bad as having none. This is a good first sequence:

  1. Pick a task with a visible result, such as fixing one bug.
  2. Write down what "done" means in a sentence a test could check.
  3. Give the agent only the tools that task needs.
  4. Run it in a disposable workspace.
  5. Record every action, and read the trace when the run fails.
  6. Change one thing, run the same task again and compare the results.

When you want to see all of the parts in one place, the Python agent tutorial builds a small loop with tools, permissions, saved state and a completion check. The 30-day learning roadmap gives you a plan for each week. When you are ready to practise on your own, the list of harness engineering projects gives you tasks with a clear finish line, and the guide to testing AI agents shows you how to tell whether a change helped.

The Start Here guide and The 20 Must-Read Engineering Articles are two of the PDFs in my free resource pack.

Learn harness engineering with my book

When I was studying this subject, I kept finding one piece at a time. One article explained tools and another explained loops, but very few showed a beginner how the pieces fit together. I wrote The Harness Engineering Blueprint to put those pieces in order, from what an agent is to a harness in production. I believe it is the best book for learning harness engineering from the ground up.

You can read it beside the free companion course, where each idea becomes a small project that you can run and break. If you like to compare before you choose, I have also written about other books on harness engineering and courses that teach it.

Frequently asked questions

1. What is harness engineering, in simple terms?

Harness engineering means building the system around an AI model so that it can finish real tasks without you watching each step. You decide what the model sees, what it may touch and how its work gets checked. The model does the thinking, and your harness turns that thinking into work you can trust.

2. What do people mean when they say "my harness"?

They usually mean the setup they have added around a coding agent such as Claude Code, Codex CLI or Cursor. That includes their AGENTS.md or CLAUDE.md file, their hooks, their permission settings and their test scripts. Böckeler calls this the outer harness, and you own it even if you never write agent code yourself. I answer the original Reddit question in more detail on the harness engineering questions page.

3. Is "harness" a new buzzword for something old?

Partly, yes. Test harnesses and sandboxes have been around for years. Some developers also ask whether the new name is only a label for tweaking prompts. What is new is treating all of those parts as one system around a model, and improving that system each time an agent fails. The name is useful when it lets a team talk about that work without calling everything a prompt.

4. What is the difference between an agent harness and an agent framework or SDK?

A framework gives you parts, and a harness is the working system you build with them. LangGraph, for example, gives you graphs and state management, but you still decide what your agent may do and how its work is checked. The line is getting thinner. Anthropic calls its Claude Agent SDK a general-purpose agent harness, and Microsoft's Agent Framework now includes a ready-made Agent Harness built from its own parts. I compare the main options in my guide to harness engineering tools.

5. Who coined the term harness engineering?

No single person owns it. Mitchell Hashimoto called the habit "harness engineering" in a post on 5 February 2026, and OpenAI used the phrase as the title of an article on 11 February. LangChain and Birgitta Böckeler developed the idea over the next two months, and the name stayed.

6. Do better models make harness engineering unnecessary?

No, but they do make some parts of it unnecessary. LangChain says as much about its own loop detector, which works around a weakness that it expects newer models to lose. A stronger model still needs to know what it may touch, where to save its work, when to stop and how to prove that it has finished. When you upgrade the model, run your test tasks again and remove any check that no longer catches anything.

7. Is Claude Code an agent or a harness?

Claude Code is the harness, and Claude Code running a Claude model is the agent. Anthropic's page How Claude Code works calls the product an "agentic assistant" and calls the layer it adds around the model the "agentic harness". A Markdown file in .claude/agents/ is a subagent definition, which configures a helper with its own context window.

8. Does the harness matter more than the model?

You need both, and they do different jobs. The model sets the limit of what is possible, and the harness decides how often you get there. In LangChain's test, the same model gained 13.7 points on Terminal Bench 2.0 after harness changes alone. Try any change on your own tasks before you believe it will help you.

9. How can I tell whether a failure comes from the model or the harness?

Start with the trace. If the agent never saw the fact it needed, had no tool for the job or was never asked to prove its work, the fault sits in the harness. If it had all of that and still reasoned badly, the model is the more likely cause. Then run the same task again with one change and compare. A 2026 study, Model or Harness?, explains why this step matters: the same visible failure can need a model fix, a harness fix or a better test, depending on where it started.

Not directly. Harness is also the name of a software delivery company, and wire harness engineering designs the cable assemblies inside cars and machines, which is why search results for the phrase are mixed. A test harness or an evaluation harness runs a program or a model under controlled conditions to measure it. An agent harness runs your agent while it does real work, so the two can share code but do different jobs.

Final thoughts

You do not need a large harness to start harness engineering this week. Take one small task, such as the streak bug in this guide, and write down what a correct result looks like. Add one test and one limit. When the agent fails, read what it did before you change anything.

After one task like that, you will start to see the same gaps in every agent you use. The 30-day learning roadmap is a good place to go from there.

Sources and further reading