SysArt
Book a briefing
SysArt

Guide

What is an agent harness?

A language model becomes an agent only inside a harness: the software that runs its loop, gives it tools, manages its context and enforces limits. This guide explains what a harness is, why agent reliability depends on it and what to require before you deploy one.

Last reviewed by SysArt AI Architecture Team11 min readHow we review

In short

An agent harness is the software around a language model that turns it into an agent. It runs the loop of reasoning, tool calls and observations, provides the tools, decides what enters the model's context and enforces controls such as permissions, sandboxes, approvals and tests. How reliably an agent works depends on its harness as well as its model.

DefinitionAn agent harness is the runtime software layer that wraps one or more language models and turns them into an agent by running a loop of reasoning, action and observation, giving the model tools to act on its environment, managing what enters its context and enforcing controls that do not depend on the model's cooperation.

Key takeaways

  • A harness has four core parts: the agent loop, a tool interface that can change the environment, context management, and controls that work whether or not the model cooperates, such as permission checks, sandboxes, approvals and tests.
  • A harness is not an agent framework, an SDK or an evaluation harness: frameworks compose agents, SDKs supply building blocks, and an evaluation harness such as SWE-bench's scores an agent's output after each task.
  • Anthropic and OpenAI engineering teams fixed agent failures by changing the harness rather than the model: progress files, feature lists and end-to-end tests in one case; documentation maps, custom linters and observability in the other.
  • There is no best agent harness in general. For enterprise use, require support for self-hosted models through a standard API, scoped and sandboxed tools, approvals, full traces, governed MCP connections and control over outbound traffic.
  • Govern the harness as part of the agent: name an owner, version its configuration together with the model, prompts and tools, and rerun your evaluation suite before any of them changes.

What is an agent harness?

An agent harness is the software layer that wraps a language model and turns it into an agent. The model decides what to do next; the harness runs the loop, carries out the actions, chooses what the model sees and keeps the work within limits.

The term is used loosely: sometimes for a whole product, sometimes for the scaffold that runs benchmarks. A 2026 preprint by Sanderson Oliveira de Macedo turns it into a test. A system is an agent harness if, while a task runs, it provides all four of these:

  1. An agent loop that interleaves reasoning, action and observation, so that each step depends on what the previous one revealed.
  2. A tool interface that lets the model perceive and change an external environment, for example by editing files or running commands. Reading signals without being able to act does not count.
  3. Context management that decides what enters and leaves the model’s context window according to the task, not only its size. A wrapper that truncates the history when it overflows does not qualify.
  4. Controls that do not depend on the model’s cooperation, such as a cap on tool calls, a deterministic check, a sandbox or a human approval step. A log line alone is not a control, because it does not change what happens.

Around this core, a harness may add memory across steps and sessions, a verifier that checks whether a task is really done, retries and model switching, observability, guardrails, and ordinary code for steps too sensitive to leave to the model. Context management has become a discipline of its own; see what context engineering involves.

The coding tools that made the term popular fit this definition. Claude Code’s documentation calls the layer that provides the tools and manages the model’s context the agentic harness, and OpenAI calls the agent loop and logic behind every Codex surface the Codex harness. The paper tests six tools (Claude Code, Codex CLI, Aider, Cline, OpenHands and SWE-agent), finds that all six qualify, and notes that they differ most in their controls.

For what agents are and when to choose one over a copilot, see AI agents vs copilots.

How is an agent harness different from a framework, an SDK or an evaluation harness?

A harness makes one agent act on its environment while the task runs. Its neighbours compose agents, supply parts or judge the result afterwards:

  • Agent framework. Frameworks such as LangGraph, CrewAI or Google’s Agent Development Kit provide abstractions for composing agents: roles, conversation protocols and collaboration patterns. Many embed a minimal harness, and a framework can run a harness beneath each agent it coordinates. A system that only routes messages between personas, without acting on an environment, is a framework rather than a harness.
  • Agent SDK. An SDK supplies building blocks, such as function calling, tool definitions and loop primitives, and leaves you to assemble the agent. Once a library ships the closed loop with context management and controls, it has become a harness: Anthropic describes its Claude Agent SDK as a general-purpose agent harness, with context management such as compaction built in.
  • Agent runtime. The word is used both for the process that runs the agent loop and for the environment where tools execute, such as a container. OpenAI uses it in both senses for Codex, so ask a vendor which one it means.
  • Evaluation harness. This is the most direct name clash. SWE-bench’s harness runs in Docker containers, evaluates the patches an agent produces and records results and logs. It judges the outcome after each task; an agent harness acts during it.

