Agent Harness Architecture Breakdown: A Plugin-First Agent Framework

    This article breaks down the architecture of a plugin-based agent harness, the runtime layer that wraps a large language model and governs session state, prompt assembly, tool registration, orchestration, and rollback. It explains how a service container, typed events, and rollbackable side effects work together, how package boundaries map to capability domains, what checkpoints a tool call passes through, and what self-built platforms can learn from this design.

    1. Why the Agent Harness Deserves a Closer Look

    Over the past two years, the focus of agent engineering has been shifting from model capability to the runtime framework. The model only generates the next action. What actually determines whether a system is controllable, extensible, and auditable is the layer wrapped around the model: how session state is maintained, how prompts are assembled, how tools are registered and authorized, how a failure is rolled back, and how multiple subtasks are orchestrated. The industry calls this layer the agent harness.

    An open-source project recently published an implementation built on an “everything is a plugin” architecture. This article does not evaluate the specific product. Instead, it abstracts the design into a general engineering pattern that you can reference when building your own system or evaluating existing options. The core idea comes down to three things: using a service container to carry dependencies, using typed events to decouple interactions, and using rollbackable side effects to guarantee consistency. In practice, this takes the form of a plugin tree assembled layer by layer during startup. Even the main agent loop and the tool registry are just replaceable nodes on that tree. There is no privileged “kernel” that can be patched.

    2. Overall Shape: One Plugin Layer, Multiple Assembly Modes

    The framework provides two runtime modes. One starts a local web interface by default and listens on a loopback address. The other is a headless, one-shot execution mode that exits after finishing the task and does not run as a persistent service. Running from source follows the conventional four steps: install dependencies, build, and start in interface mode.

    What is truly worth noting is the relationship between the underlying dependency layer and the upper plugin layer. “Everything is a plugin” is not a marketing slogan: the tool registry, prompt assembly, and main loop all live in the plugin layer, at the same level as an ordinary command execution plugin. All four entry points share the same plugin layer. The difference between interface mode and headless mode is only the set of plugins (bundle) stacked on top at startup. The direct benefit of this design is that adding a new interaction mode does not require changing core logic; you only need to reassemble the manifest.

    3. Repository Structure: Expressing Responsibility Boundaries Through Package Boundaries

    This implementation is a multi-package TypeScript monorepo with roughly two hundred packages, the vast majority of which use product-oriented naming. The source code is about two hundred thousand lines, with nearly a thousand test files. The grouped directories are divided by capability domain and can be abstracted as follows:

    Capability Domain Typical Responsibilities
    Core Sessions, system prompts, tools, main loop
    Model Access Multi-model adapters, request wrappers, streaming parsers
    Execution Environment File system, command execution, terminal, language services, sandbox
    Task Orchestration Sub-agents, context compression, skills, workflows
    Integration Protocols External tool integration protocols, editor-side protocols
    Frontend Dozens of browser-side packages for session views, tool views, sidebars, model settings, and more

    Two details are worth borrowing. First, the frontend is also split into plugins rather than a single monolithic single-page application. Each UI region is an independently pluggable package, which significantly lowers the cost of interface customization and gradual replacement. Second, the underlying framework dependencies are fully brought into the repository and uniformly renamed to the project’s own namespace. The reason is to gain complete control over the framework layer: it can be audited, patched, and version-locked, avoiding uncontrollable risks from upstream changes. This is especially relevant for enterprise platforms with high stability requirements.

    4. Runtime Mechanism: Service Container + Typed Events + Rollbackable Side Effects

    Three pillars support collaboration between plugins.

    The service container handles dependency injection and lifecycle management. Plugins do not reference each other directly. Instead, they declare “I need a certain service,” and the container resolves it during assembly. The benefit is that replacing an implementation does not require changing the caller, and during testing the whole thing can be swapped out with stub implementations.

    Typed events handle the decoupling of notifications and interception. Events carry explicit payload types. Plugins participate in handling through listeners and priorities, and can validate, rewrite, or block at key points. Compared with callback registration, typed events make the contracts for cross-package collaboration statically checkable.

    Rollbackable side effects handle consistency. Write operations that plugins perform on the external world are modeled as effect objects that can be recorded and undone. If a flow fails or the user interrupts it, the framework rolls back in reverse order, avoiding half-finished dirty state. A sketch:

    1. // Pseudocode: rollbackable effect
    2. const effect = ctx.effect(async () => {
    3. await fs.write(file, content)
    4. return () => fs.remove(file) // rollback action
    5. })
    6. try { await runAgentLoop(ctx) }
    7. catch (e) { await effect.rollback(); throw e }

    5. What Checkpoints a Tool Call Passes Through

    Tool calls are the path with the densest security boundaries. Typical checkpoints include: registration and capability declaration (name, parameter schema, risk level); parameter schema validation; permission and policy checks (whether disk writes are allowed, whether network access is allowed, whether human confirmation is required); sandbox and resource limits (timeout, memory, accessible paths); execution and streaming progress reporting; result truncation and structuring; failure classification and retry policy; and audit logging. Making this chain explicit is the dividing line between an agent that can “run” and one that can be “managed.”

    6. The Engineering Constraints It Sets for Itself

    These can be summarized in five points: everything is a plugin, with no privileged kernel; contracts are typed and statically checkable across packages; side effects are rollbackable; form is determined by assembly rather than branching code; and the framework layer is self-maintained for auditability. At the same time, it explicitly notes that it is in an early preview stage and that breaking changes may follow. This is also the risk item to assess first when adopting this kind of framework.

    7. Lessons for Self-Built Platforms

    To implement a similar architecture in your own system, start in three places: first define service contracts and event contracts, then split package boundaries, and finally unify the assembly entry point; make permission checks and auditing independent plugins rather than scattered conditionals; and establish a unified model for side-effect rollback. Combined with container platforms for elastic scaling, and log services plus monitoring and alerting to cover the call chain, you can preserve the flexibility of a plugin architecture while maintaining controllability.