The anatomy of an AI agent: what the harness is and its pieces

The anatomy of an AI agent: what the harness is and its pieces
5kinds of components that make up a harness
6pieces derived from what we want the agent to do
30 → 5LangChain's agent's place on Terminal Bench 2.0
52.8 → 66.5points with the same model, changing only the harness
The anatomy of an AI agent: what the harness is and every piece inside it
I also cover it in this video of about fifteen minutes, on my Articulator EN channel.

Agent = model + harnesslink

The idea fits in one formula: agent = model + harness. And it comes with an easy rule to remember: if you're not the model, you're the harness.

The formula on screen: agent equals model plus harness.
The article's whole thesis, in one line.

A harness is all the code, configuration, and execution logic that isn't the model. A raw model doesn't act as an agent. It starts to become one when the harness gives it state, tool execution, feedback loops, and enforceable constraints.

Concretely, a harness includes five things:

  • System prompts. The starting instructions.
  • Tools, skills, and MCP servers, along with their descriptions.
  • Bundled infrastructure: file system, sandbox, and browser.
  • Orchestration: spawning subagents, splitting up the work, and choosing a model.
  • Hooks or middleware: deterministic steps, like compacting, keeping the agent going, or running the linter.
The brain, the model, connected to five columns: system prompts, tools, infrastructure, orchestration, and hooks.
The five components around the model.

The cleanest boundarylink

There are many messy ways to split the model from the harness. Vivek argues for this one as the cleanest, because it forces us to think about how to design systems around the model's intelligence. From there, the article works backwards to why each piece exists.

The model inside a circle and the harness outside it: design systems around the intelligence.
Everything outside the circle is the harness.

The article sums it up in a diagram. In the center is the model, which reasons and decides. Context comes in from above: prompts, memory, skills, and the conversation. On the right it acts: it calls bash, tools, and MCP servers, and the results go back into its context. Below, it persists: it writes and reads files, git, and progress files. On the diagonal it observes and verifies, with browser screenshots, test results, and logs. And on the left is control: compaction, orchestration, and Ralph loops.

Diagram with the model in the center surrounded by context, action, persistence, observation, and control, all inside an orange frame: the harness.
The article's diagram, redrawn: the whole orange frame is the harness.

Why you need a harnesslink

Put yourself in the model's place. Most take in data, like text, images, audio, or video, and return text. That's it. Out of the box, they can't:

  • Keep durable state across interactions.
  • Run code.
  • Access real-time knowledge.
  • Set up environments and install packages to finish a job.
The brain next to four crossed-out cards: durable state, run code, real-time knowledge, and set up environments.
Four things a model can't do by itself.

All of those are harness features. And you've almost certainly used one without knowing it: to chat with a model, we wrap it in a while loop that stores the previous messages and adds each new one of yours. That feeling of having a conversation doesn't come from the model. It comes from that loop.

The code of a chat, a while loop that keeps storing messages, with the stamp: the loop creates the experience.
A chat from the inside: a few lines of harness.

Working backwardslink

That leads to the central idea: turn the behavior we want from the agent into a real feature of the harness. That's what harness engineering means. It's used to inject prior knowledge that guides the agent and, as models get more capable, to extend and correct them with surgical precision.

That's why the article always follows the same pattern: first, the behavior we want; then, what the harness adds to achieve it. You end up with six pairs. It's not meant to be exhaustive: what matters is that each piece comes from something the model can't provide by itself.

A six-row table that pairs what we want from the agent with what the harness adds.
Figure from the article, adapted: each behavior with its piece.

Since this is about anatomy, in the video I assemble those six pieces into a body, and I keep that image here because it helps you remember them. The model is the brain. The metaphor is mine, not the article's.

1. Files: the skeletonlink

We want the agent to work with real data, store what doesn't fit in context, and keep its work between sessions. But the model only operates on what's inside its window. People used to copy and paste by hand, which is clunky and useless for an autonomous agent.

The solution came naturally. The world already worked with files, so models were trained on billions of tokens that show how to use them. That's why harnesses ship with a file system and tools to handle it. Vivek considers it perhaps the most foundational piece, because of what it unlocks:

Workspace

