🚀 SaaS & AI — book a free roadmap call →
✦ AI & RAG apps that understand your business data →
⇄ Multi-marketplace order & inventory automation →
📅 Taking a limited number of new builds this quarter →
← All posts
AI / Agents

The agent harness: why the model is the smallest part of an AI agent

Here is a thought experiment. Take a working AI agent — one that books travel, triages tickets or fixes code — and quietly swap its language model for a different frontier model. Most of the time, very little changes. Now instead swap its harness: the loop, the tools, the context, the rules. Everything changes. That asymmetry is the most important and least understood fact about building agents, and this tutorial is about the part that actually decides whether yours works.

The 30-second version

  • Agent = Model + Harness. A model predicts text. Everything that makes it an agent — acting, remembering, recovering, stopping — lives in the harness.
  • A harness has five layers: tool orchestration, verification, context and memory, guardrails, and observability.
  • The central rule: the model never executes anything. It proposes a structured action; the harness validates, authorises, sandboxes, runs and logs it.
  • Most "the agent went rogue" stories are context failures or missing guardrails — not intelligence failures.
  • Published results show the same model jumping from mid-table to near the top of an agentic benchmark on harness changes alone.

1. The swap test

Run this experiment on any agent you have built. It settles the argument faster than any benchmark.

SWAP THE MODEL SWAP THE HARNESS HARNESS · unchanged MODEL · swapped → behaviour barely changes HARNESS · swapped MODEL · unchanged → everything changes
The asymmetry at the heart of agent engineering. If the interchangeable part is the one you spend all your time choosing, you are optimising the wrong thing.

The field compressed this into a formula that spread through 2026:

Agent = Model + Harness

The shorthand, popularised by Mitchell Hashimoto, that reframed the work

Three claims sit inside it. A model alone is not an agent. Frontier models are close enough in raw capability to be broadly interchangeable. And therefore the harness — not the model — is where your competitive advantage actually lives, because it is where your business rules, your verification and your institutional knowledge get encoded.

↑ back to top

2. What a harness actually is

In plain English

A language model does exactly one thing: given text, it predicts more text. That is not an agent. An agent is what you get when you wrap that model in software that lets it take actions, see results, remember what happened and keep going until a goal is met. The harness is all of that wrapping — every piece of code, configuration and execution logic that is not the model itself.

If the model is a brain in a jar, the harness is the body and the nervous system: the senses that bring information in, the hands that act on the world, the memory, and the reflexes that stop it doing something dangerous. Or, in the phrasing that has become standard, the harness is the deterministic runtime layer that wraps a non-deterministic model — validating, authorising, executing and logging every action the model proposes.

Where this sits among the buzzwords

Prompt engineering optimises one message. Context engineering optimises what the model sees each turn. Loop engineering optimises the cycle. Harness engineering is the whole system that runs all three — it is the superset, not a rival.

↑ back to top

3. The five layers of a harness

Strip down any production agent and you find the same five layers. When an agent misbehaves, the useful diagnostic question is not "is the model dumb?" but "which of these five failed?"

MODEL the smallest, most interchangeable part TOOL ORCHESTRATION VERIFICATION CONTEXT + MEMORY GUARDRAILS OBSERVABILITY what it may do, and how errors recover checks that fail fast, from outside what the model sees on each turn limits, sandbox, budgets, approvals telemetry and logs you can debug from
The five layers. Every agent failure you will ever debug belongs to one of them — which is exactly why naming them is useful.
The harness engineer's working rule

Any time the agent makes a mistake, you do not reword the prompt and hope. You engineer a change to the harness so that the agent cannot make that mistake again. Prompts persuade; harnesses prevent.

↑ back to top

4. The control plane: the model proposes, the harness disposes

This is the single most important rule in harness design, and it is worth stating bluntly: the model never executes anything itself. It only emits a structured request — "call search_orders with these arguments". Everything after that is your code.

