Understanding the Agent Harness Architecture: A Practical Guide to Building Controllable AI Agents
This article breaks down why model capability alone does not equal agent capability, introducing the formula Agent = Model + Harness. It explains the core responsibilities of an agent runtime framework, the benefits and trade-offs of a plugin-based microkernel design, and how these systems differ from everyday chat products. It then walks through six practical steps for building a controllable agent from scratch, along with common risks and how to avoid them. Readers will learn what to look for when evaluating whether a framework is worth adopting.
1. Why Model Capability Is Not Agent Capability
The open-source community has recently shown strong interest in moving agents beyond “models that can chat” toward “systems that can do real work in real environments.” Many developers are confused: if a model can already reason and generate code, why do we need an extra runtime layer?
The answer is captured by a widely accepted formula:
Agent = Model + Harness
The model is the “brain” responsible for thinking, planning, and generation. The Harness is the “body” that lets this horse be steered, constrained, and connected to the real world. It determines whether model capability can be reliably turned into deliverable results.
From an engineering perspective, a runtime framework takes on at least four responsibilities:
- Environment access: wrapping the file system, terminal, browser, and internal services into tools the model can call;
- Workflow orchestration: breaking complex tasks into steps and defining execution order, retry, and rollback strategies;
- Constraints and validation: limiting the model’s freedom through project rules, permission boundaries, and test and check processes;
- State management: maintaining session context, intermediate artifacts, and execution traces so long tasks can be recovered.
A common misconception is treating the prompt as everything. In reality, the prompt is only a small part of the framework’s configuration. What really determines success is whether tool descriptions are clear, whether permissions follow least privilege, and whether failures can be detected and corrected.
2. Plugin-Based Microkernel: Making “Replaceable” an Architectural Constraint
The most striking design principle of this new generation of runtime frameworks is “everything is a plugin”: model integration, tools, skills, session storage, sandboxes, interfaces, and even the agent’s own main loop all exist as plugins that can be unloaded and replaced.
This is supported by a microkernel architecture. The kernel does only three deliberately restrained things:
Plugin loading / unloadingDependency resolution and version constraintsLifecycle and event dispatch
All other capabilities are pushed down into plugins. This brings three direct benefits:
- Decoupled evolution. Model upgrades do not affect the tool layer, and refactoring the tool layer does not affect session storage.
- Hot swapping. An ideal implementation can replace plugins at runtime while keeping execution state from crashing, which is valuable for gradually validating new toolchains.
- Controllable governance. Permissions, auditing, and rate limiting can be mounted uniformly as independent plugins instead of being scattered across business code.
It is worth noting that hot swapping is not “zero cost.” Implicit coupling between plugins, shared memory state, and event-order dependencies can all make runtime replacement fragile. A more robust engineering approach is to define explicit contracts for plugins, externalize mutable state, and keep parallel dual implementations and fast rollback paths for critical plugins.
3. How It Differs from Everyday Usage: From “Conversation” to “Execution”
The relationship between the runtime framework and what ordinary users see—web-based chat, desktop assistants, cloud coding tools—can be understood as follows:
| Form | Interaction Center | Environment Capability | Customizability |
|---|---|---|---|
| Conversational product | Session | Weak, mostly retrieval and generation | Low |
| Integrated coding assistant | Editor / repository | Medium, read/write files and run commands | Medium |
| Self-built runtime framework | Task | Strong, can connect to any toolchain | High |
The value of a runtime framework is not being “smarter,” but being “more orchestrable, more auditable, and more replaceable.” When a task spans multiple systems, runs for a long time, and requires strict permissions and traceability, the framework layer becomes the decisive factor.
4. Practical Implementation: Building a Controllable Agent from Scratch
1. Define task boundaries and acceptance criteria first
Do not start by choosing a model; start with “what counts as done.” Write acceptance criteria as executable checks, such as unit tests, static checks, and API contract validation. The more automated the acceptance criteria, the lower the model’s trial-and-error cost.
2. Follow the principle of least surprise in tool design
Keep the number of tools small and focused. Name and describe them for the model, not with human-oriented abbreviations. Example:
{"name": "read_file","description": "Reads the text content at a specified path in the repository and returns line numbers and content","parameters": {"path": "string","max_lines": "integer, default 400"}}
3. Tighten permissions and sandbox by default
Limit file read/write to the working directory, use an allowlist for network access, and run command execution in a container or isolated environment. In production, it is recommended to split “writable,” “network-enabled,” and “privilege-escalating” into three separate authorization tiers, enabled on demand.
4. Capture team conventions in a rules file
A project-level rules file should clearly state the directory structure, dependency management approach, and the check commands that must run before committing. This content is essentially a “static plugin” of the runtime framework and can significantly reduce the model repeatedly probing on irrelevant issues.
5. Prioritize observability
At minimum, record three types of data: the input parameters and a summary of results for each tool call, the time taken and failure reason for each step, and changes in context window usage. If you use general cloud capabilities, you can rely on logging services, monitoring alerts, and object storage to archive execution traces for review and cost accounting.
6. Drive iteration with an evaluation set
Maintain a small, stable set of tasks covering common scenarios and typical failure modes. Run it after any change to prompts, tools, or models, and use pass rate and average number of steps to judge whether it is progress or regression.
5. Common Risks and How to Avoid Them
- Over-automation: letting the agent run freely in areas lacking acceptance checks easily produces artifacts that “look complete but are actually unusable.”
- Context bloat: long tasks need summary compression and segmented archiving, otherwise key constraints get drowned out.
- Tool hallucination: the model may call nonexistent parameters, so parameter validation and a failure loop are needed at the framework layer.
- Supply chain risk: third-party plugins of unknown origin should undergo signature verification, version locking, and permission declaration review.
6. Conclusion
The point of a runtime framework is to package uncertain model capability into certain engineering output. To judge whether a framework is worth investing in, do not look at how many fancy features it supports, but at four things: whether tool integration is low-cost, whether permissions can be tightened, whether failures are observable, and whether components are replaceable. Get these four things right, and every time the model upgrades, your agent system gets stronger with it.
