AI Agent Harness, Explained: The Reliability Layer Around an LLM

Back
Kevin Riedl

12 min read · 26 Aug 2026
Last reviewed

Next
Made on your device, with no Instagram connection. We copy the post link for Instagram’s Link sticker.

An LLM generates text and tool calls. An AI agent harness turns those proposals into a bounded, observable and testable process. It builds the model’s context, exposes approved tools, checks permissions, executes actions, returns evidence, verifies the outcome and decides whether the run may stop.

That distinction prevents an expensive diagnosis mistake. If an agent used stale data, called an overpowered tool or declared success without testing, a stronger model may still repeat the failure. The defect sits in the system around the model.

This article owns the vendor-neutral architecture and build-or-buy intent for AI agent harness. Our AI agent definition explains the broader category. The context-engineering article goes deeper on retrieval. The jcode, DeepSeek, TrueForge and QM articles evaluate specific harness products rather than competing with this explainer.

Choosing the control flow inside that harness? Our AI agent design patterns decision guide compares single-shot, ReAct, planner-executor, reflection and verifier-gated execution by the failure each should address.

For Google’s recursive approach, read our Harness² setup, benchmark and cost guide. It separates model improvement claims from execution overhead, sandbox requirements and a bounded first evaluation.

What is an AI agent harness?

An AI agent harness is the runtime and control layer that connects a user goal to an accepted result through an LLM. It owns context assembly, model calls, tool contracts, policy decisions, execution, state, verification, recovery and telemetry. Anthropic’s effective-agent architecture guidance similarly treats retrieval, tools and memory as augmentations around the model, and recommends adding complexity only when it improves measured outcomes.

LayerWhat it decidesEvidence it should produce
0. User goalScope, success criteria and riskTask contract and approval owner
1. Context builderWhich instructions, data, history and tool schemas enterSource IDs, versions and retrieval trace
2. LLMWhat response or action to propose nextModel version, request and proposed call
3. Policy gateAllow, block or request human approvalRule, actor, decision and reason
4. Tools and runtimeHow approved work executes within resource limitsInputs, outputs, side effects, timing and errors
5. VerifyWhether the result satisfies acceptance and safety checksAssertions, scores, failures and repair request
6. Accepted resultWhat may be returned, persisted or publishedFinal artifact, provenance and status

Two concerns cross every row. Constraints set permissions, budgets, timeouts, data boundaries and stopping rules. Observability records traces, latency, cost, errors and outcomes. They are not boxes at the end because they must govern the whole loop.

How the harness loop works

  1. Translate intent into a task contract. State the deliverable, allowed systems, forbidden actions, budget, deadline and acceptance tests.
  2. Compile the smallest useful context. Select current instructions, authoritative records and only the tool definitions needed for this step. Anthropic’s context-engineering guidance frames context as a finite resource that must be curated throughout the run.
  3. Let the model propose, not authorize. The LLM chooses a response or structured tool call. It does not grant itself access.
  4. Evaluate the proposed action. Deterministic rules should check identity, scope, arguments, data class, rate, spend and reversibility. A person approves consequential exceptions. OpenAI’s Agents SDK guardrail documentation separates input, output and tool checks, which is a useful reminder that one prompt filter is not a complete policy layer. As of 29 November 2026 that page also states that tool guardrails run on function tools and local MCP tools, but not on hosted or built-in execution tools and not on the handoff call itself. List which of your tools sit outside the pipeline you think is protecting them.
  5. Execute in a controlled runtime. Tools receive typed inputs, scoped credentials, network and filesystem limits, timeouts, retries and idempotency controls. Results return as untrusted evidence, not new instructions.
  6. Verify before returning. Prefer deterministic assertions, unit tests, schema validation and reconciliation. Use a model grader only where rules cannot express quality, and do not let the producing agent be the only judge.
  7. Record and learn. OpenAI’s tracing model records model generations, tool calls, handoffs and guardrails. A production design must also redact sensitive payloads and keep audit evidence outside the agent’s ability to rewrite it.

Give the harness two approved writes, A and B, then restart it after A returns a receipt but before the run records completion. The trace may contain proposals A, A and B. Reconcile two distinct receipts against the two approvals and inspect the repeated A. Counting three tool calls alone cannot tell you whether a customer received a duplicate.

When verified experience should survive the run or move to a cheaper model, use a governed learning store instead of hiding the lesson in an ever-growing transcript. Our AI agent knowledge-transfer guide explains the Agno ARC-AGI-3 evidence, the architecture and a production pilot.

What happens when the harness restarts between a tool call and its receipt?

The harness either repeats the write or loses it, depending on which step it performs first. In our reproduction, executing before recording duplicated a write in 33.2% of runs and recording before executing lost one in 33.3%. Only a write carrying an idempotency key produced neither failure across 10,000 runs.

