Agent Harness
Runtime de agente · Scaffolding
Escrito por Darjus Kazakevic · revisado el
The loop is the algorithm. The harness is the program around it.
The agent loop is about twenty lines. The program around it is much larger. It decides which folder the agent may touch, which tools exist, whether a command may run, how big a result may be, and where the transcript is saved. That program is the harness. Swap the model and you get the same product with different judgement.
The first decision is the trust boundary. A local harness runs on a developer's machine and borrows all of their access. A hosted harness runs in a container that has only what you give it. This choice decides whether your safety comes from a sandbox or from approval prompts.
En esencia — The harness is everything except the model call: workspace, tools, permissions, transcript and budgets. Most agent abilities, and most agent incidents, come from here.
Cuándo recurrir a él
Recurre a él cuando
- You run an agent loop and need one owner for workspace, tools and approvals
- The same agent runs on laptops and unattended in CI or the cloud
- Sessions are long, so crashes, resume and compaction matter
Reconsidéralo cuando
- A single prompt with no tools — there is no loop to host
- A fixed sequence you wrote yourself; keep it as plain code
- An existing harness already fits; building one is a whole product
The parts
- The workspace (The sandbox)
- The part of the world the agent may touch, and whether it can be thrown away. Locally it is usually the real repository, with no undo. In a hosted harness it is a disposable checkout in a container.
- The tool registry
- The tools available in this session — names, schemas, handlers — and, just as important, the ones that are not. It is the agent's list of abilities, so it is your security model whether you planned it or not.
- The permission layer
- The code between a requested tool call and its execution: allow-lists, deny rules, argument checks and approval prompts. Every tool must pass through it, or it protects nothing.
- The session
- The transcript and its lifecycle. It is saved so a crash at turn 40 loses nothing, resumable so a person can continue it, and compacted at a threshold the harness controls.
- The trust boundary (Local vs. hosted)
- Whether the agent borrows access that already exists or receives access you grant. A local harness inherits the developer's shell, keys and logged-in tools. A hosted one starts with nothing.
Reglas de diseño
- Decide the trust boundary first
- Local or hosted decides whether safety comes from a sandbox or an approval prompt, and whether a shell tool is safe to offer. Every other choice follows from it. Changing it later means rewriting the permission layer.
- Send every tool call through one check
- One place sees the tool name and its arguments and returns allow, ask or deny. A tool that reaches files or the network by its own path makes that check pointless. Share it between local and hosted runs.
- Cap every tool result
- The harness, not the model, controls how much text comes back. One uncapped read of a lockfile can push the task out of the context window. Cap by tokens, cut the middle, and say that you cut it.
- Save the transcript and enforce budgets
- Save every turn, so a crash at turn 40 loses nothing and you can see why the agent acted as it did. Enforce budgets for turns, tokens, time and money: any one of them can run away alone.
Errores habituales
- Blaming the model for a harness gap: a missing tool, a cut result, a denied approval.
- A local harness that inherits production credentials from the developer's shell.
- Approval prompts so frequent that people click through them without reading.
- A sandbox that checks the path text but not the resolved path, so ../ walks out of it.