Let me start with a fact that surprises most people learning about AI: a language model, on its own, cannot actually do anything.

It can’t open a file. It can’t run your code. It can’t search the web, check a result, or click a button. A raw model does exactly one thing, and only one thing: you give it text, and it gives you text back. That’s the whole of it. It’s astonishingly good at that one thing, good enough to write essays, explain ideas, and reason through problems, but it is still just text in, text out.

So here’s the puzzle. If a model can only read and write text, how do “AI agents” fix bugs, book flights, run commands, and get real work done? Something else must be doing the actual doing. That something has a name, and it’s the piece almost nobody explains clearly: the harness.

This post is a from-scratch walkthrough of exactly what a harness is and how it works. You only need basic AI knowledge to follow along. By the end, the whole thing will feel obvious, and you’ll understand the machine that turns a text-predictor into an agent that acts.

The one thing a model can do

First, let’s really sit with the limitation, because the harness exists entirely to work around it.

text in the model text out
That's all. It cannot open files, run code, browse, or check anything in the real world.
A model is a text-to-text machine. Powerful, but sealed off from the world. It can describe how to fix your code, but it cannot open your code, try the fix, or see if it worked. Every real action an "agent" takes happens outside the model.

The brain-in-a-jar picture

Here’s the mental image that makes everything click. Picture the model as a brain in a jar: brilliant, full of knowledge, able to think and reason, but with no eyes, no hands, no way to touch the world. It can decide “I should open that door,” but it has no arm to reach out and turn the handle.

The harness is the body you build around that brain. It’s the eyes that show the brain what’s happening, and the hands that carry out what the brain decides. The brain thinks; the body acts. Neither is useful alone. Together, they get things done.

The model (the brain)

Thinks, reasons, decides what should happen next. But it can only express that decision as text. It has no way to actually carry it out.

The harness (the body)

Reads the brain's decision, actually performs it in the real world, a file gets read, code gets run, then reports back what happened.

The model is the thinker; the harness is the doer. When you hear "AI agent," what you're really looking at is a smart brain (the model) wrapped in a capable body (the harness). The harness is all the software that isn't the model.

So what is a harness, in one line?

A harness is a loop of software that runs around the model, letting it take actions and see the results, over and over, until a task is done.

That word loop is the heart of it. The harness doesn’t call the model just once. It calls it, does what the model asked, shows the model the result, and calls it again with that new information. Round and round. Let me show you exactly what happens in one trip around that loop.

The loop, step by step

Here is the entire machine, in six steps. Read it once and you’ll understand more about agents than most people do.

1
Gather the input. The harness bundles together the instructions, the list of actions the model is allowed to take, and everything that's happened so far. This whole bundle becomes the text sent to the model.
2
Ask the model. The harness sends that bundle to the model and gets text back. This is the "thinking" step.
3
Read what the model wants. The harness looks at the reply. Is it a final answer for the user? Or is it a request to take an action, like "read this file"?
4
Do the action. If the model asked to take an action, the harness actually performs it, safely, and captures the result.
5
Show the model the result. The harness adds that result to the running history, so next time the model can see what happened.
6
Loop or stop. If the model gave a final answer, stop and show the user. Otherwise, go back to step 1 with the new information. Repeat until done.
Six steps, and step six sends you right back to step one. That circle is the harness. Notice the model only ever reads and writes text (steps 2 and 3). Every actual action in the world (step 4) is done by the harness, not the model. That division is the entire trick.

The key decision: is it an answer, or an action?

Step 3 is the clever pivot of the whole loop, so let’s zoom into it. Every time the model replies, the harness has to decide one thing: did the model just give a final answer, or is it asking to use a tool?

the model just replied... what kind of reply is it?
final answer
Plain text meant for the user. The harness shows it and the loop ends. Done.
tool request
The model is asking to take an action. The harness runs it, feeds back the result, and loops again.
This one fork drives the whole loop. A final answer means "I'm finished, here's the result." A tool request means "I'm not done, please do this for me and tell me what happened." The harness reads every reply and routes it down one of these two paths.

Watch it work: fixing a broken test

Abstract steps are easier to believe once you see them play out. Say you ask an agent: “my Python test is failing, fix it.” Here’s the actual back-and-forth between the model and the harness, one loop at a time.

model:"I need to see the test first. Please read test_app.py."
harness:reads the file, sends its contents back to the model
model:"I see it. Now run the tests so I can see the error."
harness:runs pytest, feeds the error message back
model:"The bug is a missing 'await' on line 12. Editing it now."
done:harness applies the edit, reruns tests, all pass. Reports success.
Every line where the model "does" something, it's really just asking; the harness does the actual work and reports back. The model never touched a file. It reasoned, requested, and reacted to real results. Without the harness, the model could only guess a fix and hope. With it, the model sees the real error and fixes the real bug.

This is the sentence worth remembering: the intelligence is in the loop, not in the tools. The tools are simple (read a file, run a command). The magic is that the model gets to see each result and decide the next move, again and again.

The parts that make up a real harness

The loop is the skeleton. A real, working harness adds a few more parts, each one solving a specific limitation of the bare model. Here they are in plain terms.

the rules
System promptThe standing instructions: who the agent is, how it should behave, what it must never do. Set once, applies always.
the hands
ToolsThe specific actions the agent is allowed to take: read a file, run code, search the web. The harness decides which exist.
the memory
MemoryKeeps track of what's happened so the agent doesn't forget earlier steps or repeat itself on long tasks.
the workspace
Execution environmentThe safe place where tools actually run: a sandbox, a container. Without it, actions have nowhere to happen.
the safety
GuardrailsThe limits: a cap on steps so it can't run forever, permission checks, a human sign-off before risky actions.
the black box
ObservabilityA record of every step, every action, every error, so a human can see what the agent did and why.
Six parts, six jobs. The system prompt sets the rules, tools are the hands, memory is the notebook, the environment is the workshop, guardrails are the safety rails, and observability is the flight recorder. Stack these around the loop and you have a real, trustworthy agent.

When do you even need one?

Not every use of AI needs a harness, and it’s worth knowing the line. If you just want the model to write something once, a summary, an email, an explanation, you don’t need a harness at all. You ask, it answers, done.

You need a harness the moment the task requires the model to act and react over time:

You DON'T need a harnessYou DO need a harness
Write me an emailRead my inbox and reply to the urgent ones
Explain how sorting worksFix the failing test in my project
Summarize this textResearch a topic across many web pages
One question, one answerA goal that takes many steps and real feedback
The rule of thumb: if the job is "text in, text out, once," the bare model is enough. If the job needs the model to take actions, see results, and adjust, again and again, you need the loop. That loop is the harness.

The takeaway

Here’s the whole idea, tied up. A language model is a brilliant brain in a jar: it can think, but it can’t touch the world. The harness is the body you build around it, a loop of software that takes the model’s decisions, actually carries them out, shows the model what happened, and asks it again, over and over until the job is done. The model supplies the thinking. The harness supplies the doing.

So the next time you watch an AI agent fix a bug, book a trip, or work through a task step by step, you’ll know the real shape of what’s happening underneath. It isn’t one magic super-brain. It’s a plain, understandable loop, patiently letting a text-predictor act, look, and act again. That loop is the quiet engine behind every AI agent you’ll ever meet, and now you understand it exactly.

← Back to blog