You will usually run both kinds: an agent harness to do the work and an evaluation harness to test it before release.

Why does an agent’s reliability depend on its harness?

Because many agent failures come from what surrounds the model: state lost between sessions, unverified claims of success and missing tools. The documented fixes are changes to the harness, and the controls that hold are the ones outside the prompt.

In a November 2025 engineering post, Anthropic described coding agents that work across many context windows. Even a frontier model running in a loop on its Agent SDK, with compaction, fell short of building a production-quality web application from a high-level prompt. It tried to do too much at once, ran out of context mid-feature and left the next session to guess what had happened; later sessions saw progress and declared the job done. The fixes were harness changes:

  • a first session that sets up the environment: a start-up script, a progress log and an initial git commit;
  • a structured list of more than 200 features for the example application, all marked as failing, which later sessions are instructed to update only by changing a pass flag;
  • one feature per session, ending with a commit and a progress note, so that the next session can recover from the git history;
  • end-to-end testing through browser automation, which Anthropic reports greatly improved results because the agent found bugs that were not obvious from the code alone.

The de Macedo paper explains why verification matters most. A cornered model tends to give the answer that seems to satisfy the request, true or not, and telling it politely not to is the weakest of controls. The paper’s remedy is to check the real state deterministically; containment, such as a sandbox, is the strongest control because it works without the model’s cooperation. The paper also notes a gap: benchmarks measure the model and the harness together, and a way to isolate the harness’s contribution is still missing. In practice, evaluate the combination you will deploy, on your own tasks, and evaluate again when either part changes.

What is harness engineering?

Harness engineering is the work of designing the environment around an agent so that it can do reliable work: the tools it can use, the knowledge it can reach, the rules enforced on its output and the feedback that shows when it is wrong. OpenAI described the practice in a February 2026 engineering post.

The team built an internal product in which Codex wrote every line of code, including tests, CI configuration and documentation. Early progress was slower than expected, it reports, not because the model was incapable but because the environment was underspecified. When something failed, engineers asked which capability was missing and how to make it both legible and enforceable for the agent:

  • A map, not a manual. After one large instruction file failed, a short AGENTS.md of about 100 lines became a map to a structured documentation directory, the system of record. Linters and CI jobs check that it stays current and cross-linked.
  • Rules enforced mechanically. Custom linters and structural tests check architecture boundaries, and their error messages tell the agent how to fix the violation.
  • A legible application. Each change can start its own instance of the application, with logs, metrics and traces available to the agent.
  • Continuous clean-up. Recurring background tasks look for drift from agreed principles and open small refactoring pull requests.

OpenAI is explicit about the limits. The agent’s ability to drive a feature end to end depends heavily on that repository’s structure and tooling, and should not be assumed to generalise without similar investment. The team also worked with minimal blocking merge gates, a trade-off it calls irresponsible in a low-throughput environment. In a regulated enterprise, keep change control for anything an agent can merge or deploy.

What should an enterprise require from an agent harness?

There is no best agent harness in general, only one that fits your models, tools, controls and infrastructure. Assess candidates against these requirements, then test the shortlist with your own model on your own tasks.

