What is an AI harness, really?
Start with the simplest picture
Think about the first time you pasted a bug into ChatGPT in your browser.
It gave you a decent suggestion, so you copied the code, pasted it into your editor, ran npm test, got a new error, copied that error, pasted it back into the chat, and repeated that ten times.
Why did you have to do all that copy-pasting yourself? Because an AI model by itself can only do one thing: take text in, and send text out. It cannot open your folders. It cannot edit a file. It cannot run a terminal command. It is just a text predictor sitting on a server.
Now imagine you write a small program on your computer that sits between you and the AI model. You tell that program: “Fix the failing login test.”
Here is what happens next:
- Your program sends your request to the AI, along with a menu of actions it can ask for (like
read_file,edit_file, andrun_command). - The AI cannot open files itself, so it replies with a text request: “Please run
read_fileonsrc/login.ts.” - Your program reads that reply, actually opens
src/login.tson your laptop, and sends the file contents back to the AI. - The AI sees the bug and replies: “Please run
edit_fileon line 14 ofsrc/login.ts.” - Your program edits the file, runs
npm test, sees the test pass, and tells you the bug is fixed.
That program sitting around the AI model is the harness.
Without the harness, you have a chatbot. With the harness, you have a coding agent.
Humans use interfaces, AI models use harnesses
When you use a computer, you do not type raw system commands to check your email or open a folder. You use an interface: buttons, tabs, shortcuts, and windows. The interface turns your clicks into real code running on your machine.
An AI model cannot click a button or move a mouse. It can only output text. So instead of buttons, the harness gives the model a special text format for asking to run code, like this:
{
"tool": "read_file",
"args": { "path": "src/login.ts", "startLine": 1, "endLine": 40 }
}
On its own, that JSON does nothing. It is just text on a screen. The harness is the piece of software that watches for that format, runs the real code on your laptop, captures the output, and feeds that output back into the chat so the model can decide what to do next.
Wait: is Claude Code or Cursor a harness?
Kind of, and this is why the word confuses so many people.
Most coding tools you install have two parts packed into one app:
- The interface: the chat window, terminal UI, or diff viewer that you look at and type into.
- The harness: the invisible engine running underneath that talks to the model, parses tool calls, edits files, runs shell commands, and manages conversation memory.
Because both parts ship together, people casually call the whole app “the harness.” Separating them makes everything click: the same harness can power a terminal app, a desktop app, and an IDE plugin. And inside the same harness, you can swap the AI model without changing your tools.
The whole thing is just a while loop
People often imagine an AI agent as some mysterious black box. In reality, the core of almost every coding harness is a plain loop that keeps running until the model stops asking for tools:
export async function runAgent(userTask: string, maxSteps = 12) {
const messages = [{ role: "user", content: userTask }];
for (let step = 0; step < maxSteps; step++) {
const reply = await askModel(messages, availableTools);
// No tool calls means the model is ready to answer the user.
if (reply.toolCalls.length === 0) {
return reply.text;
}
for (const call of reply.toolCalls) {
const output = await runTool(call.name, call.args);
messages.push({
role: "tool",
name: call.name,
content: keepOutputShort(output, 4000),
});
}
}
throw new Error("Stopped after hitting the step limit.");
}
That is literally the engine behind a coding agent: ask the model -> run the tool it asked for -> hand back the result -> repeat.
Built-in tools vs MCP
Every harness starts with a basic toolbox for local work: reading files, searching text, editing code, and running terminal commands. Those tools run directly on your computer.
When you want the agent to reach outside your laptop, like reading a Jira ticket, querying a database, or inspecting a live browser tab, you connect an MCP (Model Context Protocol) server.
- Built-in tools are local functions baked into the harness.
- MCP servers are plugins that expose external data and actions over a standard protocol.
The AI model does not care where a tool came from. The harness puts both built-in tools and MCP tools into the same menu and routes each request to the right place.
Why the harness matters so much
Here is the part that surprises most developers: you can plug the exact same AI model into two different harnesses and get completely different results.
- If Harness A dumps 2,000 lines of raw test logs into the chat, the model gets confused and misses the real error.
- If Harness B trims the logs to the 10 failing lines, lets the model edit small patches instead of rewriting whole files, and runs
tsc --noEmitautomatically after every edit, the exact same model looks ten times smarter.
Think of the AI model as the engine and the harness as the car. A strong engine sitting on a garage floor goes nowhere. Put it inside a well-built car with good steering, brakes, and gauges, and suddenly it gets you where you want to go.
Next time an agent gives you a frustrating answer, check the harness before blaming the model. Half the time the model was fine, it just did not have the right file, a clean error message, or a fast test command to verify its own work.