The Harness Matters More Than the Model: Building One From Scratch
The harness — not the model — decides what an agent can see, what it can do, and when it must stop, which is to say the harness decides almost everything.
Quick Navigation
Difficulty: Intermediate
Estimated Time: 10-15 minutes
Prerequisites: Basic Python, familiarity with LLM APIs, understanding of JSON and function calling, conceptual grasp of AI agents
Swap a mediocre model into a good harness and you often beat a great model wired up carelessly. The harness — not the model — decides what an agent can see, do, and when it stops. Here are its six parts, each in about twenty lines of Python.
Ask most people what an "AI agent" is and they'll point at the model. GPT, Claude, Llama — the brain doing the thinking. But a raw model is a stateless function: text in, text out. It has no memory of your last message, no way to run a calculation, no ability to decide it's finished. Everything that makes an agent act lives outside the model, in a layer engineers call the harness.
The harness is unglamorous. There's no research paper for it, no leaderboard. Yet swap a mediocre model into a good harness and you often beat a great model wired up carelessly. The harness decides what the model can see, what it can do, and when it must stop — which is to say, the harness decides almost everything.
This article breaks a working harness into its six load-bearing components and shows each one as runnable Python. By the end you'll have a mental model precise enough to build your own, or to debug the one you already have.
The Six Load-Bearing Components
The harness wraps the model with six components, arranged around it as shown in the article's architecture diagram:
- Model Client — the interface that sends prompts to the model and receives its completions.
- Tools — the external functions and capabilities the model can invoke to act beyond text.
- Executor — the layer that actually runs the tool calls the model requests.
- Control Loop — the logic that iterates: prompt, act, observe, repeat, until a stopping condition is met.
- Memory / State — what carries context across turns so the agent isn't a stateless function.
- Guardrails — the constraints that bound what the agent is allowed to see, do, and output.
Tags: #AIAgent #AI #Programming #LLM #Python