Agent Harness Architecture Explained: A Dual-Plane Design
This article breaks down the dual-plane architecture behind a production-grade agent harness, separating system composition from runtime facts. It explains how a runtime plugin graph declares and governs capabilities, how an append-only event stream serves as the single source of truth for context, UI traces, recovery, and forking, and how the main loop moves between the two. It also contrasts a minimal agent loop with production requirements and offers practical implementation advice.
一、Why Production Agents Need a Harness
Early agent experiments usually implement a minimal loop: assemble a prompt, call the model, execute tools, and feed tool results back to the model for further reasoning. That loop is enough to validate an idea, but it struggles to support real business workloads. Once an application moves into production, several questions become unavoidable: how models and credentials are managed, how to recover after a session is interrupted, how to compress overly long context, whether tool calls require approval, where code executes, and how the same runtime facts can be observed by a UI.
For this reason, a production-grade agent runtime is often abstracted as a harness: the runtime skeleton that hosts models, tools, prompts, and execution policies. It is not a single inference call; it provides unified support for multiple inferences, multi-turn interactions, and multiple host environments. Using the publicly described runtime design of an AI coding tool as background, this article abstracts a general-purpose dual-plane architecture and discusses its components, how they collaborate, and its engineering value.
二、Dual-Plane Architecture: Separating Composition from Facts
The core design of a harness can be summarized as two orthogonal lines.
The first line is the runtime plugin graph. It maintains a graph describing the system’s current capabilities: which capabilities are available, what each one depends on, the scope in which it takes effect, and how resources are reclaimed when it is unloaded. It answers the question of what the system is composed of right now.
The second line is an append-only event stream. It records what actually happened during an agent run in an append-only manner, and on top of that it projects the model context, the UI trace, and the data needed for recovery and forking. It answers the question of what the system just did.
The agent main loop runs between the two lines. The main loop obtains models, tools, prompts, and session services from the plugin graph, and writes each execution result back to the event stream. Decoupling composition from facts allows the system to swap implementations without losing history, and to adjust the capability set while keeping history unchanged.
三、Runtime Plugin Graph: Declaring and Governing Capabilities
The value of the plugin graph is that it extracts cross-cutting concerns from business code. Credential injection, log collection, metrics reporting, tool policies, and sandbox management all exist as plugins, connected through dependency declarations rather than hard coding.
A simplified declaration example looks like this:
plugin: model-providerconfig: { endpoint: <injected by environment>, credentialRef: secret://agent/model }plugin: tool-registrydependsOn: [model-provider]config: { allowlist: [read_file, search_repo, run_tests] }plugin: session-storescope: workspaceplugin: policy-enginedependsOn: [tool-registry, session-store]
Configuration is typically built up from a layered structure: a base tier describes the default capability set, an extension pack adds optional capabilities, and a user patch applies the final override. The loader parses the configuration line by line and mounts it as plugin instances, forming a directed dependency graph. Scope determines whether a capability is globally visible or effective only within a specific workspace; the unload order is the reverse of the mount order, stopping dependents before their dependencies, which avoids dangling references and resource leaks.
This governance approach brings three benefits: capabilities are pluggable, so connecting a new execution backend does not require changing the main loop; dependencies are explicit, so missing or circular dependencies can be detected at startup; and the lifecycle is controllable, with plugin start and stop as first-class operations that make canary releases and rollbacks easier.
四、Append-Only Event Stream: The Single Source of Runtime Facts
The event stream is append-only and never modified. Each record carries a stable identifier, a type, a timestamp, and correlation fields. Its key role is to be the single source of runtime facts: the trace seen by the UI, the context seen by the model, and the state rebuilt during recovery are all different projections of the same log.
event#0012 type=tool_call data={name: run_tests, args:{...}}event#0013 type=tool_result data={status: failed, summary: "2 cases failed"}event#0014 type=model_turn data={tokens: 1830, finish: tool_use}
The projection layer generates different views from the log on demand. The context projection handles trimming, summarization, and compression, folding overly long history into a manageable summary; the UI projection exposes only necessary fields to avoid leaking internal details; the recovery projection replays from the most recent consistent point to rebuild session state; and the fork projection allows deriving a new branch from any event position, used for comparing approaches and running retrospective experiments.
Because the log is immutable, auditing and troubleshooting become straightforward: any anomaly can be traced to a specific event sequence, without relying on scattered process logs.
五、The Main Loop: Moving Between Composition and Facts
The main loop has a relatively restrained responsibility: resolve the required services from the plugin graph, submit context to the model, parse the tool intent returned by the model, hand it to the tool registry and policy engine for a decision, append the result back to the event stream after execution, and enter the next round until the model produces a terminal state or a budget limit is triggered.
Termination conditions and budget control deserve emphasis. A loop without a clear upper bound easily falls into idling with repeated tool calls, so in practice step limits, time limits, and resource quotas are usually set, and the termination reason is recorded in the event stream for later analysis.
六、The Gap Between a Minimal Loop and Production Capabilities
Placing a minimal loop next to production-grade capabilities makes the gap obvious:
- Models and credentials: multi-backend adaptation, key hosting and rotation, keeping credentials out of prompts and logs.
- Session recovery and compression: resume from breakpoints, context summarization, and history trimming strategies.
- Tool policies and approval: allowlists, parameter validation, and human confirmation for high-risk operations.
- Sandboxing and remote execution: isolating the file system and network egress, and placing execution cost on an elastic container platform.
- Multi-host integration: CLI, desktop, and server sharing the same runtime semantics.
- Sub-agents: task splitting, context isolation, and result aggregation.
- Plugin start and stop: hot plugging and canary releases.
- Observability: the same set of facts driving the UI, log services, and monitoring alerts.
Most of these capabilities map to common cloud categories, such as object storage for artifacts, message queues for decoupling long-running tasks, container platforms for hosting sandboxes, and logging and monitoring services for observability data, without binding to any proprietary interface.
七、Implementation Recommendations
First, define the event model before writing the loop; once event fields are stable, all subsequent projections can evolve. Second, separate policy from execution; approval logic should not be scattered across tool implementations. Third, add startup-time validation for plugin dependencies to shift problems left. Fourth, set measurable metrics for context compression, such as information retention before and after summarization and the cost per round. Fifth, route any high-risk execution through a sandbox by default and keep a complete audit trail.
The significance of the dual-plane architecture is that it governs the volatile composition and the invariant runtime facts separately. With this layering in mind, readers can design or evaluate an extensible, recoverable, and auditable agent runtime without depending on a specific implementation.
