AI Agent Harness Explained: Building Coding Agents Like Stacking Blocks
This article breaks down the agent harness from an engineering perspective: what it is, the six responsibilities it carries, and four distinct paradigms (standard, code-based tool orchestration, minimal baseline, and mode creation) that wrap the same model in different shells. It also explains why full trajectory logging matters for observability and postmortems, how to evaluate a harness across four dimensions, and a practical order for building or selecting a coding agent tool for your team.
When the industry focuses on model capability, what actually determines whether an agent can deliver reliably in real engineering work is often the “harness” layer outside the model. This article dissects the responsibilities of an agent harness from an engineering perspective, analyzes the scenarios suited to four paradigms—standard execution, code-based tool orchestration, a minimal baseline, and mode creation—explains why full trajectory logging matters for observability and postmortems, and outlines a practical path and evaluation method for building a coding agent tool.
1. The Underrated Layer: What Is an Agent Harness
The term “harness” borrows the image of tack: the reins themselves generate no power, but they determine whether that power can be constrained into a usable direction. In the agent context, the harness refers to the entire engineering system outside the model—the part responsible for letting the model read files, call tools, manage context, retry after failures, and stay continuously productive for hours.
A frequently cited division of labor is this: the model is the soul of the agent, while the harness lets the agent understand its situation, use tools, and keep working in a real environment. This split is valuable in engineering because it separates “capability” from “usability” into two variables that can evolve independently. Models iterate in months; harnesses iterate in days. The former sets the ceiling, the latter sets the floor.
After coding agents proved commercially viable, this layer quickly became contested ground for every model team, and some companies have formed teams dedicated to the harness layer. The reason is straightforward: the same model paired with different harnesses can differ by an order of magnitude in completion rate on real repositories.
2. What the Harness Layer Actually Does
Broken apart, the harness contains at least six responsibilities, each independently optimizable:
- Context assembly: deciding which files, which history, and which rules to inject into the window each turn. This is the first lever on both cost and quality.
- Tool exposure: at what granularity and with what descriptions file editing, command execution, retrieval, and other capabilities are handed to the model.
- Execution and isolation: where commands run, where the permission boundary sits, and how failures roll back.
- State and memory: the task list across turns, goal progress, and what is done versus what still needs verification.
- Orchestration and concurrency: scheduling the main agent and sub-agents, and merging parallel tasks.
- Observability and recovery: recording everything the model sees, and supporting session restore, forking, and replay.
Note that the first five determine whether the work gets done, while the last determines whether it keeps getting done. In practice, the last one is often deferred and then patched in after the first production incident.
3. An Unusual Product Shape: Local Execution, Browser Interface
Open this kind of tool and the common form is a web-based coding agent: a session list on the left organized by workspace, where one workspace maps to one local project directory; a conversation area in the middle where the user states a request and the agent reads files, writes code, and runs commands, with every tool call laid out on a timeline.
The overall feel sits between a command-line agent and a web IDE, but the key difference is that computation runs on the user’s own machine while the interface opens in a browser. This split of “local execution plus remote interface” brings three direct benefits: code never has to leave the local environment; the interface can be accessed across devices; and the execution environment is the dependency and toolchain set the user already knows.
Free, open source, locally run, and traceable process—stacked together, these four properties make it look like a well-designed general-purpose coding agent baseline. But what is really worth expanding on is its mode design.
4. Four Modes: One Model, Four Harnesses
Such tools typically ship with multiple working modes, which are essentially different harnesses adapted to different tasks:
- Standard mode: the full capability set, including file editing, command execution, local and web retrieval, skill extensions, task planning, goal management, and sub-agent and workflow orchestration. Suited to end-to-end changes in real business repositories.
- Code-based orchestration mode: tools are exposed to the model through a code-mode SDK, so the model no longer makes round trips one call at a time. Instead it writes a program directly, collapsing what would have taken ten back-and-forth tool operations into a single execution. Illustration:
// Pseudocode: collapse multiple tool round trips into one programmatic executionconst files = await listFiles({ dir: "src/api" });const targets = files.filter(f => f.endsWith(".ts"));for (const f of targets) {const src = await readFile({ path: f });if (!src.includes("deprecated")) continue;await writeFile({ path: f, content: src.replace(/deprecated/g, "legacy") });}const report = await runTests({ scope: "src/api" });return report.summary;
Its value is shifting “orchestration cost” from the model side to the runtime side: loops, filtering, and conditional branches are expressed by the program, and the model’s tokens are spent only on decisions.
- Minimal mode: subtraction, keeping only one persistent command environment and one file editor—two tools. Its official purpose is benchmarking the model: strip away every harness trick and observe the model’s raw capability. This is a critical control group in any evaluation setup.
- Creation mode: it does not solve a specific task; it exists to create new modes. The user describes a workflow in natural language, and the agent generates a reusable mode definition.
5. Creation Mode: Turning the Harness into a Compilable Artifact
Creation mode is the most imaginative part of this design. It turns “configuring the harness” from hand-written engineer scripts into a structured artifact the model can help generate. A mode definition typically has four sections:
mode: code-reviewsystem_prompt: |You are a code review assistant focused only on correctness, security, and maintainability.tools:- read_file- search_repo- run_testscontext_policy:include: ["diff", "changed_files", "test_report"]max_history_turns: 6workflow:- plan: list the risk points- verify: provide evidence for each risk point- report: output a structured conclusion
The engineering significance of this approach is threefold. First, the harness shifts from “code” to “data,” so it can be versioned, reviewed, and rolled out gradually. Second, developers who are not on the core team can produce usable modes by describing requirements, lowering the barrier. Third, modes can be composed into a template library for team scenarios such as review, migration, test backfill, and documentation.
6. Trajectory Logging: A Black Box for Every Run
Another frequently underrated design is the trajectory. Everything the model sees—system prompts, reasoning, tool calls and their results, sub-agent scheduling, every context injection—is written to an append-only session log. Users can inspect it entry by entry by source in the trajectory view, while session restore, session forking, search, and replay all operate on the same event stream.
This yields four practical benefits:
- Postmortems: when something goes wrong, you can answer “what exactly did it see at the time” instead of guessing.
- Evaluation: the same trajectory can be replayed repeatedly to compare different harnesses and different models.
- Fork experiments: branch from a given step to test different prompt or tool strategies at controlled cost.
- Audit and compliance: an append-only log naturally satisfies traceability requirements, making internal adoption easier.
The recommended minimum implementation is a structured event stream where each record contains at least a sequence number, timestamp, source, type, payload, and parent event reference:
{"seq": 42, "ts": "2025-01-01T10:00:00Z", "source": "tool", "type": "tool_result", "parent": 41, "payload": {"name": "read_file", "path": "src/index.ts", "bytes": 2048}}
7. How to Evaluate a Harness
Do not draw conclusions from a single leaderboard. Cover at least four dimensions:
- Task completion rate: success rate on multi-step change tasks in real repositories.
- Cost efficiency: tokens consumed and number of tool round trips per completed task; code-based orchestration usually has a clear advantage here.
- Stability: whether long tasks show goal drift, repeated work, or context overflow.
- Operability: whether logs are complete, whether restore and replay work, and whether permission boundaries are clear.
A practical approach is to build your own small regression set: pick 20 to 30 real tasks from your team’s repositories, fix the model version, and vary only the harness configuration for comparison. This method keeps you from being pulled along by marketing language.
8. Implementation Advice
If you are building or selecting a coding agent tool inside a team, proceed in this order: first narrow tool exposure to a few stable primitives; then make the context assembly policy explicitly configurable; then add trajectory logging and recovery; and only after that introduce complex orchestration such as sub-agents and workflows. Reversing the order usually costs you: capabilities pile up, but you cannot locate the cause of a failure.
On the infrastructure side, general-purpose category capabilities are enough: use a container platform for execution isolation, object storage for trajectories and artifacts, logging services with monitoring and alerting to track long-task health, and a message queue to decouple asynchronous subtasks. These capabilities are vendor-neutral; select based on interface openness and data portability.
Competition at the harness layer is just beginning. The model determines how far an agent can think; the harness determines how far it can go in real engineering—and the latter is the part an engineering team can actually design deliberately.