MODEL proposes only TRUST BOUNDARY VALIDATEAUTHORISE EXECUTELOG against schemamay it, right now? in a sandboxappend-only the observation goes back as data — never as instructions
Every action crosses the boundary. The model's output is a request, not a command — exactly as an operating system sits between a program and the hardware.
# the naive version — the model's text becomes an action
action = model(context)
exec(action)                              # never do this

# the harness version — four gates before anything happens
proposal = model(context)                 # a structured request, nothing more

if not schema.validate(proposal):        # 1. is it well-formed?
    return teach(context, "bad arguments: …")
if not policy.allows(user, proposal):    # 2. is it permitted, for THIS caller?
    return deny(proposal)
if proposal.irreversible:                 # 3. does a human need to see it?
    return await_approval(proposal)

result = sandbox.run(proposal)            # 4. run it where it can't hurt you
ledger.append(proposal, result)           # and record what happened
context = observe(context, result)        # result re-enters as DATA

Notice the first branch. When validation fails, the harness does not crash and it does not silently repair the call — it returns a specific, actionable error into the context. A good error message is the cheapest teaching mechanism you have, and well-designed tool errors do more for reliability than most prompt tuning.

↑ back to top

5. Designing the tool interface

Tools are the agent's entire vocabulary of action. Most tool interfaces are bad in the same few ways:

DON'T

Expose your API surface

Forty thin CRUD endpoints mean forty ways to be wrong, and forty schemas paid for on every turn. Tools are a product surface for a non-human user, not a proxy for your database.

DO

Expose intentions

One refund_order(order_id, reason) that encapsulates the six calls and the business rules beats six primitives the agent must correctly sequence itself.

↑ back to top

6. Context: the art of what the model sees

A model has no memory between calls. Every turn, the harness rebuilds what the agent knows from scratch and packs it into a limited window. What goes in, what gets summarised and what gets dropped is a design decision on every single turn.

Two strategies dominate, and they are genuinely different:

STRATEGY A

Compaction

Summarise the history and let the same agent continue with a compressed context. Preserves continuity and momentum. Cheap. But it carries forward whatever confusion was already there.

STRATEGY B

Context reset

Clear the window entirely and start a fresh instance, handing over a complete written handoff document. Eliminates accumulated confusion — but only works if the handoff is genuinely complete.

A genuinely strange finding: context anxiety

Agents behave worse as their context window fills — rushing, cutting corners, one-shotting instead of working stepwise. One reported mitigation is simply capping the usable window well below the true limit, so the agent always believes it has room. Whatever the mechanism, the lesson is structural: treat remaining context as a resource the harness manages, not something the model should worry about.

A third technique is worth knowing: sub-agent isolation. Give a narrow task to a fresh sub-agent with its own clean context, and return only its conclusion to the parent. The parent never pays for — or gets confused by — the child's working transcript. This is also how you keep a long-running agent from drowning in detail it no longer needs.

If your agent's problem is that it cannot connect facts across documents rather than that it forgets them, that is a retrieval problem rather than a context problem — see graph engineering and what RAG actually is.

↑ back to top

7. Guardrails: designing the blast radius

An agent that can call tools is an agent that can cause damage, and the threat model is unusual. Untrusted text — a web page, an email, a ticket, a code comment — can reach the model and try to steer it into tool calls with your authority. This is prompt injection, it remains the top-ranked LLM security risk, and as of 2026 it is not solved.

The only strategy that works

Stop trying to prevent every injection. Assume one will land, and engineer so that a landed injection cannot do much. Containment, not prevention.

Containment is built from four ordinary security ideas:

  1. Least privilege, scoped to the task The agent holds only the permissions this task needs, and loses them when it ends. A support agent answering a billing question has no reason to hold delete rights on anything.
  2. Tool output is data, never instructions The single most important framing. Text returned from a tool must never be treated as a command, no matter how imperative it sounds.
  3. Sandboxed execution Run anything the agent triggers where it cannot reach your real systems. The isolation ladder runs roughly: microVMs (strongest) → user-space kernels → hardened containers → WebAssembly for plugin-level isolation. Pick by blast radius, not by fashion.
  4. Human gates on the irreversible Sending money, emailing customers, deleting data, deploying. Put approval exactly where a mistake cannot be undone — and nowhere else, or people will click through it without reading.