We ran the two-write scenario above instead of arguing about it: 10,000 runs per strategy on 29 November 2026 (Node 24.15, built-in SQLite 3.54.1, Apple M3 Pro laptop, 18 GB RAM, macOS).

Every run has two approved writes, A and B, and exactly one injected crash at one of six points: before, between or after the two steps of each write. The harness then restarts and replays whatever its journal does not show as completed. A SQLite table stands in for the external system that customers see. No model is involved.

Order of stepsTool callsEffects in the external systemRuns with a duplicateRuns with a lost write
Execute, then record completion23,32123,3213,321 (33.2%)0
Record completion, then execute16,67516,67503,325 (33.3%)
Execute with an idempotency key, then record23,40120,00000

The one-third is an artefact of the setup: two of the six crash points sit between the two steps. It says nothing about how often your harness crashes. The shape is what transfers. Swapping the order of “execute” and “record” converts duplicates into silent losses, and no ordering removes both. Only the third row delivers 20,000 effects for 20,000 approvals, because the receiving system rejects the replayed write by key.

Look at the tool-call column again. With the key, 3,401 runs made three tool calls. Without it, 3,321 did. The two traces are indistinguishable by count, yet one produced a duplicate every time and the other never did. A verifier that counts calls or reads the agent’s own summary cannot see the difference. One that reconciles receipts against approvals can.

The key is cheap. On a file-backed SQLite database in WAL mode, a unique key with ON CONFLICT DO NOTHING raised the median write from 6.2 to 11.3 microseconds (five trials of 50,000 writes each). Five microseconds per write is not a reason to skip it.

key = run_id + ":" + approved_step_id      (stable across replays)
INSERT INTO effects (run, step, key) VALUES (?, ?, ?)
  ON CONFLICT(key) DO NOTHING

Derive the key from the approved step, never from the model’s output. After a restart the model may propose the same action with slightly different arguments, and a key hashed from those arguments would let the duplicate through. The OWASP cheat sheet cited below asks for the same two properties in its high-impact action controls: idempotent actions where possible, and approvals that are consumed atomically so a repeated request cannot reuse one.

Which guarantee does each tool need?

Tool behaviourReplay rule after a restartWhat you still have to check
Read-only lookupRetry freelyRate limits and cost, nothing else
Write to an API that accepts an idempotency keyReplay with the same keyHow long the provider remembers keys, and that replays stay inside that window
Write with no key, but the result can be read backRead first, write only if the effect is missingThe gap between the read and the write if two workers can run the same step
Irreversible action with no key and no read-back (a sent message, a payment on a legacy rail)Record the intent first and stop for a person after a restartThat the lost-write case reaches an owner. A person can resend. Nobody can unsend

What the simulation does not show: it contains neither an LLM nor a real API, and nothing crosses a network. It injects one crash per run in a single process and never crashes inside the external write itself. Real idempotency keys expire and some APIs offer none, which is why the last two rows of the table exist.

Where do most AI agent failures happen?

Give the harness a receipt that says “submitted” when the task requires “approved.” If the run closes successfully, inspect the completion check before changing the prompt. A useful trace identifies the tool result, the required final state and the component that accepted the difference.

There is no credible universal percentage that assigns most failures to context, tools, constraints or verification. Failure rates depend on the workflow, model, tool surface and definition of success. The useful move is to classify the first broken contract in the trace.

Failure layerTypical symptomFirst diagnosticLikely fix
ContextConfident answer from stale, irrelevant or missing evidenceReplay the exact context and source versionsImprove retrieval, freshness, compaction or task instructions
ToolsWrong function, malformed arguments, timeout or duplicate side effectInspect schema, arguments, response and retry pathNarrow the interface, validate inputs and make writes idempotent
ConstraintsAgent reaches data or actions outside the intended scopeCheck effective identity, permission and approval decisionLeast privilege, deterministic policy and human authority
VerificationPlausible output marked complete although the real task failedCompare the final artifact with independent acceptance checksAdd environment tests, graders, thresholds and repair loops

Verification is often the missing last mile because a fluent answer looks finished. Anthropic’s agent-evaluation guidance recommends evaluating multi-turn traces and environment state, not only the final response. Security failures cut across several layers. The OWASP AI Agent Security Cheat Sheet recommends treating external content as untrusted, limiting privilege, validating tool calls and requiring human approval for high-impact actions.

Agent harness vs framework, workflow engine and model API

CategoryPrimary jobWhat it does not prove
Model APIGenerate text, reasoning items and tool callsAuthorization, durable state, recovery or business correctness
Agent frameworkProvide abstractions for agents, tools, handoffs and memoryThat your deployed controls and operations are complete
Workflow engineRun defined steps, retries and schedulesSafe handling of model-selected actions or semantic quality
Agent harnessJoin the model, context, tools, policy, runtime, verification and telemetry into one controlled loopReliability without task-specific tests and operating ownership

Build, extend or buy an agent harness?

