CHAPTER 01 · What Is an Agent Harness? · 4 / 6
A tiny illustration
There is no real MVP for this chapter, because the harness is the thing we spend the whole book building. But here is the shape of the split in code, just to make it concrete. Notice how little the "agent" knows how to do on its own.
# The model is just a function: text in, text (or a tool request) out.
# It cannot do anything else. Everything else is the harness's job.
def call_model(prompt: str, tools: list) -> dict:
"""Stand-in for an API call to Claude or GPT.
Returns either {"type": "text", ...} or {"type": "tool_call", ...}.
The model NEVER runs the tool itself; it only asks."""
...
# The harness is everything around that function: it owns the files,
# the shell, the permissions, the memory, and the loop.
class Harness:
def __init__(self):
self.tools = {} # Ch 6: what the model is allowed to ask for
self.history = [] # Ch 3: the conversation so far
self.memory = "" # Ch 9: persistent project knowledge
self.permissions = {} # Ch 7: what may run without asking
def run(self, user_request: str):
# Ch 2 turns this comment into a real loop. For now, just note
# that the harness, not the model, is in the driver's seat.
...
The model is a single stateless function. The Harness class is where all the chapters live. Every later chapter fills in one of those attributes or methods.