Agent Harness Design: Rebuilding Coding Assistants in a Programmable Way
This article examines agent harness design through the lens of four working modes found in web-based coding agents. It explains why the harness, not the interface, is the real differentiator, and covers context budgeting, code-driven execution, minimal-mode benchmarking, and user-defined modes. It closes with practical guidance on tool contracts, state persistence, permissions and sandboxes, observability, and evaluation loops.
Agent Harness Design: Rebuilding Coding Assistants in a Programmable Way
Starting Point: The Model Is the Soul, the Harness Is the Body
The industry consensus on agents can be summed up in one sentence: the model sets the ceiling on intelligence, while the harness determines whether that intelligence can actually deliver in a real environment. The harness layer is responsible for three things: letting the model understand its current situation (context and workspace state), letting the model use tools safely (reading and writing files, executing commands, retrieving information), and letting the model keep working through long tasks (memory, planning, goal management, and retrying after failures).
Once a certain class of coding agent tools proved out commercially, this layer quickly became contested ground for every model team. A common misjudgment is the assumption that the competition is about “building a more usable command-line coding assistant.” From an engineering perspective, however, the real differentiation is not the form of the interface but whether the harness is programmable, tailorable, and measurable. Using the four working modes presented by a certain web-based coding agent as a thread, this article abstracts a general methodology for harness design.
Form Factor: Running Locally, with the Interface in the Browser
The typical form of these products looks like this: on the left, a session list organized by workspace, where one workspace maps to one local project directory; in the middle, a conversation area where the user describes a requirement and the agent reads files, changes code, and runs commands, with every tool call laid out in full on a timeline.
Its key characteristic is not that it is “web-based,” but that the execution location and the interaction location are decoupled: computation and file operations happen on the user’s own machine or inside a controlled container, and the interface is merely a remotely rendered panel for observation and control. This decoupling brings three direct benefits:
- Code and credentials do not have to leave the local environment, so the data boundary is clear;
- The tool-call process can be replayed, which makes auditing and debugging easier;
- The interface is replaceable (browser, desktop shell, IDE plugin) while the core stays single.
Four Modes: The Programmable Spectrum of the Harness
1. Standard Mode: Full Capability Set and Context Budget
Standard mode provides a complete capability set: file editing, command execution, file and web retrieval, skills, planning, goal management, sub-agents, and workflows. Its engineering difficulty is not “integrating a lot” but making tool selection and result trimming within a limited context budget: the more tools there are, the higher the risk of wrong selection and prompt bloat. A workable approach is layered exposure: high-frequency tools stay resident, low-frequency tools are loaded on demand via semantic retrieval, and long outputs are structurally summarized before being fed back in.
2. Code-Driven Mode: Compressing Ten Round Trips into One Execution
Code-driven mode (which can be understood as Code Mode) changes the way work gets done: tools are exposed to the model through a software development kit, and instead of issuing calls one by one, the model writes a program directly, merging what would otherwise take a dozen or more “call, wait, call again” operations into a single execution.
Illustrative expression (pseudocode, for explaining the idea only):
// An orchestration program generated by the model, completing multiple steps in one executionconst files = await fs.glob("src/**/*.ts");const targets = files.filter(f => f.includes("legacy"));for (const f of targets) {const src = await fs.read(f);await fs.write(f, src.replace(/oldApi/g, "newApi"));}const report = await shell.run("npm run build");return { changed: targets.length, ok: report.exitCode === 0 };
The benefit is that control flow shifts from “the model deciding step by step” down to “deterministic program execution,” significantly reducing round-trip overhead and context usage. The cost is higher demands on sandboxing, resource quotas, and timeout control, because a single program can produce a large number of side effects in a very short time.
3. Minimal Mode: Stripping Away the Harness to See Raw Capability
Minimal mode keeps only a persistent command execution environment and a file editor: two tools. Its purpose is benchmarking: remove all the “harness tricks” such as prompt engineering, skill orchestration, and sub-agents, and observe the model’s real coding ability under the smallest possible tool surface. For engineering teams, this is the most honest regression baseline: any harness optimization should prove, on the minimal baseline, that it is not using prompt techniques to paper over model weaknesses.
4. Creation Mode: Letting the Harness Grow Its Own New Modes
Creation mode is for “creating modes”: the user describes the desired way of working in natural language, and the system produces a reusable mode definition (tool subset, system prompt, workflow orchestration, termination conditions) that can be invoked like a built-in mode once saved. This essentially turns the harness from a “fixed product” into an “extensible platform,” and its feasibility depends on three prerequisites: mode definitions are declarative configuration rather than hardcoding; the tool registry is unified and annotated with permissions; and modes can be version-managed and rolled back.
Implementation Essentials: Keeping a Programmable Harness Under Control
- Tool contracts: every tool declares its name, input schema, side-effect level, idempotency, and timeout; the model side sees only the contract, not implementation details.
- State and persistence: workspace, session, and command environment state are persisted separately, supporting resume after interruption and rollback on failure.
- Permissions and sandboxing: authorization is graded by side effect, with write operations and network access defaulting to least privilege; in code-driven mode, resource quotas and execution time limits must be added on top.
- Observability: a complete timeline records tool calls, input and output summaries, and elapsed time, making replay and root-cause location easier.
- Evaluation loop: with minimal mode as the baseline, standard mode and code-driven mode are compared incrementally, using the same set of real repository tasks to measure success rate, number of round trips, and rate of human intervention.
Conclusion
Moving from “building a coding assistant” to “building a programmable agent harness” is a leap in product thinking. To implement similar capabilities in your own environment, you can run execution sandboxes on a container platform, store workspace snapshots in object storage, decouple long tasks with a message queue, and build an evaluation and operations loop with logging services and monitoring alerts. This is also the category of capabilities that Baidu AI Cloud continues to invest in for agent infrastructure. In the end, the value of a harness is proven by three things: being measurable, reproducible, and tailorable.