A useful question for any tool

"If a stranger on the internet could call this tool once, with arguments of their choosing, what is the worst outcome?" Because with prompt injection in play, that is roughly the situation you are in.

↑ back to top

8. Verification inside the harness

Agents have a documented and inconvenient habit: victory declaration bias — marking work complete without checking it. No amount of instructing the model to "be sure" fixes this reliably, because the model's confidence and the work's correctness are only loosely related.

The harness fix is structural. Verification is a layer, not a request:

All three must come from outside the model. An agent grading its own homework is not verification; it is a second opinion from the same source. This is the same discipline covered in depth in loop engineering — and it is where the loop layer and the harness layer meet.

One-shotting overreach

The third documented behaviour, alongside victory declaration and context anxiety: agents attempt the entire problem at once, producing a large undocumented tangle instead of reviewable steps. The harness answer is to make the small step the only available move — checkpoint after each unit, and require the verification to pass before the next one starts.

↑ back to top

9. Observability: you cannot fix what you cannot see

When an agent does something baffling at 3am, the only thing that will save you is the record. A workable minimum, one row per turn, append-only:

FieldWhy it earns its place
session_id, turnTies every row to one run, in order. Everything else is useless without it.
proposalWhat the model asked for — before validation changed or rejected anything.
decisionAllowed, denied, or sent for approval — and which rule decided.
result / errorWhat actually happened, including the error text the agent then saw.
tokens, durationWhere cost and latency actually go. Almost never where you assume.
outcomePass, fail, or which exit condition fired. This is what you aggregate over.

Log the proposal separately from the result. The gap between what the model wanted and what the harness permitted is the most informative signal you will collect.

↑ back to top

10. The evidence — and the hype

The claim "the harness matters more than the model" is testable, and the strongest evidence comes from cases where the model was held constant:

Reported resultWhat changedWhy it matters
30th → 5th place on an agentic terminal benchmarkHarness only — the underlying model was not changedThe cleanest available demonstration of the asymmetry
Open models matching or beating frontier routesOptimised harness, validated across 211 real engineering tasksHarness quality can substitute for model spend
~1M lines of code, none hand-writtenThree engineers, five months, models unchanged throughoutThroughput is a harness property, not a model property
38% better accuracy on generated SQLA governed data-context layer feeding the harnessContext quality is measurable, not vibes

Figures as reported by the teams and vendors involved, 2025–2026. Directionally consistent across independent sources; treat exact numbers as indicative.

Now the numbers you should push back on

You will also see "88% of agent projects never reach production" and "95% of enterprise AI pilots delivered zero measurable ROI" quoted constantly. Both come from real studies, but both are widely stripped of their definitions and sampling — and "pilot did not show ROI" is not the same claim as "the technology does not work". Cite them if you like, but do not build a strategy on a statistic whose denominator you have never seen.

↑ back to top

11. How to measure your harness

Model benchmarks tell you almost nothing about your agent. Measure outcomes instead, starting with metrics that need no new infrastructure:

  1. Stage 1 — what you can measure today Cost per completed unit of work. Time from start to accepted. Review effort relative to the size of the change. Compute spend per person. All four come from systems you already have.
  2. Stage 2 — attribute the work Link each agent session to the artefact it produced, so you can separate "the agent did this" from "a human rescued it".
  3. Stage 3 — categorise the failures Tag every failure to one of the five layers. The distribution tells you exactly where the next round of engineering should go, and it is almost never where the team assumed.
The uncomfortable metric

Track how often a human had to intervene. An agent with a 95% success rate that a person must inspect every single time has not saved anybody any time — it has just moved the work from doing to reviewing.

