Subscribe
Agents
6 min read

What Is an AI Agent Harness? The Software Around the Model

An agent harness is the software around an AI model that runs it in a loop, gives it tools and manages what it sees. Here is what each part does.

Olivetti-style cover reading Agent Harness Explained, with a charcoal model block inside a frame of teal, red and mustard blocks marked with tool, memory and loop icons on cream.
Olivetti-style cover reading Agent Harness Explained, with a charcoal model block inside a frame of teal, red and mustard blocks marked with tool, memory and loop icons on cream.

An AI agent harness is the software around an AI model that lets it act: it runs the model in a loop, gives it tools, and manages what the model sees. Anthropic, for example, describes Claude Code itself as the harness around its Claude models.

This guide explains what a harness is in plain terms, what its parts do, how it differs from a model and a framework, and why the term keeps coming up when people talk about coding agents.

What is an agent harness?

The clearest definition comes from Anthropic's own documentation. The How Claude Code works page says: "The agentic loop is powered by two components: models that reason and tools that act. Claude Code is the layer around the model that provides the tools and manages the context the model sees. This surrounding layer is what the term agentic harness refers to."

LangChain, which makes software for building agents, puts it as a short formula on its Agents documentation page: "Agent = Model + Harness." The same page defines the two halves. "An agent is a model calling tools in a loop until a given task is complete." And: "A harness is everything around that loop: the prompt, the tools, and any middleware that shapes the model's behavior."

Developer Simon Willison uses a similar definition in a September 2025 post: "An LLM agent runs tools in a loop to achieve a goal." He describes tool calls as the model being "given the ability to request actions to be executed by its harness, and the outcome of those tools is fed back into the model".

An analogy can help (this is our comparison, not a definition from these sources). Think of the model as an engine. An engine on a workbench can run, but it cannot take you anywhere. The car around it, with wheels, steering, brakes and a dashboard, turns that power into a trip. The harness is the car.

If you are new to the wider idea, our explainer on what a coding agent is covers the products built on top of harnesses.

What does a harness do?

Different products build their harnesses in different ways, but the sources above describe the same core jobs.

It runs the loop

A chat app answers once and stops. An agent keeps going. The harness sends the task to the model, receives the model's request to use a tool, runs that tool, sends the result back, and repeats until the task is done.

Anthropic's Claude Code docs describe this loop in three phases: "gather context, take action, and verify results." The docs add that these phases blend together.

It provides tools

A model on its own produces text. It cannot open a file or run a command. The Claude Code docs say it directly: "Tools are what make Claude Code agentic. Without tools, Claude can only respond with text." With tools, the docs list what Claude can do: read code, edit files, run commands, search the web and work with outside services.

The model only asks for an action. The harness is the part that actually carries it out and reports back what happened.

It manages context

A model can only see a limited amount of text at once, called its context window. The harness decides what goes into that window. According to the Claude Code docs, Claude's context window holds conversation history, file contents, command outputs, CLAUDE.md, auto memory, loaded skills and system instructions.

When the window fills up, the harness has to make room. The docs say: "Claude compacts automatically, but instructions from early in the conversation can get lost." Compaction means summarizing older parts of the conversation to free up space.

LangChain's docs sum up this job in one line: "The job of a harness: get the model the right context at the right time for the given task."

It carries memory between sessions

Each new session with a model starts fresh. Anthropic's engineering post Effective harnesses for long-running agents says each new session "begins with no memory of what came before," and compares it to engineers working in shifts where each new engineer has no memory of the last shift.

Harnesses work around this with files the agent reads at the start. Claude Code uses a CLAUDE.md file for lasting instructions. In Anthropic's long-running agent experiment, the setup also used a progress log file (claude-progress.txt), the project's git history and a feature list file.

It controls permissions

Because the harness is what runs every action, it is also where rules about actions live: which actions run on their own and which ones stop and ask a person first. In Claude Code, for example, the Claude Code docs say permissions "control what Claude can do without asking." We cover this part in detail in our guide to AI agent permissions and approvals.

