Agent Software Architecture: Principles and Plugin-Based Practice

    This article explains why AI agents need a Harness layer between the model and the product, and how to build one around a plugin-first architecture. It covers model adaptation, capability registration, state and event logging, loop scheduling, layered extensions (skills, tools, and hooks), execution boundaries (guards, approvals, and sandboxes), runtime composition and lifecycle management, observability, and a four-step validation path for building a custom agent runtime.

    1. Why Harness Matters Now

    A large language model does one core thing: predict and generate tokens from an input. It is strong at language understanding, code completion, and structured output, but it does not persist task state, does not invoke external capabilities on its own, and is not accountable for execution results. An agent, by contrast, has to complete tasks: decompose a goal, select tools, execute actions, observe results, and revise the plan until it converges.

    That gap means agent software cannot be just “a model plus a prompt.” It needs a middle layer that connects the two, commonly called a Harness. The Harness interfaces upward with product form and interaction, and downward it hides differences between models, tools, and runtime environments. Its responsibilities fall into four groups:

    • Model adaptation: unify messages, tool calls, streaming output, and error semantics;
    • Capability registration: let tools, skills, and hooks be discovered and invoked in a consistent way;
    • State and records: persist session events to support replay, auditing, and recovery;
    • Loop scheduling: drive repeated think–call–observe iterations and control termination conditions.

    Without this layer, capabilities end up scattered across business code as conditional branches, eventually turning into a monolith that is hard to test, hard to replace, and hard to observe.

    2. Core Principle: Everything Is a Plugin

    “Everything is a plugin” does not mean mechanically fragmenting code. It establishes three engineering constraints:

    1. Pluggable capabilities: model adapters, tool sets, session storage, and loop policies are all replaceable units;
    2. Composition as configuration: product behavior is determined by how plugins are composed, not by hardcoded flows;
    3. Declarable boundaries: each plugin explicitly declares its dependencies, scope, and side effects.

    The key payoff: the same model behaves very differently under different capability combinations. In practice, these combinations are fixed as Presets, for example:

    • Standard preset: the full tool set with relatively strict approvals, suited to general tasks;
    • Minimal preset: only the basic loop, used to observe the model’s native tendencies;
    • Creative preset: looser constraints and a wider tool surface, used for exploratory work;
    • Controlled preset: emphasis on permissions and sandboxing, suited to high-risk environments.

    Comparing behavior across presets is the cheapest and most effective way to understand agent architecture.

    3. Layered Extensions: Skills, Tools, and Hooks

    Internally, extension points need to be layered so that not everything is crammed into tools:

    • Skill: a task-facing method or process description that tells the agent how to do something, usually a reusable strategy asset;
    • Tool: an action-facing atomic capability with a clear input/output schema and side effects, telling the agent what it can do;
    • Hook: a process-facing interception point that injects validation, logging, or rewriting before and after calls, telling the system what must happen and when.

    The three layers only close the loop together: skills decide the path, tools perform the actions, and hooks enforce compliance and observability.

    4. Execution Boundaries: Guard, Approval, and Sandbox

    High-risk actions must be constrained within explicit boundaries. Three common lines of defense:

    • Guard: static and dynamic checks that block unauthorized parameters, dangerous paths, and abnormal call rates;
    • Approval: human or policy confirmation for irreversible or high-cost actions;
    • Sandbox: limits on filesystem, network, and resource quotas to keep the cost of failure bounded.

    The design principle is “deny by default, open up on demand,” and every interception should produce a structured record for traceback and tuning.

    Illustrative policy sketch (pseudocode):

    1. policy for tool "write_file":
    2. if path outside workspace: deny(reason="out of bounds")
    3. if size > limit: require_approval()
    4. else: allow(sandbox=workspace)

    5. Runtime: Dynamic Composition and Lifecycle

    For pluginization to work in practice, the runtime must provide two kinds of composability:

    • Composition over time: plugins can be mounted, unmounted, and hot-updated at runtime without restarting the loop;
    • Composition over space: scope context decides which target a plugin applies to, avoiding global pollution.

    The runtime must also handle dependency re-resolution: when a plugin is replaced or removed, the dependency graph is recomputed, its side effects are migrated or reclaimed, and lifecycle is maintained by Fiber-style execution units so that interruption, exceptions, and cancellation all converge cleanly.

    Three disciplines to hold in engineering: side effects must be reclaimable; dependencies must be explicit; state and effects must be separated.

    6. Loop, Event Log, and Observability

    An agent loop is essentially a finite state machine: receive input → request the model → parse actions → execute tools → append observations → decide whether to terminate. Writing every step of the process to a session event log yields three capabilities: replay for locating problems, auditing for compliance, and recovery for long-running tasks.

    Implementation advice: define a stable schema for events, recording model version, plugin composition, policy decisions, and elapsed time; pair it with a general logging service and monitoring alerts to form a complete chain from metrics to traces.

    7. Design Path: How to Validate a Custom Runtime

    From a designer’s perspective, building your own Harness can proceed in four steps:

    1. Define the minimal loop: only the loop, tools, and logging;
    2. Introduce composition: turn capabilities into plugins with configuration-based assembly;
    3. Complete boundary governance: add guards, approvals, and sandboxes;
    4. Establish an evaluation baseline: use a fixed task set to compare success rate, cost, and number of risk events across presets.

    Advanced capabilities such as code-mode execution, sub-agent collaboration, workflow orchestration, and runtime mutability should only be introduced after the baseline and boundaries are solid; otherwise they simply amplify uncontrollability.

    8. Conclusion

    Competition in agent software is shifting from “model choice” to “organization.” Making capabilities plugins, composition configuration, boundaries declarations, and processes logs is what moves agents from demos to operable, governable engineering systems. If you need to carry large-scale tool calls and trace data, you can build an elastic foundation on general cloud container platforms, object storage, and logging and monitoring services, while architectural judgment stays in your own hands.