The agent has somewhere to read data, code, and documentation.

Outside the context

It can store intermediate results instead of holding everything in the window, and keep state that outlasts the session.

Collaboration

Multiple agents and people can coordinate through shared files.

Three cards: workspace, outside the context, and collaborate.
What a file system unlocks.

Add git and it also gets versions: it tracks its work, reverts mistakes, and tries experiments on branches. This piece is worth remembering, because several of the next ones rely on it.

A line of commits with an error, the revert, and a branch to try something else.
Files plus git: versions.

2. Bash and code: the handslink

We want the agent to solve problems by itself, without anyone designing every tool for it first. The usual pattern today is the ReAct loop: the model reasons, acts by calling a tool, observes the result, and repeats.

The ReAct loop: reasons, acts, observes, and repeats, around the brain.
The ReAct loop.

But the harness can only run the tools it has logic for. Instead of programming one for every possible action, it's better to give it a general-purpose one: bash. That way the model solves problems on its own by writing and running code.

It's a big step towards giving it a computer and letting it figure out the rest. It's no longer tied to a fixed set of tools: it designs its own on the fly. Harnesses still ship with others, but running code is now the default strategy.

A terminal where the agent writes and uses its own tool, shrink.py, next to the skeleton with its hands lit up.
The agent builds the tool it's missing.

3. Sandboxes: the skinlink

It can now store and run code, but all that has to happen somewhere. Running what an agent generates on your own machine is risky, and a single local environment doesn't scale as the agent workload grows.

A laptop with a warning sign and dozens of connected agents: a single environment doesn't scale.
A single local environment: risky and it doesn't scale.

The answer is sandboxes, isolated and safe environments. The harness connects to one to run code, inspect files, and install dependencies. If you want more security, it allows only a list of commands and isolates the network. They also scale: they're created on demand, shared across many tasks, and destroyed when done.

Good environments come with good tools out of the box, and configuring them is the harness's job: preinstalled languages and packages, command-line tools for git and tests, and browsers to use the web and check the work. Browsers, logs, screenshots, and test runners let it observe its own work, and that's how self-verification loops are born: it writes the code, runs the tests, reads the logs, and fixes the errors.

The self-verification loop: writes, tests, reads, and fixes, next to a terminal with passing tests.
A self-verification loop.

Out of the box, the model doesn't set up its own environment. Where it runs, what tools it has, what it can access, and how it verifies its work are all design decisions of the harness.

Four questions stamped with the harness: where it runs, what tools, what it can access, and how it verifies. Next to them, the body with its skin lit up.
Four decisions the model doesn't make.

4. Memory and searchlink

We want it to remember what it has seen and to access what didn't exist when it was trained. But a model only knows what's in its weights and its current context. Since we can't edit those weights, the only way to add knowledge is to inject it into the context.

For memory, files are the foundation again. Harnesses support standards like AGENTS.md, which gets injected at startup. When the agent edits it, the harness loads the new version. It's a form of continual learning: what it saves in one session reaches the next ones.

An agent edits AGENTS.md in session 1 and another loads the new version in session 2: continual learning.
What it learns in one session reaches the next.

Then there's the knowledge cutoff. The model doesn't know, for example, the latest version of a library unless you give it. Web search and MCP tools like Context7 bring in what didn't exist when its training ended, so they're worth building into the harness.

A timeline cut by the knowledge cutoff; web search brings the new versions of a library to the brain.
Search jumps over the cutoff.

5. Context rot: the immune systemlink

Context rot is this: models reason worse and complete tasks worse as their window fills up. That space is a valuable, scarce resource, so the harness needs strategies to manage it. Vivek sums it up in one strong sentence: today's harnesses are, to a large extent, delivery mechanisms for good context engineering.

The window at 97%, a falling curve, and a rotting pumpkin: a valuable, scarce resource.
A diagram, not a measurement: the fuller the window, the worse it reasons.