It checks the work

Verification is the third phase in the Claude Code loop. In Anthropic's long-running agent post, the team found that Claude tended to mark features complete without testing them end to end. Claude mostly did well at end-to-end checks once it was explicitly prompted to use browser automation tools and test "as a human user would." The post says these testing tools "dramatically improved performance."

Harness vs model vs framework

These three words often get mixed up.

  • The model is the trained AI system, such as a Claude, GPT or Gemini model. It reads text and writes text.
  • The harness is the working software around one model: the loop, tools, context handling, memory files and rules. Claude Code is a harness by Anthropic's own description.
  • A framework or SDK is a kit for building harnesses. LangChain describes its create_agent function as "a highly configurable harness" that developers shape with their own prompt, tools and middleware.

The lines can blur. Anthropic calls the Claude Agent SDK "a powerful, general-purpose agent harness" in its long-running agent post. Its Agent SDK overview also lists Managed Agents, described as "a hosted agent harness that runs the agent loop, with sessions in an Anthropic-managed cloud sandbox or a self-hosted sandbox on your own infrastructure."

Agent equals model plus harness: the harness holds the loop, tools, context, memory, permissions and checks

Why do people talk about harness engineering?

"Harness engineering" is the work of designing that surrounding layer. Two engineering posts, one from OpenAI and one from Anthropic, show what that work looks like.

OpenAI: humans steer, agents execute

In Harness engineering: leveraging Codex in an agent-first world, published February 11, 2026, OpenAI's Ryan Lopopolo describes a team that built an internal beta product with "0 lines of manually-written code." His summary: "Humans steer. Agents execute."

He writes that the engineers' job became to "design environments, specify intent, and build feedback loops that allow Codex agents to do reliable work." Early progress was slower than expected, "not because Codex was incapable, but because the environment was underspecified." When something failed, the team asked: "what capability is missing, and how do we make it both legible and enforceable for the agent?"

Anthropic: same model, different setup

Anthropic's long-running agent post describes two failure patterns. The agent tried to do too much at once, and a later session would see that some progress had been made and declare the job done.

Anthropic notes that compaction "isn't sufficient" on its own. The fix was a change in setup, not a new model:

  • A first session (the "initializer agent") creates an init.sh script, a progress log and a first git commit.
  • It also writes a feature list. For a test project, a clone of claude.ai, that meant over 200 features, all marked failing at the start.
  • Each later session works on one feature at a time, commits to git and updates the progress notes.

A footnote in the post makes the point plainly: the two "agents" differ only in their first user prompt. "The system prompt, set of tools, and overall agent harness was otherwise identical."

How Anthropic's long-running harness splits work: initializer session, then one feature per coding session

What does this mean if you use AI tools?

You do not need to build a harness to benefit from knowing what one is. A few practical points follow from the sources above.

  • Two apps can use the same model and still behave differently. What an app can read, change and check depends on its tools, context handling and rules, which are harness choices.
  • Lasting instructions belong in the files the harness reads. The Claude Code docs warn that early instructions can get lost when context is compacted, and suggest putting lasting rules in CLAUDE.md. OpenAI's harness engineering post describes a similar file, AGENTS.md, that "directs agents how to work in the repository." Our explainer on what AGENTS.md is covers it.
  • Long tasks go better in small steps with notes. Anthropic's experiment worked once the agent did one feature per session and left a progress log for the next one.
  • Approval prompts come from the harness. If an agent asks before it runs a command, that check is part of the software around the model.

Summary

An agent harness is everything around the model that turns text predictions into actions: the loop, the tools, context and memory handling, permissions and checks. LangChain's formula, "Agent = Model + Harness," is a useful shorthand. Anthropic and OpenAI engineering posts both describe cases where changing the setup around a model, not the model itself, made the agent do better work.

Sources

AgentsAI CodingExplainers