Agent harness, the software that runs the model
A language model on its own takes text in and gives text out: it answers a prompt and stops. To act in a loop, call tools and decide when the task is done, it depends on the software around it. That surrounding layer is what many texts call a harness, or an agent harness, and the model plus that software is what gets described as an agent.
LangChain’s documentation puts it plainly: an agent is a model calling tools in a loop until a task is complete, and a harness is everything around that loop, the prompt, the tools and the middleware that shapes the model’s behavior. On the same page, the formula is agent equals model plus harness, and create_agent is a configurable harness. Claude Code’s documentation describes the same cut from another angle: Claude Code is the layer around the model that provides the tools and manages the context the model sees, and that surrounding layer is what the term agentic harness refers to.
What the harness does
In practice, the harness is what runs the work. It calls the model, executes the tools the model asks for, handles errors, applies permissions and decides when to stop. Without it, a tool request stays on the page as text and nothing actually runs.
Harness, scaffolding and orchestrator
The vocabulary is still unsettled, and the Hugging Face glossary says so clearly: different frameworks use the same word in different ways. When the parts need to be pulled apart, that text calls scaffolding the behavior-defining layer, the system prompt, the tool descriptions, how the model’s replies are parsed and how context is managed. In that narrower cut, the harness is the execution layer, the one that calls the model, handles the tools and decides when to stop. An orchestrator sits one level up: it coordinates several agents, each running its own harness.
Some texts use scaffolding in the broad sense, for the whole software layer around the model. That is how Anthropic’s article on SWE-bench performance uses it: the scaffolding generates the prompts, parses the model’s output in order to act and manages the interaction loop, and an agent’s score on that benchmark can vary widely with this software even when the underlying model stays the same.
The agent loop
In the article on the Claude Agent SDK, Anthropic describes the loop Claude Code often works in as gather context, take action, verify the work and repeat. The harness is what keeps that cycle going and what decides when it ends, either because the model declares the task complete or because a stopping rule kicks in, such as the context window running out. Without a clear stopping rule, the loop keeps spending tokens after the useful work is done, or it stops too early and leaves the task half-finished.
Harness engineering
Harness engineering is the work of designing and tuning this layer. The Hugging Face glossary describes the discipline as deciding when the agent should stop, how errors get handled and which guardrails keep it on the task. In practice, that looks like what the Claude Agent SDK article recommends after a few turns of the loop: look carefully at the output, especially the cases where the agent fails, and ask whether it had the right tools. A visible failure can become a new rule, a new tool or an extra check in the harness.
Hooks
Hooks are a documented way to attach commands to that cycle. In the Claude Code documentation, hooks are user-defined shell commands, HTTP endpoints, MCP tool calls, prompts or subagents, and they run on their own at specific points in the product’s lifecycle. Two events show the cut: PreToolUse runs before a tool call executes and can block it; PostToolUse runs after a successful call. Other harnesses may have similar mechanisms under other names; what the sources support under this name is the Claude Code mechanism.
Public examples
There are public, documented examples. Claude Code is the agentic harness described in Anthropic’s own documentation, and the Claude Agent SDK, according to the company’s article, is the harness that powers it and is also used for other kinds of agents. OpenAI publishes Codex as an open harness in the official repository, and the post «Codex as a platform» presents that open-source harness as what powers the product’s experiences. In LangChain, the documented starting point is the create_agent function, a configurable harness where you choose the model, the tools and the system prompt.
Why the harness is part of the result
The same model, measured with a different harness, can return a different result, because what gets evaluated in practice is the agent, not the model in isolation. On How to read AI benchmarks for each use case, this is stated up front: the same benchmark with a different harness, time limit or reasoning effort produces a different result, and comparing what was not measured under the same conditions is one of the mistakes to avoid. Anthropic’s SWE-bench article says the same thing in the vocabulary of scaffolding: an agent’s performance on that benchmark can vary significantly with the software around the model, even when the underlying model is the same.
In the open evaluation described in the note With the model fixed, the harness shows up in cost and speed, Garry Tan kept the model and the tasks the same and changed only the harness. Accuracy rates were statistically indistinguishable, and cost and time per task diverged. The harness is therefore part of the result: sometimes what changes is the cost, while accuracy stays in the same range.
FAQ
What is an agent harness? It is the software around the model that runs the loop, executes tools, handles errors and permissions and decides when to stop. Added to the model, it forms the agent, in the sense used by LangChain’s documentation and by Claude Code’s documentation.
Are harness and scaffolding the same thing? It depends on the text. Some uses treat both names as the whole software layer around the model. When the Hugging Face glossary separates the parts, scaffolding is what the model has in front of it (prompt, tools, format) and the harness is what makes the loop run.
Why does a model’s score change with a different harness? Because many benchmarks measure the agent, not the model alone. Changing the harness, the time limit or the system prompt changes the condition, and the result may change in accuracy, in cost or in both.
What is harness engineering? It is the work of designing and tuning the harness: the stopping rule, error handling, permissions and the checks that get added after a visible failure.
Sources
- LangChain documentation, Agents
- Claude Code documentation, How Claude Code works
- Claude Code documentation, Hooks reference
- Anthropic, Effective harnesses for long-running agents
- Anthropic, Building agents with the Claude Agent SDK
- Anthropic, Claude SWE-Bench performance
- Hugging Face, Harness, Scaffold, and the AI Agent Terms Worth Getting Right
- OpenAI, Codex as a platform
- Official Codex repository
- How to read AI benchmarks for each use case, on this site
- Note on Garry Tan’s evaluation, on this site