RequirementWhat to checkWhy it matters
Models you hostCalls models through a standard API, such as an OpenAI-compatible endpoint, with vendor support for your own inference serversPrompts, code and tool results stay on infrastructure you control
Reliable tool callsTool calling works with the exact model and serving engine you will runSelf-hosted engines must parse each model’s tool-call format
Scoped permissionsAllow, ask and deny rules per tool, separate read and write tools, central policy that users cannot overrideNarrow permissions limit the damage of a wrong or manipulated step
SandboxingFile system, process and network isolation for shell and code execution, with network access off by defaultContainment works even when the model does not cooperate
Human approvalApproval before high-impact actions, configurable by action type, showing the reviewer the proposed actionA harness may roll back file edits, but not a payment or a sent message
Audit logs and tracesEvery model call, tool call, approval and error recorded under one run identifier and exported in an open format, such as OpenTelemetryYou can explain, replay and audit any run
Governed MCP connectionsAn allowlist of MCP servers, consent before tool calls and separate credentials per serverThe protocol cannot enforce its own security principles; the host must
Telemetry and egressA documented list of everything the harness sends out, a setting for each, and support for your proxyA single switch may not cover every outbound call
Your infrastructureRuns in your network or air-gapped, with pinned versions and a licence that permits itYou decide when it changes and where its data goes

Models and tool calls. Inference engines such as vLLM serve open-weight models through OpenAI-compatible and Anthropic Messages-compatible APIs, so a harness that lets you configure its endpoint can use models on your own GPUs. Then test tool calling: vLLM needs automatic tool choice switched on with a parser that matches the model’s format, and warns that without strict schema enforcement, arguments may occasionally be malformed. Our comparison of vLLM, Ollama, llama.cpp and SGLang covers the serving side.

Approval and reversibility. Claude Code’s documentation, for example, says its checkpoints cover file changes only; actions that affect databases, APIs or deployments cannot be rolled back and are controlled through permission modes and rules. OpenAI’s Codex App Server pauses a turn that needs approval until the client allows or denies the action.

MCP connections. The Model Context Protocol (MCP) standardises how a harness connects to external tools and data. Its specification says that tools represent arbitrary code execution, that tool descriptions should be treated as untrusted unless they come from a trusted server, and that hosts must obtain explicit user consent before invoking any tool. It adds that MCP cannot enforce these principles at the protocol level, so the harness has to. Our guide to MCP security covers allowlists, credentials and gateways.

Telemetry and egress. Read the vendor’s data-flow documentation rather than assuming one switch covers everything. Claude Code’s, for example, documents separate opt-outs for usage metrics and error reports and one variable for all non-essential traffic, plus a domain check before web fetches that has its own setting. Block at the network any egress the harness does not need; our guide to AI agent security covers the wider threat model.

Where does the harness sit in an on-premises AI architecture?

Between your users and your platform services: it calls models through your AI gateway, reaches tools through governed connections, runs code in sandboxes and sends traces to your own monitoring.

  • Models are reached through an AI gateway with a stable API that routes to inference engines on your GPUs, so changing the model means changing configuration, not the harness.
  • Tools sit behind a gateway or approved MCP servers that check identity and scope on every call, so permissions do not depend on the harness.
  • Execution happens in containers or virtual machines inside your network. OpenAI, for example, runs the Codex harness for its web product in a container provisioned with the checked-out workspace.
  • Traces go to your observability stack. OpenTelemetry’s semantic conventions for generative AI cover agents, tool execution and MCP, which keeps traces portable between monitoring tools.

Our on-premises AI reference architecture shows where each layer sits.

How do you govern an agent harness in production?

Treat the harness as part of the agent’s controlled configuration, not as a developer tool: owned, versioned, changed through review and evaluated again before every upgrade.

  • Ownership. Each agent needs a business owner for its outcomes and a technical owner for how it runs, including its harness.
  • One versioned configuration. Record the harness version, model, system prompts, tools, permission policy, sandbox settings and MCP servers together, because a change to any of them can change behaviour. OpenAI pins the Codex binary shipped in its IDE extension and desktop app to a tested version, so the client runs exactly the version it was validated against.
  • Change control. A new tool, a wider permission, a new MCP server or a new model goes through review like a code change.
  • Evaluation before upgrades. Run a scenario suite of normal, ambiguous, adversarial and failure cases against the exact harness and model you will deploy, and compare results before upgrading either.
  • Monitoring and a stop control. Track task success, wrong actions, escalations and cost per run, and keep a tested way to stop a run and revoke its credentials.

