Agent Plugin Architecture: A Beginner's Guide to Principles and Design

    This article explains how to move from a monolithic agent loop to a plugin-based architecture. It covers the core principles of treating every capability as a plugin, four preset configurations for controlled experiments, three extension layers (Skill, Tool, and Hook), the layered execution boundary of Guard, Approval, and Sandbox, and the dynamic runtime concerns of dependency resolution, lifecycle management, and hot reloading. It also outlines a practical path for building and validating your own agent harness.

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

    The core capability of a large language model is deliberately narrow. Given an input sequence, it outputs a probability distribution over the next token and keeps extending the sequence autoregressively. It does not read files on its own, execute commands, remember anything beyond the previous turn, or retry after a failure. A usable agent, by contrast, has to understand the goal, plan the steps, call external capabilities, observe the results, and revise the plan until the task converges.

    The gap between these two is exactly what the harness is meant to close. Think of the model as the engine, and the harness as the transmission, brakes, cooling system, and body built around it. A lesson that keeps reappearing in engineering practice: with the same model, swapping the harness can change the task success rate by orders of magnitude. This is why the engineering focus of agents is shifting from tuning the model to designing the runtime that hosts it.

    The traditional approach writes all of these capabilities into one large monolithic loop, with model invocation, tool dispatch, history trimming, and permission checks tightly coupled. It looks fast in the short term, but it inevitably rots over time: adding a tool means editing the core loop, switching models means rewriting the adapter layer, and adding audit logging means intruding into business branches.

    2. The Core Principle: Everything Is a Plugin

    The point of a plugin architecture is not that it “supports plugins,” but that it follows the plugin rule all the way through. There are three criteria:

    1. The core runtime has zero knowledge of specific capabilities. It does not know what a “file reading tool” is, nor what “a particular vendor’s model” is.
    2. Capabilities never reference each other; they only declare dependencies. A tool does not import another tool, it only declares “I need the session store service.”
    3. Any capability can be replaced or removed. After removal, the system still starts, only missing the corresponding function.

    Under these principles, four typical categories of capability are abstracted uniformly as plugins:

    • Model adapter layer: normalizes message formats and streaming responses from different vendors and protocols into the runtime’s unified internal message structure, and handles incremental assembly of tool call arguments.
    • Tool registry layer: describes executable capabilities as a manifest with a name, description, and parameter schema for the model to choose from.
    • Session record layer: handles message persistence, context trimming, summary compression, and replay.
    • Main loop layer: drives the “reason-call-observe” iteration and decides the termination condition.

    A schematic plugin declaration can be written as follows; the emphasis is on declaring dependencies rather than hardcoding calls:

    1. plugin: tool-runner
    2. provides: [tool.registry, tool.executor]
    3. depends: [session.store, policy.guard, policy.approval]
    4. lifecycle: [setup, activate, suspend, dispose]

    3. Four Preset Combinations: Understanding Behavioral Differences Through Controlled Experiments

    The fastest way to understand the architecture is to keep the model fixed, change only the combination of capabilities, and observe how behavior changes. In engineering, several presets are usually prepared as baselines:

    • Minimal preset: model adapter plus main loop only. With no tools, the model can only output text, which is useful for validating the streaming pipeline and termination logic.
    • Read-only preset: adds file reading and retrieval tools without exposing write operations. Suitable for code comprehension and log analysis tasks.
    • Full preset: read and write tools plus command execution and a sandbox, capable of end-to-end delivery.
    • Restricted preset: the full toolset with strict approval enabled and a smaller context budget, used to observe how the model’s strategy changes when it is constrained everywhere, for example whether it tends to ask questions before acting.

    The value of this comparison is that it separates attribution between “model capability” and “framework capability.” When a task fails, first determine whether the model chose the wrong tool, whether the tool description was vague, or whether a permission boundary caused the action to be rejected, instead of blaming everything on the model.

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

    Layering the extension points is the key to controlling complexity.

    A Skill is a package of knowledge and process aimed at the model, usually described in structured text covering “in what scenario, following what steps, and what to watch out for.” It does not perform actions; it only affects decision quality, and it is cheap to modify and easy to roll back.

    A Tool is a capability unit that actually produces side effects. Key design points include: descriptions written for the model rather than for humans, parameter schemas kept as flat as possible, return results kept within a controlled size (overly long content should be truncated with locating information), and operations that must be idempotent or compensable.

    A Hook is a cross-cutting concern that inserts observation and intervention logic at key points, such as redacting before a request, recording token usage and latency after a call, and writing diagnostic information on exceptions.

    The relationship among the three can be understood this way: a Skill changes “how to think,” a Tool changes “what can be done,” and a Hook changes “how the process is constrained and observed.”

    5. Execution Boundaries: Guard, Approval, and Sandbox

    Security boundaries must be explicitly layered, in a fixed order: Guard performs static checks (whether parameters are out of bounds, whether a path is within an allowed directory), Approval performs human or policy confirmation (high-risk actions are suspended and wait), and Sandbox performs runtime isolation (filesystem view, network egress, resource quotas).

    1. Request -> Guard (static validation) -> Approval (risk confirmation) -> Sandbox (isolated execution) -> Result normalization -> Session record

    The principle to emphasize is that untrusted input always comes from model output and external content, so validation cannot rely on the caller’s discipline; it must be a mandatory intermediate layer. Missing any of the three layers leads to the classic incident where “the prompt says dropping the database is forbidden, but it can actually be dropped.”

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

    Once all capabilities are plugin-based, a runtime is needed to manage them. An ideal runtime provides four capabilities:

    • Dependency resolution: build a dependency graph from the declarations, start in topological order, and detect circular dependencies.
    • Lifecycle management: unified setup / activate / suspend / dispose phases that guarantee resources are acquired and released in pairs.
    • Dynamic mounting and hot updates: when replacing a plugin, first suspend the old instance, migrate or rebuild state, then activate the new instance, enabling capability upgrades without restarting the process.
    • Service location: plugins obtain services by name rather than referencing objects directly, which makes replacement possible.

    The hard part of hot updates has never been loading new code, but state migration. In practice, plugins are usually required to declare their state explicitly as serializable data, which the runtime exports before dispose and imports after activate, avoiding the loss of in-memory state.

    7. Building and Validating Your Own Harness from the Designer’s Perspective

    For in-house development, follow a clear path: first get the minimal closed loop running (model adapter plus loop plus one read-only tool), then add layers step by step. The validation system should include four types of tests: contract tests (whether tool descriptions and parameter schemas can be parsed correctly), boundary tests (unauthorized paths, overly long output, timeouts and retries), a regression suite (a fixed task set compared for success rate and average number of steps), and observability validation (whether full-chain tracing can reconstruct the basis for each decision).

    If it needs to run in the cloud, you can combine a container platform to run sandboxes, object storage to keep sessions and artifacts, a message queue to smooth out and process asynchronous tasks, and logging services with monitoring and alerting to track quality metrics, so that a single-machine prototype evolves smoothly into an operable system.

    The final conclusion is that the core competitiveness of an agent lies not in prompt techniques, but in whether volatile capabilities can be made into pluggable units and stable scheduling can be made into a minimal kernel. Only when this is achieved can model iteration and business expansion proceed without interfering with each other.