The article names three techniques:

  1. Compaction. What happens if the conversation exceeds the window? One option is for the API to return an error, and that's not good. So the harness intelligently offloads and summarizes what's there, and the agent can keep working.
  2. Offloading tool outputs. Huge outputs fill the context with noise without adding anything useful. If one goes over a certain token threshold, the harness keeps the start and the end and saves the full text to a file, in case the model needs it.
  3. Skills. Having too many tools or MCP servers loaded at startup makes it perform worse before it even begins. Skills avoid that with progressive disclosure: only their header is loaded at the start. The model didn't choose this; it's the harness protecting it.
The context window after compacting, with a summary at the top and free space below: keeps working.
Compaction: a summary instead of the whole conversation.
A huge output keeps its start and end; the full text moves to a file.
Offloading: the start and the end stay; the rest goes to a file.
On the left, the window full of tools at startup; on the right, only the skills' headers. Next to them, the body.
Progressive disclosure: at the start, only each skill's header.

If you want to go deeper, I cover this in my posts on context compression, context management, and context engineering.

6. Long-running work: the heartlink

Building software autonomously is the holy grail of coding agents. But today's models stop too early, struggle to break down complex problems, and lose coherence as the work stretches across several windows. A good harness has to design around all of that.

Three cards: stop too early, struggle to break down, and lose coherence.
The three problems models have on long tasks.

This is where the earlier pieces start to come together: working long-term requires durable state, planning, observation, and verification.

  • Files and git to track the work. On a long task, an agent produces millions of tokens. Files keep that progress, and git lets a newcomer catch up right away. For multiple agents, it's also a shared ledger.
  • The Ralph loop to keep it going. When the model tries to finish, a hook intercepts that exit and reinjects the original prompt into a clean context window. It's forced to keep going until it meets the goal. It doesn't start from zero because each round begins with fresh context but reads from the files the state the last one left.
  • Planning and verifying to stay on course. The model breaks the goal down into steps, and the harness supports it with good prompts and reminders about how to use a plan file. After each step, hooks can run a test suite and, if it fails, hand back the error. It can also be asked to evaluate its own code independently.
A hook, a robot forced to keep going, and a clean window with the original prompt, until it meets the goal.
The Ralph loop: the original prompt again, in a clean window.
Three rounds in a row reading the same progress.md, next to the body with its heart lit up.
Each round starts clean but reads what the last one left.
A goal and a plan file with the steps checked off one by one: check each step.
The plan lives in a file, and every step gets checked.

Verification anchors the solution in those tests and creates a signal to improve with.

The whole bodylink

It's all assembled now. The skeleton of files and git. The hands of bash and code. The skin of the sandbox. The memory and search. The immune system against rot. And the heart, which keeps beating until the work is done. Each part came from something the brain couldn't do alone.

The full body with each piece labeled: skeleton, immune system, hands, memory, heart, and skin.
The full anatomy of an agent.

Model and harness, trained togetherlink

Products like Claude Code and Codex are post-trained with the model and the harness in the loop. That helps the model improve at what its designers think it should do well natively: working with files, running bash, planning, or splitting work among subagents.

That creates a cycle: a useful piece is discovered, added to the harness, and used to train the next generation. As it repeats, the model gets more and more capable, but inside the harness it was trained in.

The cycle: discover a piece, add it to the harness, train the next model, and the model improves, only inside that harness.
The cycle between harness design and training.

This co-evolution has a side effect: if you change a tool's logic, it performs worse. The example is apply_patch, the utility Codex uses to edit files. Its guide recommends using that exact implementation, because the model was trained on that format. Something truly intelligent would switch methods without trouble; training this way causes overfitting.

A padlock, a low performance bar, and the quote from the Codex guide: we recommend using our exact implementation.
The model gets used to one specific tool.

Even so, the best harness for your task isn't necessarily the one the model was trained with. Terminal Bench 2.0 is a good example: according to the article, when it was written, Opus 4.6 in Claude Code scored far below the same Opus 4.6 in other harnesses. I couldn't verify this: the Terminal Bench page now shows a different version.

Two bars with the same model on top: a low one for Claude Code and a high one for other harnesses.
A diagram, no figures: the same model performs differently depending on the harness.

LangChain tested this with its own coding agent: it went from 30th place to the top 5 by changing only the harness, from 52.8 to 66.5 points, without touching the model (GPT-5.2-Codex). There's a lot of room to improve if you optimize it for your task.

