Agent harnesses explained: tools, MCP, approval gates and traces
An agent is a model in a loop. A harness is everything around it that makes the loop safe and debuggable: typed tools, MCP integrations, approval gates, retries, tracing and evals.
An agent is a model in a loop. A harness is everything around that loop that makes it safe, observable and debuggable. Most "agent" demos are a prompt and a while loop. Most agent failures in production are harness failures — missing validation, no approval gate, no trace, no evals.
TL;DR
- Typed tools beat free-text parsing. Validate arguments before execution.
- MCP standardizes tool exposure and keeps surfaces discoverable.
- Approval gates scale autonomy to reversibility.
- Traces make failures replayable; without them you debug by vibes.
- Evals score tool choice and safety, not just final prose.
The model is the engine. The harness is the car.
The harness answers questions the model cannot:
- Which tools exist, and what are their schemas?
- How are arguments validated before anything runs?
- Which actions require a human "yes"?
- What happens on a timeout, a bad argument, a 500?
- Can I replay exactly what happened, step by step?
- Did the agent pick the right tool — measurably?
1. Typed tools
Every tool is a schema plus a handler. Arguments are validated; errors are returned as data, not crashes:
TOOL_SCHEMAS = [{
"type": "function",
"function": {
"name": "get_evals",
"description": "Return the eval approach and current summary.",
"parameters": {"type": "object", "properties": {}, "additionalProperties": False},
},
}]
def execute_tool(name, args):
fn = TOOL_FUNCS.get(name)
if not fn:
return {"error": f"unknown tool {name}"}
try:
return fn(**args)
except Exception as exc:
return {"error": f"{type(exc).__name__}: {exc}"}
The agent sees the error, can recover, and the loop stays alive.
2. MCP for integrations
The Model Context Protocol gives you a standard way to expose tools and data. Instead of hard-coding ten integrations per agent, you expose them once. That keeps the tool surface typed, discoverable, and reusable across agents and hosts.
3. Approval gates scale with reversibility
Rank actions by blast radius:
| Reversibility | Example | Policy |
|---|---|---|
| Read-only | search, fetch, summarize | auto |
| Reversible write | draft, tag, create ticket | auto + undo |
| Irreversible | pay, delete, email a customer | human approval |
Autonomy should grow only as evals prove reliability. Start conservative; widen the lane with data.
4. Bounded loops and retries
Cap tool steps, retry transient failures with backoff, and on exhaustion force a final, tool-free answer. An agent that can loop forever is an agent that eventually bills you forever.
5. Trace everything
For every run, record: messages, tool calls with arguments and results, token counts, cost, latency, and the decision. A trace should let you replay a failure deterministically. OpenTelemetry is the sane default; a run log is the minimum.
6. Evaluate behavior
Score the harness, not just the prose:
- Tool-call accuracy — right tool, right arguments.
- Unsafe action block rate — did the approval gate hold?
- Recovery rate — does it bounce back from a tool error?
- Steps to resolution — efficiency under a cap.
These are the numbers that justify shipping an agent to a paying customer.
The takeaway
Anyone can call a model in a loop. The engineering is the seatbelts: typed tools, MCP, approval gates, bounded retries, traces and evals. That is what turns a demo into something a team will let near production.
See how the eval side works in how I evaluate a RAG system, or talk to the agent on this site — it runs on exactly this kind of harness.
Frequently asked
What is an agent harness?
An agent harness is the layer around a model in a loop: the tools it can call, how tool calls are validated, approval gates for risky actions, retries and error handling, execution traces, and the evals that score behavior. The model is the engine; the harness is the car.
What is MCP and why does it matter for agents?
The Model Context Protocol (MCP) is a standard way to expose tools and data to models. It lets you reuse integrations across agents instead of hard-coding each one, and keeps tool surfaces typed and discoverable.
Why do agents need human-in-the-loop approval gates?
Because autonomy should scale with reversibility. Safe, read-only actions can run automatically; irreversible actions (sending money, deleting data, emailing a customer) should require explicit approval until evals prove the agent is reliable.
Keep reading
Hiring an AI Engineer who ships like this?