Build a minimal harness this weekend

  1. Start with one tool and a schema. Not five. Validate the model's arguments and return a teaching error when they are wrong.
  2. Add the permission check as a separate function from the tool itself. Keeping "can it?" apart from "do it" is what makes both testable.
  3. Run the tool in a subprocess with a timeout and no credentials it does not need. That is a real sandbox, at the smallest useful scale.
  4. Append one row per turn to a file. Proposal, decision, result, tokens. You will use this more than anything else you build.
  5. Add the terminal verification last — the external check that decides whether the run succeeded. Then try to make the agent lie to you about being finished, and watch the harness catch it.
↑ back to top

12. Glossary

Harness
Everything around the model that makes it an agent: loop, tools, context, controls, logging.
Agent loop
The plan–act–observe cycle the harness runs, consulting the model once per turn.
Control plane
The validate → authorise → execute → log path every proposed action must cross.
Trust boundary
The line the model's output crosses to become an action. Nothing passes it unvalidated.
Tool schema
The typed contract for a tool call, enforced by the harness rather than requested of the model.
Compaction
Summarising history so the same agent continues with a smaller context.
Context reset
Starting a fresh agent with a written handoff instead of a compressed transcript.
Sub-agent isolation
Delegating a narrow task to a fresh context and returning only the conclusion.
Prompt injection
Untrusted text steering the agent into tool calls with your authority. Contained, not prevented.
Least privilege
Holding only the permissions the current task needs, and dropping them afterwards.
Victory declaration
An agent claiming completion without verification. Fixed structurally, not by asking nicely.
Context anxiety
Degraded, rushed behaviour as the context window fills.

Frequently asked questions

What is an agent harness, in one paragraph?
Everything around the model that turns it from a text generator into an agent: the loop that runs it, the tools it may call, the context assembled for each turn, the permissions and sandbox that constrain it, and the logging that lets you debug it afterwards. The model supplies reasoning; the harness supplies reliability. The shorthand the field settled on is Agent = Model + Harness.
Should I build my own harness or use an existing one?
Start with an existing one. Mature agent SDKs already give you a loop, tool calling, a permission model and session handling — rebuilding that is weeks of work with no differentiation. What you should build yourself is the layer above: your business rules, your verification, your permission policy and your audit trail. That is where the value is, and it is the part no SDK can supply.
Does a better model let me skip harness work?
It lets you delete some of it — and that is by design. A well-built harness contains scaffolding that exists to compensate for current model weaknesses, and some of it should become redundant with each model upgrade. Revisit those workarounds when you upgrade. But the parts that encode your permissions, your business rules and your audit requirements are not model weaknesses, and no model will ever make them unnecessary.
How many tools should an agent have?
Fewer than you think. Every definition costs tokens on every turn and adds a way to choose wrong. Prefer a handful of intention-shaped tools that encapsulate your business rules over dozens of thin API wrappers the agent must correctly sequence. If a task needs many tools, that is usually a signal to split it across sub-agents, each with a small focused set.
Where should the human approval gate go?
Exactly at the irreversible actions — money movement, outbound communication, deletion, deployment — and nowhere else. Gates placed everywhere get click-through approval within a week, which is worse than no gate because it manufactures a false audit trail. One gate people actually read beats five they dismiss.
Is multi-agent better than a single well-built harness?
Sometimes, and it is never free. One reported planner–generator–evaluator setup moved output quality from broken to fully functional, but cost roughly 20× more than the single-agent version. That can be an excellent trade for high-value work and a terrible one for routine tasks. Get one agent's harness right first; multi-agent multiplies whatever discipline you already have, including the absence of it.

Where this leaves you

Model choice has quietly stopped being the interesting decision. Frontier models are close enough in raw capability that swapping one for another rarely determines whether an agent works. What determines it is the harness: the loop, the tools, the context discipline, the guardrails and the record of what happened. The model is the smallest, most interchangeable part — and the engineering that makes an agent dependable is everything around it.

That layer is exactly where we build. If you are moving an agent from an impressive demo to something you can put in front of customers, the harness is where that work happens — and it is work, not a prompt.

Talk to us about your AI project

← Loop engineering: stop prompting your AI, start designing the loopFrom prototype to production: shipping a reliable AI feature →