A ranking with LangChain's agent in fifth place, 66.5 points, and the model untouched.
Same model, different harness.

Where it's headinglink

As models improve, part of what lives in the harness today will end up inside them. They'll plan, verify themselves, and stay coherent better on their own, and they'll need less injected context. That suggests the harness will matter less and less.

But Vivek believes it will stay useful, just as prompt engineering still is today. It's true that harnesses patch over shortcomings, but they also build systems around the intelligence. A well-configured environment, good tools, durable state, and verification loops make any model more efficient, whatever its level.

Environment, tools, state, and verification next to three bars: they make any model more efficient.
A diagram, no figures: the harness helps whatever the model's level.

That's why it remains a very active research area. At LangChain they use it to improve their deepagents library, and they cite three open problems:

  • Orchestrating hundreds of agents in parallel on the same codebase.
  • Getting agents to analyze their own traces to find and fix harness failures.
  • Harnesses assembled on the fly, with just the right tools and context for each task, instead of being preconfigured.
Three cards with the open problems: hundreds of agents, analyzing their traces, and harnesses assembled on the fly.
The three open problems LangChain cites.

In shortlink

Each piece of the harness exists because of something the model can't do alone: store, act, run safely, remember, keep its context clean, and keep working. And since the model is trained inside a harness, changing that harness can achieve more than changing the model.

In one sentence

The model holds the intelligence, and the harness is the system that makes it useful.

Which piece of the harness has paid off the most for you?

Sourceslink

Continue reading

Last posts -->

Have you seen these projects?

Gymnasia

Gymnasia Gymnasia
Expo
React Native
TypeScript
OpenAI
Anthropic

Fitness app with two agents that run entirely on the device, with no backend, so the user's data never leaves the phone. A BYOK conversational coach with local tools and a remote system prompt with offline fallback, plus a food estimator that pulls macronutrients out of a photo of the plate, with barcode scanning against OpenFoodFacts.

LangGraph Deep Researcher

LangGraph Deep Researcher LangGraph Deep Researcher
Python
LangGraph
FastAPI
React
TypeScript
Docker

Multi-agent research system built with LangGraph. A supervisor breaks your question down into topics and launches search sub-agents in parallel; each one compresses its findings before handing them to a writer agent that produces the final sourced markdown report. Live streaming over WebSockets, a configurable model per role and bring-your-own API keys that are never persisted server-side.

Tau

Tau Tau
Python
LangChain

Multi-agent tutoring system for secondary school students, with one agent per subject and course material written and validated by a team of teachers. It was used with real students at a private school in Spain and at a secondary school in Colombia.

View all projects -->
>_ Available for projects

Do you have an AI project?

Let's talk.

maximofn@gmail.com

Machine Learning and AI specialist. I develop solutions with generative AI, intelligent agents and custom models.

Do you want to watch any talk?

Last talks -->

Do you want to improve with these tips?

Last tips -->

Use this locally

Hugging Face spaces allow us to run models with very simple demos, but what if the demo breaks? Or if the user deletes it? That's why I've created docker containers with some interesting spaces, to be able to use them locally, whatever happens. In fact, if you click on any project view button, it may take you to a space that doesn't work.

Flow edit

Flow edit Flow edit

FLUX.1-RealismLora

FLUX.1-RealismLora FLUX.1-RealismLora
View all containers -->
>_ Available for projects

Do you have an AI project?

Let's talk.

maximofn@gmail.com

Machine Learning and AI specialist. I develop solutions with generative AI, intelligent agents and custom models.

Do you want to train your model with these datasets?

short-jokes-dataset

HuggingFace

Dataset with jokes in English

Use: Fine-tuning text generation models for humor

231K rows 2 columns 45 MB
View on HuggingFace →

opus100

HuggingFace

Dataset with translations from English to Spanish

Use: Training English-Spanish translation models

1M rows 2 columns 210 MB
View on HuggingFace →

netflix_titles

HuggingFace

Dataset with Netflix movies and series

Use: Netflix catalog analysis and recommendation systems

8.8K rows 12 columns 3.5 MB
View on HuggingFace →
View more datasets -->