For high-risk AI systems, the EU AI Act requires that the system technically allows the automatic recording of events over its lifetime (Article 12), and that the people overseeing it can, as appropriate and proportionate, interrupt it through a stop button or a similar procedure that brings it to a halt in a safe state (Article 14). In an agent, that logging and stop control are usually built into the harness. Whether these duties apply depends on the agent’s intended purpose and your role; this guide is not legal advice, so confirm borderline cases with qualified counsel. The agentic AI governance framework sets out the full set of controls and records.

SysArt designs, builds and governs AI agents on infrastructure you control. We choose the harness that fits your stack and keep tools, permissions and traces independent of it, so you can change the harness or the model later.

Frequently asked questions

What is an agent harness?

An agent harness is the software layer that turns a language model into an agent. It runs the loop in which the model reasons, calls a tool and reads the result; it provides the tools; it decides what enters the model's limited context; and it enforces controls such as permission checks, sandboxes, approvals and tests. Claude Code, Codex CLI, Aider, Cline, OpenHands and SWE-agent are examples from software development.

What is harness engineering?

Harness engineering is the work of designing the environment around an AI agent so that it can work reliably: the tools it can use, the documentation and context it can reach, the rules enforced on its output and the feedback that shows when it is wrong. OpenAI described the practice in February 2026 after a project in which Codex wrote all the code; slow early progress came from an underspecified environment, not an incapable model.

What is the difference between an agent harness and an agent framework?

An agent framework works a level above the harness. It offers abstractions for composing agents, such as roles, conversation protocols and collaboration patterns, and it can run a harness inside each agent it coordinates. The harness makes a single agent act on its environment: it runs the loop, executes tools, manages context and enforces controls. A single agent that edits files and checks its own results is a harness without any framework.

Are Claude Code and Codex agent harnesses?

Yes, by their makers' own descriptions. Claude Code's documentation calls the layer that provides the tools and manages the model's context an agentic harness, and OpenAI calls the agent loop and logic behind every Codex surface the Codex harness. A 2026 research paper that tests systems against four conditions classifies Claude Code and Codex CLI as harnesses, along with Aider, Cline, OpenHands and SWE-agent. The six differ most in how they control the agent.

What is the best agent harness?

There is no best agent harness in general, only one that fits your models, tools, controls and infrastructure. For enterprise use, check that it can call self-hosted models through a standard API, scope and sandbox its tools, require approval for high-impact actions, trace every step, govern MCP connections, let you switch off telemetry and run on your own infrastructure. Then test the shortlist with your model on your own tasks.

Is SWE-bench an agent harness?

No. SWE-bench uses an evaluation harness: it runs in Docker containers, evaluates the patches a coding agent produces and records results and logs. An agent harness acts during a task, choosing each next step from what the agent has just observed; an evaluation harness judges the outcome from outside once the task has ended. You need both: one to run the agent and one to test it.

Is a guardrail the same as an agent harness?

No. A guardrail is one part of a harness. Guardrails limit the agent: they cap tool calls or cost, block destructive commands and validate actions. The harness as a whole also helps the agent work, by managing its context, keeping memory, retrying failed steps and verifying that a task is really done. If a component restricts the agent, it is a guardrail; if it helps the agent execute, it belongs to the wider harness.

Can an agent harness use a local or on-premises LLM?

Yes, if the harness lets you configure its model endpoint and your inference server offers the API it expects. vLLM, for example, serves open-weight models through OpenAI-compatible and Anthropic Messages-compatible APIs. Tool calling needs the most care: for the model to choose tools itself, vLLM must be started with automatic tool choice enabled and a parser that matches the model's tool-call format. Test the exact model, engine and harness together before production.

Choose a harness that fits your controls

Bring the agent use case, the models you can run and the systems the agent must reach. We assess candidate harnesses against your security and governance requirements and test them on your own tasks.