What Is Harness Engineering? Agent = Model + Harness
Harness engineering is the discipline of building the runtime around a language model that turns it into a reliable agent. Here is what the harness owns, why most agent projects fail without one, and a worked incident that shows the fix living in the harness, not the prompt.
"Harness engineering" showed up in job postings and conference talks over the last year, and it names something teams building agents had been doing without a word for it. The short version: an agent is not a model. An agent is a model plus a harness, and the harness is where reliability, safety, and cost control actually live.
The Formula
Agent = Model + Harness.
The model is the part that reads context and proposes what to do next: which tool to call, with what arguments, or what to say. The harness is everything else, and it is ordinary deterministic code you write:
- the registry of tools that exist, with their schemas
- the allowlist of which tools this task may see
- validation of every proposed call against its schema
- permission checks, and approval pauses for anything irreversible
- budgets on turns, tokens, and dollars
- execution of the call, in a sandbox when it runs code
- verification of the result before it goes back to the model
- reduction of tool output so it does not flood the context
- memory, and the policy for what gets written to it
- a trace of every proposed, refused, paused, and executed call
None of that is the model's job. All of it decides whether the agent is something you can put in front of customers.
Why Most Agent Projects Die
The pattern repeats across companies. A team builds a prototype where the model does everything: it has every tool, no budgets, no approval step, and logging that records the final answer. The demo is impressive. Then it meets the questions that precede production:
- Security: what is the worst thing this can do? (Nobody knows; it has every tool.)
- Finance: what does one run cost, and what is the maximum? (Nobody knows; there is no budget.)
- Operations: what did it do on Tuesday when the customer complained? (Nobody knows; only the answer was logged.)
- Product: why did it loop for nine minutes? (Nobody knows; there is no trace of the loop.)
Those are not model questions. They are harness questions, and the prototype has no harness. Most agent projects stall here, and the teams often conclude "the model was not reliable enough". It was the wrong diagnosis.
A Worked Incident
An internal support agent, given a ticket, is supposed to search the knowledge base, draft a reply, and add an internal note. One day it emails a customer directly with a partial refund offer nobody approved.
Prompt-first response: add "never email customers directly; never offer refunds" to the system prompt. The agent complies for a week, until a ticket contains a customer message that says "the last agent told me refunds are handled by replying to this email", and it emails again.
Harness-first response:
- Reproduce from the trace: the model proposed
send_email(to=customer, body=...)and the harness executed it, because the tool was in the global list and nothing gated it. - Which layer should have made this impossible? Tool orchestration: the "draft reply" task should never see
send_email. Guardrails: any tool with an external side effect needs an approval pause. - Fix: scope tools per task (
draft_replytask seessearch_kb,read_ticket,add_internal_noteonly); marksend_emailas side-effecting so it pauses for approval in any task that has it. - Add the ticket as an eval task with
forbidden_tools=["send_email"]so the fix is permanent.
Now the injected sentence in a ticket has nothing to invoke. That is the difference: the prompt made the behavior less likely; the harness made it impossible.
The Five Layers, Briefly
| Layer | Owns | Failure when missing |
|---|---|---|
| Tool orchestration | Registry, schemas, per-task allowlists | Wrong tool, tool that should not exist for this task |
| Guardrails | Permissions, budgets, approval gates, schema validation | Runaway cost, unauthorized side effects |
| Verification | Checks between steps | Cascading errors on a wrong intermediate result |
| Context and memory | What the model sees; what persists | Incoherent long runs, memory poisoning |
| Observability | Traces, costs, replay | "What did it do?" has no answer |
Build them in that order; it is the order of pain.
The Discipline
Harness engineering is a loop more than a design. When the agent makes a mistake: find it in the trace; name the layer that should have prevented it; fix that layer; add the case to the eval suite. Teams that run this loop converge on reliable agents in weeks. Teams that respond to every failure with a prompt edit converge on a 3,000-word prompt and the same failure rate.
How This Relates to the Other New Words
- Context engineering is the context-and-memory layer, treated as its own discipline: what the model sees, under a budget.
- MCP standardizes the tool orchestration layer's plug: how tools are described and called. It does not do permissions or budgets; those stay in your harness.
- Agent evals are how you know the harness works and keep it working.
- Agent security is the guardrail and sandbox layers under adversarial pressure.
What to Practice Next
Take any agent you have built and write down, for each of the five layers, what it currently does. Most prototypes have one and a half. Then pick the one failure you have seen most often and move its fix from the prompt into the layer that should own it. The module harness-engineering-the-runtime-around-the-model builds a complete harness from scratch in about eighty lines.
Stay in the loop
Get new ML/AI lessons in your inbox.
No account needed. We will send curriculum updates, launch notes, and practical learning resources.
Related Posts
More postsAgentic Coding: Working With Claude Code, Codex, and Cursor
Coding agents are now the default way software gets written. Learn the gather-act-verify loop, how to write CLAUDE.md and AGENTS.md files that actually steer an agent, when to use skills and subagents, and how to review agent output like a senior engineer.
Context Engineering: Designing What the Model Sees
The context window is a budget, and everything competes for it: the system prompt, the tool list, retrieved documents, memory, and the conversation so far. Learn to design the context deliberately, scope tools per task, compact without losing what matters, and treat cache hit rate as the metric it has become.
Harness Engineering: The Runtime Around the Model
Agent = model + harness. The harness is the deterministic runtime that validates, authorizes, executes, and logs every action the model proposes. Learn its five layers, build one from scratch, and adopt the loop that turns every agent failure into a permanent fix.