Agent Harness Architecture: Principles and a Plugin-Based Approach

    This article explains what an agent harness is and why it is necessary, then walks through a plugin-based design for building one. It covers the "everything is a plugin" organizing principle, the three extension layers (Skill, Tool, Hook), the three security boundaries (Guard, Approval, Sandbox), runtime responsibilities such as dependency re-resolution and hot updates, a four-step path from a minimal setup to a self-built harness, and common pitfalls with practical engineering advice.

    1. The Starting Point: Models Generate Tokens, Agents Deliver Results

    A large language model is essentially a conditional probability generator: given a context, it emits the next fragment token by token. It has no memory, no side effects, no concept of a failed attempt that needs retrying, and no awareness of the environment it is running in. A genuinely usable agent, by contrast, has to carry a task across multiple turns, call external capabilities, read and write state, and roll back when something goes wrong. That gap is not closed automatically by a stronger model. It is closed by the engineering layer wrapped around the model, commonly called the harness.

    Getting this layer right means answering four questions: how is the model connected and swapped out? How are external capabilities declared and discovered? How is process state recorded and replayed? When does the loop terminate? If the answers are scattered across business code, the system quickly degrades into a giant web of conditionals that nobody can maintain. Pluginization is an effective way to contain that complexity.

    2. The Core Principle: What “Everything Is a Plugin” Actually Means

    “Everything is a plugin” is not about fragmenting directories. It establishes one uniform organizing contract: every capability exists as a plugin, plugins interact only through explicit extension points, and the host is responsible for assembly, not implementation.

    The principle yields three direct benefits. First, replacement cost drops: swapping the model adapter or adding another way to persist logs requires no change to the loop logic. Second, composability improves: capabilities stack orthogonally, and the same model shows noticeably different behavioral boundaries under different plugin combinations. Third, verifiability increases: each plugin can be unit tested in isolation, while overall behavior is covered by a combination matrix.

    In practice, a plugin is usually defined by three elements: declaration (who it is, what it depends on, what it provides), initialization (obtaining dependency handles and completing registration), and teardown (revoking registrations and releasing resources). By resolving the dependency graph once during assembly, the host can tell whether a given combination is self-consistent.

    1. Plugin declaration sketch (pseudocode)
    2. definePlugin({
    3. name: "tool-registry",
    4. inject: ["logger", "policy"], // dependency declaration
    5. setup(ctx) {
    6. ctx.on("tool.call", handler); // register on an extension point
    7. return () => ctx.off("tool.call", handler); // teardown hook
    8. }
    9. })

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

    Separating extension points into layers significantly reduces cognitive load in practice.

    The Skill layer packages knowledge and process. It tells the agent what steps to think through when facing a certain class of task. It is typically a reusable set of instruction text and reference material, and it produces no side effects. The Tool layer is the atomic exit point for a capability, with a well-defined input schema, output structure, and failure semantics; it is the only layer allowed to produce external side effects. The Hook layer handles cross-cutting concerns, inserting observation, rewriting, or interception logic at key points, for example injecting a tracing identifier uniformly or masking sensitive parameters.

    The rule for telling them apart fits in one sentence: change “how it thinks” with a Skill, change “what it can do” with a Tool, and change “what happens during execution” with a Hook. Mixing them leads to uncontrolled permissions and painful debugging.

    4. Security Boundaries: Guard, Approval, and Sandbox

    The biggest risk of pluginization is capabilities being stacked arbitrarily. Three types of boundaries are therefore required, and they cannot substitute for one another.

    Guard is a static constraint. It decides allow or deny against policy before a call happens, and addresses “is this class of operation permitted.” Approval is dynamic confirmation. It hands high-risk actions back to a human or an upper-level policy for a decision, and addresses “is this particular instance approved.” Sandbox is execution isolation. It uses a restricted runtime to limit the file system, network, and resource quotas, and addresses “even if it goes out of bounds, the impact stays narrow.”

    Together they form defense in depth: Guard shrinks the attack surface, Approval handles uncertainty, and Sandbox covers residual risk. Investing in only one layer will be bypassed in real scenarios.

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

    As the number of plugins grows, static assembly is no longer enough, and the runtime has to take on four responsibilities: resolve the dependency topology and determine load order; manage instance lifecycles so that initialization and teardown always come in pairs; re-resolve dependencies when plugins are added or removed, propagating the change to affected nodes; and roll back in reverse dependency order on failure, so no half-initialized state is left behind.

    The key to hot updates is not “replacing code” but state migration: the new instance takes over the registrations and context of the old one, and the old instance is destroyed only after it has drained. If state cannot be serialized or migrated, the explicit fallback is to restart that subtree rather than pretend hot updates are supported.

    1. Change propagation order sketch
    2. unload tool-a → mark dependents as pending re-resolution → re-resolve policy → remount tool-a' → restore extension point registrations

    6. From Running to Self-Built: A Practical Path

    A four-step progression works well. Step one: get a minimal combination running, pair the same model with different preset combinations, observe the behavioral differences, and build intuition. Step two: break down the three extension layers, draw the extension points and call chains, and pin down the input and output contract of each layer. Step three: fill in the boundaries by wiring policy checks, human confirmation, and isolated execution to high-risk tools, then construct privilege-escalation cases to verify them. Step four: design a combination matrix for regression, turning “capability combination × input sample × expected boundary” into a repeatable set of test cases.

    7. Common Pitfalls and Engineering Advice

    One is treating prompts as architecture, which leaves capabilities unreusable. Two is making plugins too fine-grained, so the dependency graph swells beyond what anyone can reason about; a good granularity is “one independently verifiable responsibility.” Three is missing teardown paths, which leaks registrations after long runtimes. Four is treating observability as an afterthought, when in fact without a unified tracing identifier you cannot locate timing problems that span plugins. If you need to carry session records, logs, and metrics, general-purpose object storage, logging, and monitoring and alerting services from a cloud provider work directly, as long as you keep the interfaces abstract and avoid coupling to a specific implementation.

    8. Conclusion

    The maturity of agent engineering depends on whether the surrounding harness has clear extension contracts, explicit permission boundaries, and a controllable runtime. Treating “everything is a plugin” as an organizing principle rather than a slogan, combined with layered extension and defense in depth, is what turns growth in model capability into a real improvement in task completion rates.