Agent Harness Architecture: Principles and Plugin-Based Design

    This article explains what an agent harness is and why model capability alone does not complete real tasks. It covers the core plugin-first principle, the three extension layers of Skill, Tool, and Hook, the distinct roles of Guard, Approval, and Sandbox, and how a runtime handles dynamic mounting and dependency resolution. It also shows how preset combinations support controlled experiments and outlines a practical path to build and verify your own harness.

    1. The Starting Problem: Model Capability Is Not Task Completion

    A large language model is fundamentally a token generator: given a context, it outputs a probability distribution over the next token and samples it step by step. It has no persistent memory, cannot read files on its own, cannot execute commands, and cannot sense whether its previous action succeeded. A real task, however, usually demands a closed loop of “look up information, make a judgment, call a tool, inspect the result, and correct course.” The gap between the two is exactly why an agent runtime exists, commonly referred to in the industry as a harness.

    The harness is not part of the model. It is an engineering layer wrapped around the model. It turns the model’s repeated stateless inference into a stateful, executable, and rollback-capable task process. This distinction matters: swapping the model only changes inference quality, while the harness determines whether capabilities can actually be released.

    2. Core Principle: Everything Is a Plugin

    The central claim of a plugin-based design is that the system has no “special-case capabilities.” Model adaptation, tool registration, session persistence, loop scheduling, and policy interception all exist as plugins and connect through a unified contract. This yields three direct benefits:

    • Replaceable: the adapter layer is a plugin, so switching model vendors or inference protocols requires no change to the main loop.
    • Composable: capabilities are assembled as a set, and different scenarios load different subsets to form different “preset combinations.”
    • Evolvable: adding a capability means adding a plugin rather than modifying the kernel, which prevents the trunk code from rotting.

    There is a simple test for whether a design is truly plugin-based: if a capability only works when written into the main loop, the abstraction is still leaking.

    3. Layered Extension Model: Skill, Tool, and Hook

    In engineering practice, extension points are usually divided into three layers, each answering a different question.

    A Skill answers “how to do it.” It is a knowledge and process wrapper aimed at the model, injected into the context as prompts, documentation, and operating guidelines, telling the model which steps and constraints to follow for a given class of tasks. A Skill does not change system permissions; it only shifts the model’s behavioral tendency.

    A Tool answers “what can be done.” It is a deterministic function that the model selects and calls, with a clear input schema, output structure, and error semantics. The key to tool design is not quantity but description quality and idempotency: the description determines whether the model can pick the right tool, and idempotency determines whether a failed call can be safely retried.

    1. Tool contract (illustrative)
    2. name: query_metric
    3. input: { service: string, window: string }
    4. output: { series: Array<{ ts: number, value: number }> }
    5. errors: [INVALID_WINDOW, TIMEOUT, NO_DATA]
    6. idempotent: true

    A Hook answers “what is allowed and what happened.” It attaches to key lifecycle points for observation and intervention, such as injecting context before a request, redacting data after a request, or recording entries before and after a tool call.

    4. Security Boundaries: Guard, Approval, and Sandbox

    The three are often confused, but their enforcement boundaries are entirely different and should be divided along “intercept, authorize, isolate”:

    Mechanism Where it acts Decision maker Failure behavior
    Guard Before a call happens Rule engine Rejects directly and returns a reason
    Approval When a high-risk action is triggered A human or a higher-level policy Suspends and waits, terminates on timeout
    Sandbox The environment where execution happens Runtime isolation Out-of-bounds actions are cut off, main environment unharmed

    The design point is ordering: Guard performs cheap filtering, Approval interrupts the flow only for a few high-risk actions, and Sandbox serves as the final fallback. Mixing the three in one place produces the classic failure of “very complex rules that still leave an escape path.”

    5. Runtime: Dynamic Mounting and Dependency Re-resolution

    As the number of plugins grows, static assembly can no longer keep up, and the runtime must handle four things:

    1. Dependency resolution: build a topology from the dependencies declared by plugins, and detect circular dependencies and version conflicts.
    2. Lifecycle management: advance through discovery, resolution, loading, startup, shutdown, and unloading, ensuring state can be reclaimed.
    3. Hot updates: when replacing a single plugin, re-resolve only the affected subgraph instead of restarting the whole process.
    4. Fault isolation: when a single plugin fails to start, degrade to a missing capability rather than bringing down the whole system.
    1. Dependency graph (illustrative)
    2. loop ── depends on ──> session, model-adapter, tool-registry
    3. guard ── depends on ──> policy
    4. When hot-updating loop, only loop and its downstream views need restarting

    Session records must be plugin-based precisely because they are depended on by the loop, the tools, and the policy layer at the same time. Hard-coding them into the kernel makes hot updates impossible.

    6. Using Preset Combinations for Controlled Experiments

    The most economical way to validate a harness design is to control variables: fix the model and the task, switch only the capability combination, and observe behavioral differences. Four common combination ideas are:

    • Minimal combination: only the model adapter and the loop, used to confirm baseline behavior.
    • Read-only combination: add read-only tools and a Guard, and observe refusal and out-of-bounds handling.
    • Full-flow combination: add write operations, Approval, and Sandbox, and observe interruption and recovery.
    • High-constraint combination: layer on strict policies and full session auditing, and observe the tradeoff between efficiency and safety.

    If the model output and tool traces differ only slightly across all four combinations, it usually means the extension layer is not actually taking effect, and the problem most often lies in injection timing or dependency resolution.

    7. Building and Verifying Your Own Harness

    From a designer’s perspective, the recommended order is: first define the unified plugin contract and error semantics, then implement a minimal loop, then connect the adapter, tools, session, and policy one by one, and finally introduce runtime hot updates. Verification should cover four kinds of cases: the normal closed loop, tool failure and retry, policy rejection, and plugin hot replacement. Observability must be built in, at minimum recording the input summary, elapsed time, and result status of every tool call to support later review.

    When deploying in the cloud, you can reuse general-purpose category capabilities: a container platform to host the runtime, object storage to hold sessions and artifacts, a message queue to decouple asynchronous tasks, and logging, monitoring, and alerting services for auditing and anomaly detection. To further reduce operational cost, you can look at general cloud-native capability combinations offered by cloud vendors such as Baidu AI Cloud.

    8. Conclusion

    The value of a harness is placing an “uncertain model” inside a “deterministic engineering structure.” Plugin-based design solves extension and replacement, layered extension points solve the confusion of responsibilities, the security trio solves risk boundaries, and the runtime solves dynamic evolution. With all four in place, an agent moves from a demo to a maintainable system.