Knaph

Tools and the Loop18 of 375 min read

The Program Around the Model

So far, "the program around the model" has turned up in every lesson: it keeps the conversation, writes the system prompt, sends the tool list, runs the tools and keeps the loop going. It's time it had a proper name, because it's the part of an agent you can actually change.


Leila So when I use Claude Code, I'm using Claude. The model.

Omid You're using Claude, yes. Is Claude Code the same thing as Claude?

Leila I assumed so. Same name.

Omid Let's test it. Claude also answers in the Claude app on your phone. Can the phone app edit files in your project folder?

Leila No.

Omid Can the same Claude model, inside Claude Code, edit them?

Leila Yes. So the difference isn't the model. It's everything around it: the tools it's given, the system prompt, the loop.

Omid Right. Claude Code is the program around the model. People call that program the harness.

Leila Like a horse's harness? Something that lets the power be used for work.

Omid That's the picture. The model is the strength; the harness points it at a job and keeps it under control.


What the harness does

The harness is everything in an agent except the model itself. It does all the jobs you've met so far, and a few more:

  • runs the loop: sends requests, reads replies, decides when the session is over;
  • holds the tools and runs them: reading files, editing, running commands, searching the web;
  • writes the system prompt and the tool descriptions;
  • builds the context: what goes into each request, in what order, and what gets compacted when the window fills;
  • decides what's allowed: which actions need your permission and which are blocked;
  • talks to you: the screen you type in, the progress it shows, the questions it asks;
  • keeps records: saving sessions so you can come back to them.

The model in the middle, surrounded by the harness: the loop, the tools, the system prompt, building the context, permissions, the screen you use, and saved sessions.

A useful way to divide the work: the model decides what to do; the harness decides what's allowed, carries it out, and remembers. The model is the same for millions of people; the harness is where an agent's own character comes from.

Same model, different harness

Because so much lives in the harness, the same model can behave very differently in different ones. Claude in the Claude app is a chat assistant; Claude in Claude Code is a coding agent; Claude in a company's own app might be a careful assistant that can only read one database. And the same harness can run different models: Claude Code lets you switch between a faster, cheaper model and a slower, stronger one in the middle of your work.

One model, two harnesses. In a chat app's harness, it can only reply with text. In a coding agent's harness, it has tools for files and commands, and a loop.

This also tells you where to look when an agent disappoints you. Sometimes the model really isn't up to the task. But often the problem is in the harness: a missing tool, a cluttered context, a permission it didn't have, an instruction it never saw.

Where an agent runs

The harness also decides where the tools act. Claude Code usually runs on your own computer, so its tools work on your own files, with your own permissions. Other agents run in the cloud, inside a sandbox: a closed-off computer of their own where they can't reach anything else. Which one you're using matters for what the agent can see, and what it could damage.

Programmers who want this kind of harness in their own programs can use the Claude Agent SDK, which offers the same loop, tools and context handling as Claude Code, as a library to build on.

The rest of this course

Every module from here on is about a part of the harness that you can shape:

  • Giving an agent knowledge: what the harness loads into the context for you: instruction files, memory, and skills that load only when needed.
  • Keeping an agent in check: what the harness lets happen: permissions, hooks that run every time, and planning before acting.
  • Many agents, many tools: helper agents with their own context, and a standard way to plug in new tools.
  • Using agents well: what it costs, what can go wrong, and how to hand over a task.

Try it

If you have Claude Code, type /model to see which models this one harness can use, and /help to see the harness's own commands: none of them are the model. Then think of the AI tools you use: the chat app, the agent, an assistant built into an office app. Which do you think use the same model, in a different harness?

Using it well

  1. When an agent fails, ask which part failed. Was it the model's judgement, or the harness: a missing tool, a crowded context, a blocked action? The fix is different.
  2. Learn your harness, not just your model. Its commands, settings and files are where you have real control, and they work the same whichever model you choose.
  3. Know where your agent runs. On your computer, it can touch your files; in a sandbox, only its own. Choose according to the task.

Words to know

  • harness - everything in an agent except the model: the loop, the tools, the system prompt, building the context, permissions, the screen, saved sessions
  • sandbox - a closed-off space where an agent's tools run, cut off from everything else
  • Claude Agent SDK - a library that gives programmers the same harness as Claude Code, to build their own agents

Big idea

An agent is a model plus a harness. The model decides what to do; the harness decides what's allowed, carries it out and remembers. Most of what you can change about an agent lives in the harness.

Watch this lesson

3 minPart of episode 4 (9 min)Watch the whole episode

Test your understanding

Sign in to test your understanding of this lesson and track your progress.