Mhonn YbañezSRE, DevOps, AI Engineer
 Today I Learned
Read the full page

What is harness engineering?

Posted
Tags
ai, llm, agents

Claude Code and Claude Sonnet are two different products: one is the harness that does things, the other is the model that thinks. The model never touches a file. It asks for a tool, the harness runs it and sends back the result, and harness engineering is building everything around that loop.

It started with a thought that seemed obvious once I had it: Claude Code and Claude Sonnet are two entirely different products from Anthropic. I'd been using them as if they were one thing. Then I stumbled on the term "harness engineering," and I wanted to know what it actually meant.

The question I had

If the model only ever writes text, how does the tool around it know which files to read and which files to change? And what is harness engineering?

What I found

Two products, two jobs

ProductWhat it isWhat it does
Claude CodeThe harnessBuilds each request, runs tools, reads and writes files, asks me for permission
Claude SonnetThe modelReads everything the harness sends and decides what to say or do next

One way to see they're separate: Claude Code can also run other Anthropic models, like Opus or Haiku. Swap the model and the harness stays the same.

Where my epiphany came in

In my context window post I learned that the model remembers nothing between requests, and the app resends the conversation every time. That app is the harness. Its job is to gather everything the model needs into a single request. The model's job is to take all of it in and reason about it. The harness gathers, the model thinks.

The model never touches a file

This was the part I was most curious about. The model can't open a file, run a command, or save anything. It only produces text. So how does anything get done?

The answer is tool calling. With every request, the harness sends a list of tools the model is allowed to use. Each one has a name, a description, and the inputs it expects. When the model decides it needs a tool, it doesn't answer in plain prose. It replies with a structured tool call: the tool's name plus its inputs as JSON.

The harness doesn't guess from the wording. The reply comes back clearly marked as a tool call, in a fixed format that models are trained to produce. The harness reads it, runs the tool itself, and sends the result back.

What a tool call looks like

Simplified, one round trip looks like this:

// 1. The harness describes a tool in the request
{
  "name": "read_file",
  "description": "Read a file from the project",
  "input_schema": { "path": "string" }
}

// 2. The model replies with a tool call instead of text
{ "type": "tool_use", "name": "read_file", "input": { "path": "src/app.ts" } }

// 3. The harness runs it and sends the result back
{ "type": "tool_result", "content": "export function main() { ... }" }

Editing works the same way. The model asks for something like "in this file, replace this exact text with this new text," and the harness makes the change, often after asking me first.

How a tool gets made

A tool has two halves:

  • The definition: a name, a description, and the inputs it expects. This is the only part the model ever sees.
  • The code: what actually runs when the model calls it. This lives in the harness, and the model never sees it.

Tools don't have to wrap a command. They can just be code. Math is a good example. The model writes its answer one token at a time by predicting what comes next, so exact arithmetic over a long list of numbers is where it slips. Something like the p95 latency from my p99 vs average post is better handed to real code, which gets it exactly right every time.

A simple one, in TypeScript, looks something like this:

const percentile = {
  // What the model sees
  name: "percentile",
  description:
    "Calculate a percentile (like p95) from a list of numbers. Use this instead of doing the math yourself.",
  input_schema: {
    type: "object",
    properties: {
      values: { type: "array", items: { type: "number" }, description: "The numbers, in any order" },
      p: { type: "number", description: "Percentile from 0 to 100, for example 95" },
    },
    required: ["values", "p"],
  },

  // What the harness runs
  run({ values, p }: { values: number[]; p: number }) {
    const sorted = [...values].sort((a, b) => a - b);
    const rank = Math.ceil((p / 100) * sorted.length);
    return String(sorted[Math.max(rank - 1, 0)]);
  },
};

The model never does the math. It sends the numbers and p: 95, the harness runs run, and the model gets back a single number to work with.

There are a few ways tools end up in a harness:

  • Built in: the basics every coding harness ships with, like reading, editing, searching, and running commands.
  • MCP (Model Context Protocol): an open standard Anthropic released in late 2024. Anyone can build a small server that offers tools, and any harness that speaks MCP can use them. This is how a harness picks up tools for things like a database or an issue tracker without the harness itself changing.
  • Plugins: some harnesses have their own plugin system. DeepSeek Harness, which I get to below, is built entirely around it.

What surprised me is that the description is basically a prompt. The model picks a tool by reading its description, so a vague one gets ignored or misused. A good tool has a clear name, says when to use it, keeps its inputs narrow, and returns short results, since every result takes up room in the context window.

The loop

One message from me can turn into many requests:

  1. I type a message.
  2. The harness sends the model my message, the conversation so far, and the list of tools.
  3. The model replies with a tool call.
  4. The harness runs the tool and adds the result to the conversation.
  5. The harness sends everything back to the model.
  6. Steps 3 to 5 repeat until the model replies with plain text and no tool call.
  7. That text is the answer I see.

So how does it pick the right file?

Usually it doesn't know at first. It does what I would do: search for a name, list a folder, read what looks relevant, and only then edit. Each tool result lands in the context window, so the next decision is based on what it just saw. The harness also helps by loading project instruction files at the start, so the model begins with some idea of where things live.

So what is harness engineering?

It's designing everything around the model. The model is the same for everyone. The harness is where a product makes its choices:

  • Context: what goes into each request, and in what order
  • Tools: which ones exist, and how clearly they're described
  • The loop: when to keep going, when to stop, when to hand work to a helper agent
  • Permissions: what can run on its own and what needs my approval
  • Long sessions: summarizing older parts of the conversation when the window fills up
  • Project instructions: files that tell the model how a codebase works

Other harnesses

Claude Code isn't the only one. A few others I looked at:

  • OpenCode: an open source coding agent for the terminal. It works with models from many providers, not just Anthropic.
  • DSH (DeepSeek Harness): an open source agent harness from DeepSeek, still in developer preview. Its idea is that everything is a plugin, so tools, features, and even the interface can be swapped out.

They all run the same basic loop: send context and tools, get back a tool call, run it, send the result. What differs is everything around it.

The Claude Code leak

The clearest example of how much a harness matters came from Anthropic itself. A release of the Claude Code package was published with a source map, a file meant for debugging that let people rebuild the readable source code. Anthropic said it was a packaging mistake caused by human error, and that no customer data or credentials were exposed.

The model wasn't part of it. What leaked was the harness: the prompts, the tool definitions, the loop, and features that hadn't shipped yet. People spent days digging through it, which says a lot. A big part of what makes the product good lives outside the model.

Takeaway

The model decides, the harness does. Every file read and every edit is the harness carrying out a structured request from the model, and harness engineering is the work of making that loop give the model the right context, the right tools, and the right limits.