ChoiceBest fitMain cost
Build a thin custom loopOne narrow workflow with unusual controls and a strong platform teamYou own every integration, regression and incident path
Extend an open framework or harnessYou need speed plus code-level control and can operate the stackUpgrades, missing enterprise controls and extension maintenance
Use a managed agent platformStandard capabilities, fast pilot and limited platform capacityProvider boundaries, data terms, pricing and portability

Do not choose by feature count. Run the same acceptance set through each option and compare successful outcomes, P50 and P95 latency, review minutes, unsafe actions blocked, recovery success and cost per accepted task. Our 30/60/90-day AI agent pilot provides the rollout sequence. The agent eval sandbox checklist covers containment in more depth.

Evaluating a concrete open-source implementation? Our DeerFlow 2.0 Docker setup, sandbox and memory guide separates application startup from task isolation and provides deployment acceptance checks.

Make the harness reviewable

Bring one repository and a recurring agent failure. Define context, tool permissions, checkpoints and verification around a representative task.

Relevant service:

Evaluating the managed option? Our OpenAI Agents API review compares it with Agents SDK and Responses, separates the launch numbers, and provides migration, cost and data-control checks.

A managed harness can move orchestration and recovery outside your application. OpenAI’s Agents API still manages session state when you host the sandbox yourself, with US-only residency and no Zero Data Retention support for this API. Verify where the session, tool outputs and published artifacts are retained separately from where code executes. Test that the application can reconcile a resumed run before allowing another consequential write. OpenAI Agents API.

Production acceptance checklist

  • Task contract: one named outcome, owner, deadline, budget and forbidden-action list.
  • Context: authoritative sources, freshness rules, source IDs, tenant isolation and compaction tests.
  • Tools: typed schemas, least-privilege credentials, validation, timeouts, retries and idempotency.
  • Policy: deterministic checks for high-impact actions, explicit approval and no silent bypass.
  • Runtime: network, filesystem, package, secret and resource boundaries with cancellation and recovery.
  • Verification: representative tasks, multiple trials, independent graders and real environment checks.
  • Observability: correlated traces, redaction, cost, latency, errors, policy events and accepted outcomes.
  • Operations: version pinning, eval gates before upgrades, rollback, incident ownership and data retention.

Wavect’s Harness Engineering service implements repository context, tool boundaries and verification loops around existing coding agents. For an implementation scope, discuss your agent harness.

Frequently Asked Questions

What is an AI agent harness in one sentence?
It is the runtime and control layer around an LLM that assembles context, governs tool use, executes actions, verifies results and records the complete run.
Is an agent harness the same as an agent framework?
No. A framework supplies development primitives. A harness is the deployed reliability boundary that joins those primitives with permissions, execution, verification, recovery and operations. One product can provide both.
Can a better model replace the harness?
A better model may improve planning and tool selection, but it cannot replace your identity system, permissions, idempotency, acceptance tests, audit trail or incident response. Re-test harness assumptions when models improve, then remove only the controls that evidence shows are unnecessary.
What should an agent harness log?
Record the task and context versions, model and prompt configuration, proposed and executed tool calls, policy and approval decisions, results, errors, retries, verification outcomes, latency and cost. Redact sensitive data and apply an explicit retention policy.
Where should a team start?
Choose one valuable and reversible workflow. Write representative tasks, acceptance checks and forbidden actions before connecting production tools. Begin in shadow mode, inspect failed traces and expand authority only after repeated passes.
How do you stop an AI agent from repeating a write after a crash?
Give every approved write an idempotency key derived from the run and the approved step, and let the receiving system reject a replay with the same key. In our 10,000-run simulation, executing before recording duplicated a write in 33.2% of runs, recording first lost one in 33.3%, and the keyed variant did neither.

For a concrete visual-authoring option, our SmythOS Studio self-hosting guide separates the editor, SRE execution and operational checks needed beyond a local Docker demo.

Final thoughts

An LLM is the reasoning component, not the reliability system. The agent harness decides what enters the model, which proposed actions may run, how tools execute, what evidence proves completion and what operators can reconstruct after a failure.

Start with the failure map and acceptance checklist, not a framework shortlist. A simpler harness that proves one business outcome is more valuable than a feature-rich stack that cannot explain why the agent succeeded or failed.

For concrete integration boundaries, see Vendo tenant isolation, Arga and Archal stateful test environments and AgentMail duplicate-send recovery. Their proposed protocols separate platform features from permissions and recovery your application still owns.

Inbox, without the noise

Follow the work that matters to you

Get a short email when we publish something new. Follow the whole blog or only the problems you care about.

What would you like to receive?
Choose your topics

Free, double opt-in, no tracking pixels.

Add Wavect as a preferred source on Google

Back
Kevin Riedl

12 min read · 26 Aug 2026
Last reviewed

Next

Get the next AI and agents field note

One concise email when we publish. No tracking pixels, and no inbox filler.

Free, double opt-in, no tracking pixels.

Add Wavect as a preferred source on Google