Agent Harness Architecture Principles and Plugin-Based Practices

    This article explains what an Agent Harness is and why it is needed to turn a language model's token generation into task execution. It covers the core principle that everything is a plugin, the three extension layers of Skill, Tool, and Hook, the execution boundaries enforced by Guard, Approval, and Sandbox, and the runtime responsibilities of dependency resolution, lifecycle management, dynamic mounting, and context passing. It also outlines a three-step approach to building and validating your own Harness, along with common pitfalls and practical recommendations for keeping capabilities replaceable, boundaries enforceable, and behavior verifiable.

    1. The Starting Problem: Models Generate Tokens, Agents Complete Tasks

    A large language model is essentially a probabilistic sequence generator: given a context, it emits the next token, and repeats. It has no inherent notion of whether a task is complete, nor does it natively possess the ability to read or write files, call APIs, or execute code. A usable AI Agent, by contrast, must be able to perceive the environment, select an action, execute it, observe the result, and decide whether to continue.

    The gap between these two is exactly what a Harness is meant to close. The Harness is a complete engineering structure wrapped around the model, responsible for converting generative capability into task capability. A common industry approach is to pile these capabilities into one large monolith, which results in tightly coupled modules that are hard to replace and cannot be rolled out gradually. A more reasonable path is a plugin-based design: treat every capability as a pluggable unit and let the runtime assemble them uniformly.

    2. Core Principle: Everything Is a Plugin

    “Everything is a plugin” is not a slogan but a verifiable engineering constraint. It carries at least three implications:

    • Replaceable capabilities: model adapters, tool registration, session persistence, and loop scheduling are not hard-coded into the main trunk; they are plugged in as plugins.
    • Declarative composition: a working agent is the result of combining several plugins, not a fixed binary.
    • Resolvable dependencies: plugins do not communicate through global variables; they rely on explicit dependency declarations and runtime injection.

    The direct benefit is that the same model, paired with a different plugin combination, exhibits completely different behavioral boundaries. In engineering practice, a few typical assemblies can be fixed as Presets, such as a minimal chat combination, a combination with tool calling, a combination with approval and isolation, and a combination with long-term memory. Comparing how the same model behaves under these four combinations makes it clear that the behavioral differences come from the framework rather than the model.

    A schematic composition description (pseudocode):

    1. preset "minimal":
    2. plugins: [model.adapter, session.memory, loop.basic]
    3. preset "tool-enabled":
    4. plugins: [model.adapter, session.memory, loop.basic,
    5. tool.registry, guard.policy]

    3. Three Extension Layers: Skill, Tool, and Hook

    A plugin-based framework usually needs to distinguish three kinds of extension points; confusing them is the most common mistake beginners make.

    A Skill is a “way of doing things” aimed at the model. It mostly exists as structured text and constraint descriptions, telling the model what steps to follow in which scenario. It does not change runtime capability; it only shifts the model’s decision tendencies.

    A Tool is an “executable action” aimed at the runtime, with a clear input schema, output structure, and error semantics. The key to tool design is not quantity but whether the description is unambiguous, whether failures are observable, and whether side effects are controllable.

    A Hook is an “interception and enhancement point” aimed at the flow, inserting validation, logging, metrics, or rewriting before and after an action executes. Hooks are where governance capability lands and the entry point for observability.

    The relationship among the three can be summarized as: Skills influence selection, Tools provide the means, and Hooks constrain the process.

    4. Execution Boundaries: Guard, Approval, and Sandbox

    Once an agent has real side effects, security design must come first. Three types of boundaries each serve their own role:

    • Guard (policy guard): makes rule-based decisions before an action happens, such as parameter allowlists, dangerous pattern detection, and call rate limits. It must be deterministic and testable.
    • Approval (human approval): introduces interruption and confirmation for high-risk actions, returning decision authority to humans. The design must ensure sufficient approval context, a clear timeout policy, and a usable rejection path.
    • Sandbox (isolation): limits the resources and visibility available to execution, including the filesystem view, network egress, process permissions, and resource quotas. It assumes Guard may be bypassed, so it is the last line of defense.

    The three cannot replace one another: Guard governs “whether it should happen,” Approval governs “who decides,” and Sandbox governs “how bad it gets if it breaks.”

    5. The Runtime: Dynamic Mounting, Lifecycle, and Dependency Re-resolution

    For plugins to be truly pluggable, a runtime kernel is needed to handle assembly and scheduling. Such a runtime, generally called a plugin runtime, typically provides four capabilities:

    1) Dependency resolution: build a dependency graph from declarations, detect missing and circular dependencies, and decide load order.
    2) Lifecycle management: provide standardized init, start, stop, and destroy phases for plugins, and guarantee that resources are fully released in the stop phase.
    3) Dynamic mounting and unmounting: add or remove capabilities without restarting the process, enabling gradual rollout and fast rollback.
    4) Event and context passing: replace global state with a controlled context to avoid implicit coupling between plugins.

    The rigor of the lifecycle directly determines whether hot updates are trustworthy. A hot-updatable plugin must achieve “stop means reclaim”: timers are canceled, listeners are unbound, and temporary files are cleaned up. Otherwise, leaks that are hard to locate will accumulate after repeated hot updates.

    1. onLoad(ctx) -> parse configuration, register services
    2. onStart(ctx) -> establish connections, subscribe to events
    3. onStop(ctx) -> unbind, close, clean up
    4. onUnload(ctx) -> remove from the dependency graph

    6. From the Designer’s Perspective: Building and Validating Your Own Harness

    For a self-built Harness, follow the order “get it running, then take it apart, then build it yourself.”

    Step one: get the minimal loop working: model adapter + session recording + basic loop, and confirm it can reliably complete multi-turn tasks.

    Step two: break down the extension layers, clarify where each capability belongs, and draw an execution boundary diagram marking which actions need approval and which must be isolated.

    Step three: introduce the runtime and gradually turn monolithic capabilities into plugins, migrating only one module at a time and using regression cases to verify that behavior has not degraded.

    The validation system should cover at least four layers: the unit layer validates tool input/output and error semantics; the contract layer validates plugin dependency declarations and lifecycle completeness; the scenario layer uses a fixed task set to compare behavioral differences across combinations; and the governance layer validates Guard rule hits, approval interruption, and sandbox escape protection. An agent system lacking governance-layer validation carries uncontrollable risk in real environments.

    7. Common Pitfalls and Practical Recommendations

    • Treating the prompt as everything: prompts only influence selection; capability and boundaries are still determined by the framework.
    • Vague tool descriptions: when the model picks the wrong tool, it usually stems from unclear descriptions and error messages.
    • Ignoring the stop phase: in hot-update scenarios, resource leaks amplify quickly.
    • Deferring security and functionality: once side effects become real, remediation costs far more than designing them in upfront.

    Overall, plugin-based design is not about looking elegant; it is about making capabilities replaceable, boundaries enforceable, and behavior verifiable. As model capabilities keep evolving, a clearly structured Harness keeps engineering assets stable and confines change to the plugin layer. Combined with general-purpose container platforms, logging services, and monitoring and alerting capabilities in the cloud, it can further enable gradual rollout, full-link tracing, and metric-based evaluation, shifting agent iteration from experience-driven to data-driven.