Harness Engineering
The model is the engine. The harness is the rest of the car: the steering, the brakes, the dashboard and the seatbelts. Most of the teams that win in 2027 won't have a better model than you. They'll have a better harness.
Definition: Harness engineering is the work of designing the software around an AI model (the loop, context, tools, permissions, checks, limits and logs) that turns the model into an agent that completes real tasks safely and reliably.
1 The big idea
An agent is a model inside a harness
A language model on its own does one thing: you give it text, it gives you text back. It cannot read your database, send an email, or check whether it was right. Between calls it remembers nothing unless something hands the history back to it.
To turn that into an agent, something that gets real work done, you wrap it in software. That software picks what the model gets to see and offers it tools. It runs the tools the model chooses, checks the results, keeps it inside the rules and stops it when the job is done or going wrong. That wrapping is the harness.
You already use harnesses. A coding assistant that edits files and runs tests is a harness around a model. So is a support bot that can look up your order. Agent frameworks and SDKs give you building blocks for a harness. Deciding how those blocks fit your business is still your job.
Why the word "harness". A horse is strong, but on its own it goes wherever it likes. A harness turns that strength into pulling a cart in a straight line. The model is the horse. You don't make the horse smarter. You build a better harness.
2 Interactive map
The nine parts of a harness
Click any part to see what it does, a real example, and what goes wrong without it. Then switch to Model only to see what is left when the harness is gone.
The loop
Runs the model again and again: think, act, look at the result, think again, until the job is done or a limit is hit.
Read all 9 parts as text
- The loop
- Runs the model again and again: think, act, look at the result, think again, until the job is done or a limit is hit. Example: Look up the booking, see two charges, refund one, check the refund went through, reply to the guest. That is four trips round the loop. Without it: The model answers once and stops. It can't react to what it finds, so it guesses.
- Context
- Chooses exactly what the model gets to see before each decision: the right documents, the right history, the right rules, and nothing else. Example: For a refund question: this guest's booking, the current refund policy and the last three messages. Not their 40 old tickets. Without it: The model answers from stale or irrelevant facts, gets distracted, and costs more per question.
- Tools
- The actions the agent can request, each with a clear name, strict inputs and a helpful error when something is wrong. Example: lookup_payments(booking_id) and refund(charge_id, amount). Each does one thing and rejects bad input. Without it: Vague tools get used for the wrong job, or called with made-up inputs that break real systems.
- Memory
- Decides what the agent remembers between steps, between conversations and between days, and what it deliberately forgets. Example: Remembering this guest prefers WhatsApp and had a problem last month. Forgetting their card number. Without it: The agent asks the same questions every time, or remembers things it should never keep.
- Sub-agents
- Splits a big job across several focused agents, and coordinates who does what and in which order. Example: One agent reads the complaint, one checks payments, one drafts the reply. A coordinator puts it together. Without it: One agent tries to do everything with one giant prompt and gets worse at all of it.
- Permissions
- Rules written in code that decide which actions are allowed, limited or blocked, whatever the model says. Example: Reading payments: always allowed. Refunds: allowed up to AED 1,000 with a matching duplicate charge. Above that: needs a person. Without it: A clever message from a user, or a web page the agent reads, can talk the model into anything.
- Checks & evals
- Checks the real result after each action, and tests the whole agent against known cases before every change goes live. Example: After the refund, ask the payment system again: is it really there? Before a model upgrade, replay 200 past cases. Without it: The agent says "done" when it isn't, and quality quietly drops after every change.
- Human approval
- Knows when to pause and ask a person, and gives that person exactly what they need to decide in seconds. Example: A AED 4,200 refund request is paused. A support lead sees the photos and the guest's history, and approves AED 1,500. Without it: Either the agent acts on decisions it shouldn't, or people approve everything without reading it.
- Tracing
- Records every step: what the model saw, what it proposed, what was allowed, what happened, how long it took and what it cost. Example: A guest complains a week later. You open trace #T-55120 and see every step in order, in under a minute. Without it: When something goes wrong, nobody can say what happened or why, so nobody can fix it.
Each of these nine parts is its own topic in this series. Harness engineering is the skill of making them work together.
3 Step-by-step simulator
Watch one task go through the harness
A guest-support agent at a holiday-rental company. The model is the same in all four scenarios. Only what happens around it changes. Notice how few steps belong to the model.
- Requestuser
- Build contextharness
- Decide next stepmodel
- Permission checkharness
- Run toolharness
- Verifyharness
- Loop or stopharness
Normal day
A guest says they were charged twice. Everything works as it should. Watch how much of the work is the harness.
Read the walkthrough as text
Normal day
A guest says they were charged twice. Everything works as it should. Watch how much of the work is the harness.
- A request comes in. The guest writes in on WhatsApp. The harness receives it first: it knows who the guest is, which channel they used, and which agent should handle it.
- The harness builds the context. The model only knows what it is shown. The harness picks what goes in: this booking, the current refund policy, the last three messages. It leaves out 40 old tickets that would only add noise and cost. Why it matters: Many "the model is dumb" bugs are really "the model was shown the wrong things" bugs.
- The model decides the next step. This is the model's turn. It reads the context and proposes one action: look up the payments on booking #4821. It proposes. It does not act. Why it matters: A model can only produce text. Every real action goes through the harness.
- Permission check. The harness checks the proposed action against rules written in code. Reading payments is read-only and low risk, so it is allowed automatically.
- The harness runs the tool. The harness, not the model, calls the payment system, with its own credentials and a 10-second timeout. It passes the result back to the model as plain data.
- Back to the model, with new facts. The loop goes round again. Now the model can see two identical charges a minute apart. It proposes refunding the second one.
- Permission check, stricter this time. Refunds move money, so the rule is tighter: refunds up to AED 1,000 are allowed only when there is a matching duplicate charge. Both are true here. Why it matters: The limit lives in code. No clever message from the guest can talk the model past it.
- Run the refund. The harness issues the refund and saves a way to reverse it, so a person could undo it within 24 hours if something was wrong.
- Verify the result. The model thinks it's done. The harness checks for itself by asking the payment system again: the duplicate charge now has a refund pending. The check passes. Why it matters: Never trust "done". A harness checks the world, not the model's claim.
- Stop, reply, save the trace. The job is done, so the loop stops. The model writes the reply. The harness sends it and saves the whole run: context, proposals, checks and results.
A tool breaks
Same request, but the payment system is slow today. Without a harness, the model would either hang or make up an answer.
- A request comes in. Same guest, same double charge.
- Build the context. Booking, refund policy, recent messages. Same as before.
- The model asks for the payments. The model proposes the same first step: look up the payments.
- Allowed. Read-only, so it's allowed.
- The tool times out. The payment system doesn't answer within 10 seconds. The harness catches the error instead of crashing or waiting forever. Why it matters: Without this, a bare model might say "I've checked and there's only one charge", an answer it made up.
- Retry, and tell the model what happened. The harness waits two seconds and tries again. It also notes the error in plain words in the context, so if the retry fails too, the model can decide what to do next instead of guessing.
- The model carries on. With the real data, the model proposes refunding the duplicate charge.
- Allowed within the limit. Under AED 1,000 with a matching duplicate. Allowed.
- Refund issued. The refund goes through.
- Verify. Because the payment system was flaky, verification matters even more today. The harness confirms the refund really exists.
- Done, and the slowness is recorded. The guest gets their refund. The trace records the timeout, so the team can see how often the payment system is slow.
Risky request
An angry guest asks for a full refund. The model might well agree. The harness makes sure a person decides.
- A big request comes in. The guest asks for the full AED 4,200 back.
- Build the context. Booking, cleaning report from check-in, refund policy, the photos and the guest's history.
- The model wants to be helpful. Models are trained to be helpful. Faced with an upset guest and photos, it proposes the full refund.
- Blocked: above the limit. AED 4,200 is far above the AED 1,000 limit for automatic refunds. The harness doesn't refuse and doesn't guess. It pauses and asks a person. Why it matters: The model was not wrong to suggest it. It just isn't the model's decision to make.
- A person decides, in seconds. A support lead sees one screen: the request, the photos, the check-in report and the model's suggestion. They approve a partial refund of AED 1,500. Why it matters: Good human-in-the-loop design means the person gets everything they need on one screen, so approval is a real decision, not a rubber stamp.
- Run the approved amount. The harness issues exactly what the human approved, not what the model first proposed.
- Verify. The refund is confirmed in the payment system.
- Reply and record who decided. The model drafts a reply explaining the partial refund. The trace shows the model's suggestion, the block, and who approved what.
Stuck in a loop
A simple question, but the confirmation email doesn't exist. The model keeps trying the same thing. Without stop rules, this runs until someone notices the bill.
- A simple question. A guest can't find their confirmation email.
- Build the context. Guest profile and recent bookings. There's a step budget for this task: 8 steps.
- The model searches for the email. Reasonable first move: search sent emails for this guest.
- Nothing found. The search returns nothing. The email was never sent because of a bug elsewhere.
- The model tries again. And again.. The model assumes the search failed and repeats it with tiny changes. This is a very common agent failure: confidently retrying a dead end.
- Loop detector steps in. The harness notices the same tool called three times with the same result. Continuing is pointless, so it stops the loop before it uses the rest of the budget. Why it matters: Without stop rules, agents can run for hours. A loop detector and a step budget are a few lines of code.
- Hand over to a person, with a summary. The harness tells the guest a person will follow up, and gives the support team a short summary: what was asked, what was tried, what was found. No one has to read the whole log.
The point: the model made a handful of decisions. The harness made every one of them safe, checked and recorded. When an agent fails in production, look first at what was missing around the model. Very often the fix lives there.
4 Who does what
What the model does, and what the harness does
The model
- Understands the request
- Suggests the next step
- Picks which tool to call, with which inputs
- Writes the reply
The harness
- Decides what the model sees
- Decides which tools exist at all
- Checks every action against the rules
- Runs the action, catches errors, retries
- Checks that the work was really done
- Stops on time and on budget
- Asks a human when it should
- Records everything
Compare the lengths of those lists. That is why swapping the model rarely fixes a broken agent on its own, and why fixing the harness so often does.
5 Build your own harness
Turn on harness parts. Watch the failures disappear.
These are the kinds of agent failure that end up in incident reports. Tick the parts your harness has, and see which failures you are protected from. Many teams start with just a model and a prompt: zero ticks.
- Refunds AED 40,000 because a guest asked nicelyNothing in code stops it.
- Says "done", but the change never happenedIt trusts the model's word.
- Loops all night and burns the month's AI budgetNothing tells it to stop.
- Answers from a policy that changed last monthIt was shown stale facts.
- Calls an API with a made-up field and breaks itThe tool accepts anything.
- Nobody can explain what it did last TuesdayNo record exists.
- Emails 2,000 customers by mistakeOne bad call reaches everyone.
- A web page it reads tells it to ignore its rulesThe model is the only defence.
- Quality drops after a model upgrade, unnoticed for weeksNobody is measuring.
Read which part prevents which failure
- Refunds AED 40,000 because a guest asked nicely: prevented by Permission checks or Human approval.
- Says "done", but the change never happened: prevented by Verification.
- Loops all night and burns the month's AI budget: prevented by Budgets & stop rules.
- Answers from a policy that changed last month: prevented by Context rules.
- Calls an API with a made-up field and breaks it: prevented by Well-designed tools.
- Nobody can explain what it did last Tuesday: prevented by Tracing.
- Emails 2,000 customers by mistake: prevented by Permission checks or Human approval or Budgets & stop rules.
- A web page it reads tells it to ignore its rules: prevented by Permission checks.
- Quality drops after a model upgrade, unnoticed for weeks: prevented by Verification or Tracing.
No single part covers everything, and "a better prompt" is not on the list. Each failure is stopped by software around the model. (Prompt injection, the web-page case, is never fully solved by any one part. Permission checks limit the damage when the model is fooled.)
6 Optional: what it looks like in code
A whole harness in 20 lines
You don't need to read code to follow this series. If you do, here is a harness stripped to the bone. The highlighted line is the only place the model appears. Everything else is harness.
def run(task, budget=Budget(steps=12, usd=0.50)):
context = build_context(task) # what the model may see
while budget.left():
action = model.next_action(context) # the ONLY model step
if action.type == "finish":
if verify(task): # check the world, not the claim
return done(action.reply)
context.add("Check failed: " + why())
continue
if not allowed(action): # rules in code, not in the prompt
if needs_human(action):
return ask_human(task, action) # pause, don't guess
context.add("Blocked: " + action.name + " is not allowed")
continue
result = run_tool(action, timeout=10, retries=2)
context.add(result) # feed results AND errors back
trace.log(context, action, result) # so you can replay it later
if loop_detected(trace):
return escalate(task, trace)
return escalate(task, trace) # out of budget: hand to a human
build_context is Context Engineering, allowed is Guardrails & Permissions, verify is Evals, trace is Observability.7 The rules I build by
Eight principles of a good harness
Put rules in code, not in the prompt
A prompt is a request. Code is a wall. "Never refund more than AED 1,000" belongs in a check the model cannot argue with.
Show the model less, but the right things
More context is not better context. Every extra page is something the model can get distracted by, and something you pay for.
Make tools hard to misuse
Clear names, strict inputs, helpful errors. If a new hire would be confused by your tool, so will the model.
Check the world, not the claim
When the model says "done", look for yourself: run the test, query the database, read the sent email.
Feed errors back as information
"Timeout after 10s, try again or use the backup" lets the model recover. A crash or silence does not.
Budget everything
Steps, time, tokens, money and the number of people affected. Every agent needs a point where it must stop and ask.
Record everything
What the model saw, what it proposed, what was allowed, what happened. If you can't replay it, you can't fix it.
When it fails, fix the harness
Ask "what was missing around the model?" before "how do I reword the prompt?". Add the check, tool or rule so that kind of failure cannot happen again.
8 Common mistakes
Things teams say right before an incident
"We'll fix it with a better prompt."
Prompts help the model choose well. They don't stop it choosing badly. Use the prompt to guide and the harness to enforce. If breaking a rule would cost you money or trust, that rule must live in code.
"Let's just switch to the newest model."
A newer model in the same weak harness tends to make the same kinds of mistake, sometimes more confidently. Upgrade when your harness is solid and your evals can show the new model is better for your tasks.
"Give it every tool. It's smart enough to choose."
Each extra tool is another way to be wrong, and more tool descriptions crowd the context. Give the agent the fewest tools it needs for this job, and make the dangerous ones need approval.
"It worked perfectly in the demo."
Demos are the happy path. Production is timeouts, odd requests, stale data and people trying to trick it. Run the "tool breaks" and "risky request" scenarios above against your own agent before launch.
"The model will tell us if something goes wrong."
Models are often unaware when they're wrong, and they can report success very convincingly. Detection is the harness's job: verification, limits and traces.
9 Check yourself
Four quick questions
10 Do this today
Six steps to a better harness this week
Pick one agent you're building or buying. Work down this list. Your ticks are saved in this browser.
11 Questions people ask
Harness engineering FAQ
What is an agent harness?
An agent harness is the software around an AI model that turns it into an agent. It runs the loop, builds the context, offers and runs tools, checks permissions, verifies results, enforces limits and records every step. The model suggests; the harness acts.
Is harness engineering the same as prompt engineering?
No. Prompt engineering shapes what you say to the model. Harness engineering shapes everything around the model: what it sees, what it can do, what is checked and when it stops. The prompt is one small input the harness builds.
How is harness engineering different from context engineering?
Context engineering is one part of harness engineering: deciding what goes into the model's context window for each step. Harness engineering also covers tools, permissions, verification, budgets, human approval and tracing.
What are examples of agent harnesses?
Coding assistants that read files, edit code and run tests are harnesses around a model. So are support agents that can look up orders and issue refunds within limits. Agent frameworks and SDKs give you parts to build a harness; the rules, tools and checks for your business are still yours to design.
Do I need a better model or a better harness?
Usually a better harness first. If your agent fails because it saw the wrong facts, had a confusing tool, was never checked or never stopped, a newer model will not fix that. Upgrade the model once your harness is solid and your evals can measure the difference.
Do I need to be an engineer to understand this?
No. Founders, product managers and reviewers can use the nine parts on this page as a checklist: for any agent, ask who decides what it sees, what it is allowed to do, how its work is checked, when it stops and where the record is.
12 Glossary
Words you'll hear
- Model
- The AI that reads text and writes text. It suggests; it doesn't act.
- Harness
- All the software around the model that turns its suggestions into safe, checked actions.
- Agent loop
- The cycle of think, act, observe, repeat, until the job is done or a limit is hit.
- Tool call
- The model asking the harness to do something: look up data, send a message, run code.
- Context
- Everything the model is shown before it decides. It knows nothing else about your situation.
- Guardrail
- A rule enforced in code that blocks or limits an action, whatever the model says.
- Verification
- The harness checking the real result instead of trusting the model's report.
- Escalation
- Handing the task to a human, with a summary, when the agent shouldn't continue.
- Trace
- A step-by-step record of a run, so you can replay and debug it.
- Sandbox
- A walled-off place to run actions so mistakes can't reach real systems.
For teams
Want your team to build harnesses like this?
I run AI agents in production at estaie that set prices, find customers and look after guests. This page comes from building and running them.
AI Skills 2027, for your engineering team
A hands-on workshop where your engineers build a harness around a real use case from your business.
- One skill in depth, or all ten as a bootcamp
- On site in the UAE or remote
- Your team leaves with working code, not slides
Have your agent's harness reviewed
I check your agent against the failure types on this page and give you a written list of what to fix first, in order of risk.
- For teams about to launch, or just after an incident
- Plain-English findings your board can read
The series
All ten AI Skills for 2027
- Harness Engineering
- Loop Engineering
- Context Engineering
- Tool Design
- Memory Architecture
- Orchestration Patterns
- Guardrails & Permissions
- Evals for Agents
- Human-in-the-loop Design
- Observability & Tracing
Published 1 December 2026 · Updated 2 December 2026. Written by Nimit Solanki from building production agents at estaie.
Get the free Playbook by email
Seven short lessons on taking an agent from prototype to production. One a day, free. You may also hear about my course and consulting. Opt out any time.