Skip to main content
AgentsUse

The Harness pillar

Good tools fail in bad harnesses.

A harness is the runtime layer between a model and its tools. It selects the call, checks the arguments, enforces permission, handles failure, decides how much of the result belongs in context, and records what happened. This pillar collects the patterns for building that layer, each one tied to the official documentation or production writing behind it.

9 patterns · 3 new guides · 5 profiles with harness notes · sources checked 2026-10-08

The harness loopThe model proposes a tool call. The harness validates arguments, checks permissions, and budgets context before the tool acts. The shaped result returns as context. A human checkpoint can approve, edit, or reject consequential calls.Modelproposes the next actionHARNESSthe control layerValidate argumentsPermission gateContext budgetRetry + timeoutAudit logToolsAPIs, MCP servers, codeContextwhat the model sees nextshaped result, within budgetHuman checkpointapprove · edit · reject

The loop every agent run travels: the model proposes, the harness checks the proposal (arguments, permissions, budget), the tool acts, and the result comes back trimmed, logged, and grounded before it becomes context for the next step. Everything on this page hangs off that loop.

Between intent and execution

Six jobs, one layer

Different frameworks name the pieces differently: tool design, context engineering, workflow patterns, middleware. AgentsUse uses “harness” for the whole layer a builder owns between model intent and tool execution. That layer has six jobs.

Constrain

Check every call against the schema before anything executes.

Recover

Retry what heals, stop on what cannot, resume where it broke.

Budget

Cap, shape, and clear tool results before they crowd out the task.

Gate

Let safe calls run. Hold the irreversible ones for a decision.

Record

Log every call and ground every claim in a result that arrived.

Coordinate

Run independent calls in parallel and dependent calls in order, with gates.

Why the layer matters

What the harness buys you

The value of a harness is easier to judge by failure than by feature list. Each outcome below names the failure it prevents, the patterns that do the work, and the AgentsUse direction that follows from it. The claims are mechanisms, not benchmarks.

Performance

3patterns

Prevents: Wasted steps: malformed calls failing late, bloated results, dependent calls guessed in parallel.

Calls are checked before they run, results are sized for the context they re-enter, and independent work runs in parallel where the dependency graph allows it. Argument validation, Context budgeting, Sequencing.

RoadmapThe catalog compatibility record is the starting point: put a documented tool in front of the model before tuning the loop around it.

Security

3patterns

Prevents: An action nobody approved executes, and nobody can reconstruct it later.

Only allowlisted tools run. Destructive calls wait for an approval, edit, or reject decision, and each call leaves an audit record. Permission gating, Tool-call logs, Grounding.

RoadmapThe planned permission and audit middleware is the AgentsUse direction for carrying these patterns across runtimes.

Reliability

6patterns

Prevents: Runs stall on a hung call, loop on a flaky one, or repeat a side effect after a resume.

Retries are classified and capped, calls run against a timeout with cancellation, and re-runs are designed so a repeated call does not repeat the side effect. Bounded retries, Timeouts and cancellation, Idempotency.

RoadmapThe roadmap treats recovery as reference code, so teams do not have to rediscover the same failure handling in every stack.

Cost and observability

2patterns

Prevents: Token burn nobody can attribute, and agent behavior nobody can review.

Result budgets cap what re-enters context at each step, and structured logs make per-tool cost and failure rates visible without reading a transcript. Context budgeting, Tool-call logs.

RoadmapThe planned audit layer is meant to turn call logs into a cost and behavior record for each connected tool.

One call, start to finish

Anatomy of a tool call

A single pass through the loop shows why order matters. Validation and permission checks sit before execution because a call stopped there has not changed anything yet. Past execution, failure handling has to be explicit: retry inside a bound, then move to a fallback, a compensation step, or a person.

Anatomy of one tool callA proposed call passes validation and a permission check, then executes. Errors go to a bounded retry or escalate to a fallback or a human. Successful results are shaped to a context budget before entering the model context.RequestValidationPermission checkExecutionResult shapingContextErrorbounded retryEscalatefallback or humanfailure branch: retry inside the bound,then escalate instead of loopingevery step writes one line to the audit log

And every step leaves a record

One line per tool call (AgentsUse shape)
{
  "ts": "2026-10-08T14:03:11Z",
  "run_id": "run_8f3",
  "step": 7,
  "tool": "web_search",
  "gate": "auto-approved",
  "args_hash": "b3:9f2c",
  "duration_ms": 1840,
  "outcome": "ok",
  "result_tokens": 3120,
  "attempt": 1
}

Arguments are hashed, not stored. Outcome, duration, and result size are what the monthly review reads. The pattern: Tool-call logs and observability.

Start from the failure

The failure you keep hitting, and the pattern that ends it

Start from the symptom your runs produce, then read the pattern that addresses that failure mode.

Without harness work

