Harness Engineering Explained: What It Is, Why It Matters and How It Works (With Real Examples)
#artificial-intelligence
#ai
#prompt-engineering
#ai-agents
#harness-engineering
If you have followed AI news in 2026, you have probably seen a new term everywhere harness engineering. It is being called the next big skill after prompt engineering and context engineering. Big companies like OpenAI and AWS are building products around it. Engineers on LinkedIn and X are debating it every week.
But most articles on this topic use heavy language and skip the basics. This article explains harness engineering in plain words, shows the real problem it solves, walks through how it works step by step and gives you real examples you can actually learn from. By the end, you will know:
- What a "harness" means in AI
- What harness engineering is and where the term came from
- What problem it solves and why it matters right now
- How it works, step by step
- Two real world examples (one from AWS, one from OpenAI)
- How to talk about this topic in an interview, with rough timing
- Common mistakes people make
- FAQs
Let's start with the basics.
What Is a Harness in AI?
Think about a horse. A horse is strong and fast. But without a saddle, reins and a bridle, it will run wherever it wants. The harness is what turns that raw strength into something useful and controlled. The rider decides the direction. The harness makes sure the horse's power actually goes there. An AI model works the same way.
A large language model (like GPT or Claude) is powerful. It can write, reason and plan. But on its own, it just produces text. It cannot:
- Remember what happened in a task from yesterday
- Call an API and retry if it fails
- Check its own output against a rule or a schema
- Know which files or tools it is allowed to touch
- Stop itself when it is going in the wrong direction
A harness is the system built around the model that handles all of this. It is the code, rules, tools, memory and checks that sit between the raw model and the real task.
In simple words:
Harness = everything around the model that makes it actually work in the real world.
This idea is often written as a short formula that most engineers use today: Agent = Model + Harness
The model does the thinking. The harness does everything else :- memory, tool calls, permission checks, retries and validation.
A simple picture of the flow:
User → Harness → Model → Tools → Validators → Response
The user's request does not go straight to the model. It first passes through the harness, which adds context, memory and rules. The model then reasons and decides what to do. If it needs a tool, the harness runs that tool call. Before anything goes back to the user, a validator checks the output. Only then does the final response get sent back.
What Is Harness Engineering?
Harness engineering is the practice of designing and building that harness. It covers things like:
- What instructions and rules you give the agent (system prompts, guideline documents)
- What tools and APIs the agent can call
- How the agent remembers past context (short term and long term memory)
- How you check the agent's output before it is trusted
- How you control cost, time and number of steps the agent can take
- How you log and monitor what the agent is doing
- When a human needs to step in and approve something
Where did the term come from?
The term became popular after OpenAI published an engineering post in February 2026, written by engineer Ryan Lopopolo. In that post, OpenAI's Codex team shared a five-month experiment where they built and shipped a real internal software product about one million lines of code with zero lines written directly by a human. Every line of application code, tests, CI configuration and documentation was written by their AI coding agent, Codex. Humans only steered the work. they did not write the code by hand.
The interesting part was not that the AI wrote code. It was how the team made this reliable. They did not get better results by writing longer prompts. They got better results by building a proper system around the model repository knowledge, rules the agent had to follow, automated checks and feedback loops. OpenAI called this system the "harness," and the name stuck.
Soon after, Mitchell Hashimoto (known for building Terraform and Ghostty) summed up the whole idea in one short formula that spread fast across the AI community:
Agent = Model + Harness
Later, Martin Fowler's team at Thoughtworks (the post was written by Birgitta Böckeler) added more structure to the idea. They split harness components into two simple types:
- Guides rules that shape the agent before it acts. Examples: system prompts, instruction files, coding guidelines.
- Sensors checks that catch problems after the agent acts. Examples: automated tests, output validators, evaluation scripts.
This "guides and sensors" way of thinking is now a common way engineers describe harness design.
Why Does Harness Engineering Matter Now?
Here is the real reason this topic became important in 2026: AI models are becoming similar to each other.
A year or two ago, picking the "best" model made a huge difference. Today, top models from different companies score close to each other on most benchmarks. So the model itself is no longer the biggest lever for getting better results. The harness is.
LangChain, a well-known company that builds AI agent tools, shared research showing that changing only the harness while keeping the exact same model moved a coding agent from rank #30 to rank #5 on a public benchmark. Nothing about the model changed. Only the system around it changed: the tools it could use, how directory context was given to it, how outputs were checked and how time budgets were enforced.
This is why teams at companies like Stripe and GitHub adopted harness thinking so quickly. It gives them a way to improve results without waiting for a better model to be released.
In short, harness engineering solves this problem:
A raw model is not reliable enough for real work on its own. The harness is what turns an unreliable model into a dependable agent that can be trusted with real tasks.
Harness Engineering vs Prompt Engineering vs Context Engineering
People often mix these three up. Here is the simple difference:
- Prompt engineering writing the right words to get a good single response from a model.
- Context engineering deciding what information to put inside the model's context window so it has the right facts to work with.
- Harness engineering building the full system around the model: tools, memory, checks, permissions, retries and monitoring, across an entire task or workflow, not just one response.
Prompt engineering and context engineering are both part of a harness. But a harness is much bigger. It is the whole environment the agent lives and works in.
Here is a side-by-side comparison:
| Prompt Engineering | Context Engineering | Harness Engineering | |
|---|---|---|---|
| Scope | A single message to the model | What information goes into the context window | The full system around the model, across a whole task |
| Goal | Get a better single response | Give the model the right facts at the right time | Make the agent reliable, safe and repeatable in production |
| Includes | Instructions, examples, tone, format | Retrieved documents, memory snippets, tool outputs | Prompts, context, tools, memory, validation, limits, logging |
| Time horizon | One request | One request or one session | An entire task or many tasks over time |
| Example | Rewriting a prompt to get a cleaner JSON output | Adding the right past ticket history before asking for a support reply | Building the tool router, retry logic and validators for a support agent |
In short: prompt engineering fixes how you ask. Context engineering fixes what the model knows. Harness engineering fixes the whole system the model operates inside.
How Harness Engineering Works, Step by Step
Building a harness is not one single thing. It usually comes together in these steps:
Step 1: Define what the agent is allowed to do You write a system prompt or instruction document. This sets the agent's role, its tone and hard rules it must follow. This is a "guide" in Fowler's language.
Step 2: Give the agent tools You connect the tools the agent needs for example, a search tool, a database tool or a way to call other agents. You also decide which tools are turned on by default and which ones a user can turn on later.
Step 3: Add memory You decide what the agent should remember. Short term memory covers the current task. Long term memory lets the agent recall facts from earlier sessions, like user preferences or past decisions.
Step 4: Add permission and identity controls You decide what the agent can access, using whose identity and for how long. This matters a lot when the agent is calling other systems on a user's behalf.
Step 5: Add checks (sensors) You build validation steps that run after the agent produces output for example, checking that generated code compiles or that a JSON response matches a required format.
Step 6: Add limits You set budgets maximum tokens, maximum time, maximum number of steps so the agent cannot run forever or cost too much.
Step 7: Add observability You track what the agent did, which tools it called and what it cost. This is needed to debug problems and to improve the harness later. In a production system, observability usually covers five things:
- Tracing a step-by-step record of everything the agent did in a task, in order, so you can replay what happened.
- Tool execution logs which tools were called, with what input and what came back.
- Cost monitoring tokens used and money spent, per request and over time, so costs do not silently grow.
- Evaluation pipelines automated tests that regularly check the agent's output quality, not just once, but on an ongoing basis as the model or prompts change.
- Failure analysis a way to look back at failed or flagged tasks and find the actual root cause, so it can be fixed in the harness rather than patched with a one-off prompt tweak.
Without this, you cannot tell why an agent failed. You can only guess.
Step 8: Allow runtime changes Good harnesses let you change some of the above at run time, not just at deployment time. For example, letting a user pick a different model or turn on an extra tool while using the agent.
A more detailed picture of a production harness:
User
│
▼
Harness
├── Memory
├── Prompt / Guides
├── Tool Router
├── Validator
├── Guardrails
└── Logger / Observability
│
▼
LLM (reasoning)
│
▼
Response
Each box inside the harness is a separate, replaceable piece. You can swap the model, add a new tool or tighten a guardrail without touching the rest of the system. This is what makes a harness easier to improve over time than one giant prompt.
Now let's see this in a real example.
Real World Example 1: Building a Harness with AWS AgentCore
This example comes from a real engineering blog post about a prototype agent platform called Loom, built by engineer Heeki Park and shows both a custom harness and AWS's new managed harness feature for AgentCore.
The setup (deploy time)
At deployment, the agent is created using a configuration file, not by writing custom code for every agent. The config includes:
- The system prompt (persona, instructions and guidelines combined into one)
- The model to use
- A list of tools (MCP servers) the agent can call, with authentication details
- A list of other agents it can talk to
- Whether the agent has memory turned on and which memory store to use
This means a new agent can be created just by changing a JSON file no new code, no new deployment pipeline. This is a huge time saver and it also makes the agent safer, because you are not running untrusted, freshly-written code for every new agent.
The setup (run time)
Here is where it gets interesting. At deploy time, you set the defaults. But when a real user is using the agent, they might want to:
- Pick a different model than the default (for example, a faster or cheaper one)
- Turn on an extra tool they personally need
So the system also accepts a request at run time with fields like:
model_idoverride the default model, but only from an approved listconnector_idsa list of extra tools to attach just for this one request
This means the agent's defaults are set by an administrator, but each user still has some choice, within safe limits.
The tricky part: adding tools while the agent is running
When a user turns on a new tool that needs a personal API key (for example, a search tool), the system asks the user for their key exactly when they turn the tool on not before and not later when the tool is actually called.
Why does the timing matter? If you ask for the key too early, most users will ignore it, because they have not decided yet that they actually want the tool. If you wait until the tool is actually called, the user might have already walked away from their screen and the agent gets stuck waiting for a permission it cannot get. Asking right when the user turns the toggle on is the point where the user is most likely to say yes and be present to answer.
Moving to a managed harness
After building this custom system, the same engineer also tried AWS's new managed harness feature for Bedrock AgentCore. Instead of building and hosting all of the above by hand, you can create a harness with one command, passing in the system prompt, model, tools and memory settings:
aws bedrock-agentcore-control create-harness \
--harness-name "loom-harness-example" \
--system-prompt "persona, instructions, guidelines" \
--model "us.amazon.nova-2-lite-v1:0" \
--max-iterations 75 \
--max-tokens 16384 \
--tools '[{"type": "remote_mcp", "name": "exa", ...}]' \
--memory '{...}'
And at run time, you can send a request that overrides the model or adds a tool for just that one call, similar to the custom system, but without having to build and maintain any of the underlying plumbing yourself.
The real benefit reported was speed: the custom-built agent took about one minute to deploy, while the managed harness took about twenty seconds. That is the value of a managed harness most of the repeated, boring plumbing work is already done for you.
Real World Example 2: OpenAI's Codex Team
The second real example is the one that started the whole trend.
OpenAI's Codex team ran a five-month internal experiment. They built a real software product with daily internal users and external alpha testers where every single line of code was written by their AI agent, Codex, not by a human. This included application logic, tests, CI/CD configuration, documentation and internal tooling.
They estimated this was about ten times faster than writing the same product by hand. The team was clear that this was not because the model magically got smarter. It worked because of the harness they built around Codex, which included:
- Repository knowledge files (often called
AGENTS.md) that act like an onboarding guide for the agent, similar to onboarding a new human engineer - Executable rules and structural checks, so the agent's output could be automatically checked, not just trusted
- Observability, so engineers could see what the agent was doing and why
- A habit of asking, whenever the agent made a mistake, "what capability, context or structure is missing?" instead of just "let's write a better prompt"
This last point is probably the most useful takeaway from the whole harness engineering trend: when an AI agent fails at a task, the fix is usually not a cleverer prompt. The fix is usually a missing piece of the harness a tool it did not have, a check that should have caught the mistake or a rule it was never given.
When NOT to Use a Complex Harness
A full harness, with memory, tool routing, validators and observability, is not needed for every use case. Adding all of this to a simple task just adds cost and delay for no real benefit.
You probably do not need a heavy harness for:
- A simple chatbot that answers general questions with no real actions or side effects
- A basic FAQ bot that answers from a fixed, small set of documents
- A single API wrapper that takes one input, calls one API and returns the result
- A one-shot summarizer that reads one document and returns one summary, with no follow-up steps
For these cases, a good prompt and maybe some light context engineering is enough. Start simple. Add harness pieces only when you actually see a real problem for example, the agent keeps calling the wrong tool or its output format keeps breaking downstream systems. Build the harness to fix a real, observed failure, not because it sounds impressive.
Trade-offs: What a Harness Costs You
A harness makes an agent more reliable, but it is not free. Before adding one, weigh these trade-offs:
- Higher latency every extra step (memory lookup, validation, guardrail checks) adds time before the user gets a response.
- Increased operational cost more tool calls, more logging and more validation steps all add up in compute and token cost.
- Greater engineering complexity more moving parts means more code to maintain, more failure points and a steeper learning curve for new engineers on the team.
- More testing requirements a harness with tools, memory and validators needs its own test suite. You are no longer just testing a prompt; you are testing a system.
The right amount of harness is the smallest one that solves your actual reliability problem. More is not automatically better.
How to Talk About Harness Engineering in an Interview
If you are preparing for a system design or AI engineering interview in 2026, this topic can come up, especially if the role touches on agentic systems, LLM-based products or platform engineering. Here is how to fit it into your interview time well.
Suggested time allocation, if this comes up as a sub-topic in a 45–60 minute system design round:
- 1–2 minutes: Give the one-line definition "Agent = Model + Harness" and why it matters (models are converging, so the harness is the real differentiator).
- 2–3 minutes: List the core components tools, memory, permissions, validation, budgets, observability. Do not just name them; give one line on why each one matters.
- 3–5 minutes: Walk through one real example end to end, like the deploy-time vs run-time config pattern shown above. Interviewers like a concrete example much more than a list of buzzwords.
- 1–2 minutes: Mention trade-offs for example, build your own harness (more control, more engineering work) vs use a managed harness like AWS AgentCore's harness feature (faster to ship, less control).
Total: roughly 8–12 minutes if the interviewer wants a deeper discussion. If it is just a quick sub-question inside a bigger system design question, 2–3 minutes with a clear definition and one example is enough. Do not go longer than this unless the interviewer is clearly interested and keeps asking follow-ups in most interviews, this is a supporting topic, not the whole question.
If asked "how would you improve an AI agent that keeps failing," the strongest answer is the OpenAI lesson above: check what is missing in the harness (a tool, a rule, a check) rather than jumping straight to "let's improve the prompt."
Common Mistakes to Avoid When Building a Harness
- Treating prompt engineering as the whole solution. A good prompt cannot fix a missing tool or a missing permission check.
- No limits on cost or steps. Without a max token or max step budget, an agent can loop or run up a large bill.
- Asking for credentials at the wrong time. Asking too early gets ignored. Asking too late can block the agent while the user is not around.
- No validation step. If nothing checks the agent's output, small mistakes can silently become big problems.
- No logging. If you cannot see what tools the agent called and why, you cannot debug it when it goes wrong.
- Hardcoding everything at deploy time. Users often need to pick a different model or add a tool without waiting for a new deployment.
FAQs
1. Is harness engineering the same as prompt engineering?
No. Prompt engineering is about writing good instructions for a single response. Harness engineering is about the full system around the model tools, memory, checks and limits across an entire task.
2. Who created the term "harness engineering"?
It became widely known after OpenAI published an engineering post in February 2026, written by Ryan Lopopolo, about their Codex team's experiment. Mitchell Hashimoto turned the idea into the short formula "Agent = Model + Harness," and Martin Fowler's team at Thoughtworks added more structure with the "guides and sensors" framing.
3. Why does the harness matter more than the model now?
Because top AI models are performing closer to each other on benchmarks than before. When models are similar, the system built around the model becomes the main thing that decides whether an agent actually works well.
4. What are "guides" and "sensors" in a harness?
Guides are rules that shape the agent before it acts, like system prompts or instruction files. Sensors are checks that catch problems after the agent acts, like automated tests or output validators.
5. Do I need to build my own harness or can I use a managed one?
Both options exist. Building your own harness gives you full control and flexibility but takes real engineering time. Managed options, like AWS's harness feature for Bedrock AgentCore, are much faster to set up but give you less control over the internals.
6. Is harness engineering only for coding agents?
No. It applies to any AI agent customer support agents, data agents, research agents and more. The Codex example is about coding, but the same ideas (tools, memory, checks, limits) apply to any agent doing real work.
7. How much should I talk about this in an interview?
As a rough guide, 2–3 minutes if it is a small part of a bigger question and up to 8–12 minutes if the interviewer wants a full discussion with a real example. Always end with one concrete example rather than only definitions.
Conclusion
Harness engineering is not really a brand new idea. Engineers have always built systems around raw components to make them reliable this is just that same idea, applied to AI models. What changed in 2026 is that this finally got a name, a formula (Agent = Model + Harness) and real public examples showing how much it actually matters.
If you are working with AI agents in any way building them, reviewing them or just talking about them in interviews the biggest shift to make is this: stop asking "which model should I use?" and start asking "what does my harness look like?" That is the question that actually decides whether your agent works.