Model wired straight to toolsWithout a harness, the model calls tools directly. Malformed arguments execute, a hung call stalls the run, a verbose result floods the context, and a side effect repeats when the run resumes.ModelToolsMalformed arguments executeHung call stalls the runVerbose result floods the contextSide effect repeats on resume

With the harness patterns

Model, harness, toolsWith the harness between model and tools, arguments are validated, permissions checked, results budgeted, retries bounded, and every call logged, so the four failure modes on the left have an owner.ModelHARNESSvalidate · gate · budgetretry · log · groundnine patterns, one layerToolsArguments checked before executionTimeouts and cancellation on every callResults trimmed to a budgetRe-runs made idempotent

Same model, same tools. The difference is whether each failure mode has an owner before the run starts. The table below maps the symptom to the pattern that handles it.

Symptom in your runsPatternJob
A transient failure ends the run, or a permanent failure gets retried until latency and cost spin out of controlError recovery and bounded retriesRecover
Malformed arguments execute and fail downstream, or the model burns turns guessing the format you wantedArgument validation before executionConstrain
One oversized result evicts the instructions and constraints the model still needsContext budgeting for tool resultsBudget
The agent sends, deletes, or spends before anyone reviews the actual callPermission gating and human approvalGate
A retry or resume repeats a side effect: two charges, two emails, the same edit applied twiceIdempotency and safe re-runsRecover
After a bad run, nobody can answer what the agent did, in what order, or whyTool-call logs and observabilityRecord
One hung call stalls the entire run, and a cancelled tool keeps writing after the user said stopTimeouts and cancellationRecover
Dependent calls race in parallel, or independent calls run serially and the task takes far longer than it shouldSequencing dependent tool callsCoordinate
The final answer asserts numbers and quotes that no tool returnedGrounding and citing tool resultsRecord

The patterns library

Nine patterns, each sourced

How frameworks handle the same control problems. Twelve frameworks and agent runtimes compared on permissions, approvals, recovery, logs, and tool-result context, from their official documentation. Goose and Paperclip are included with their roles named: one is a local agent product, the other an orchestration control plane.

Compare frameworks

Inside the catalog

Harness notes, where the vendor docs support them

Five catalog profiles carry harness notes: repeat behavior, result volume, scope rules, and polling behavior, each taken from the vendor's documentation and dated. A profile gets a note only when the documentation states the behavior clearly enough to design against.

Tool profile

Harness notes: result volume is the budget lever

max_results accepts 1 to 20. Tavily agent guidance sets 5 as the starting point. Every result re-enters the context on each following step, so a high ceiling taxes the whole run, not just one call.

Open the profile

Tool profile

Harness notes: poll crawls to a terminal status

Crawl responses page results at 10 MB per response and hand back a next URL. The next URL also appears while pages are still processing, so job status (completed, failed, cancelled) is the end signal, never the absence of a next link.

Open the profile

MCP profile

Harness notes: scope the server before the model runs

The --read-only flag (or GITHUB_READ_ONLY=1) restricts the server to read tools, and read-only wins over --tools selections. A wrapper cannot widen what the flag closed. Permission gating sits in the server, not the prompt.

Open the profile

MCP profile

Harness notes: snapshots are the context cost

The server works from structured accessibility snapshots rather than screenshots. Each observation stays text-shaped and referenceable (click by ref) instead of image-priced.

Open the profile

MCP profile

Harness notes: scope is dynamic, repeat behavior is per tool

Allowed directories come from launch arguments or from client Roots. Roots replace the configured list entirely when present, and they can change while the server runs. Scope checks belong in the harness on every call, rather than only at connect time. With no allowed directory from either source, the server fails at startup.

Open the profile

Notes follow the documentation

A note appears only when a vendor document states the behavior. Browse the tools catalog and the MCP index for the setup, pricing, and limits behind each profile.

Questions

What is an agent harness?

The code and policy around a model that turns intent into tool calls. It selects the tool, checks the arguments, enforces permissions, handles errors and timeouts, decides how much of each result stays in context, and logs what happened. The model proposes a call; the harness decides whether and how it runs.

Are a harness and a framework the same thing?

They overlap. A framework (LangGraph, CrewAI, the OpenAI Agents SDK) ships harness machinery such as retry policies, approval interrupts, and checkpointing. Your harness is the set of choices you make with that machinery: which tools run ungated, what the retry bound is, what gets logged. Two teams on the same framework run different harnesses.

Do I need all nine patterns?

No. Argument validation and a per-call timeout pay for themselves on day one. Add approval gates before the agent touches anything irreversible, logs before it runs unattended, and the rest as the failures show up. The checklist guide orders all nine by what breaks first.

Where does the catalog fit in?

The harness assumes tools worth calling. Catalog profiles record setup paths, auth, pricing, and limits for the tools and MCP servers a harness drives. Five profiles also carry harness notes: vendor-documented facts about repeat behavior, result volume, and scope that a harness design needs.