Everything as a Plugin: Architecture and Practice for Agent Runtime Harnesses

    This article explains why an agent is best understood as Model + Harness, identifies where plugin boundaries should be placed in an agent runtime, outlines key mechanisms such as discovery, lifecycle management, least privilege, isolation, state consistency, observability, and fallback contracts, walks through a simple plugin implementation, and offers a production-readiness assessment with a staged adoption checklist.

    1. Positioning: Agent = Model + Harness

    When discussing agent systems, many teams focus on model capability: parameter scale, reasoning quality, context length, and tool-calling accuracy. In real business scenarios, however, the model is only the part that “thinks.” What actually enables an agent to “do work” is the runtime harness around the model. An agent can be abstracted into a simple formula:

    Agent = Model + Harness

    The Model handles understanding, reasoning, and generation. The Harness—the agent runtime framework—handles context organization, tool invocation, task planning, execution scheduling, sandbox isolation, state storage, loop control, session management, and observability. Without a Harness, a model can only output text. With a Harness, the model can read files, call APIs, execute tasks, handle errors, and maintain state across multiple turns.

    Traditional intelligent coding tools often tightly integrate the model, toolchain, and interaction experience into an end-to-end product. This approach is easy to use out of the box, but it is highly coupled: models are difficult to replace, tool protocols are opaque, and the execution loop and state management are usually fixed inside the product. A plugin-based agent runtime takes a different path: it moves the model from the center and turns it into a replaceable component. Tools, planners, schedulers, sandboxes, storage, loops, and sessions can also be replaced according to contracts.

    The core value of this type of framework is not “building a stronger coding agent,” but providing a composable runtime. It is not simply a replacement for intelligent coding tools; the two sit at different abstraction layers. The former focuses on pluggable architecture and composition, while the latter focuses on interaction efficiency in specific scenarios. Through adapters, existing intelligent coding tools can be wrapped as sub-agents or tools, but attention must be paid to process isolation, permission boundaries, and result validation.

    2. Where “Everything as a Plugin” Applies

    “Everything as a plugin” does not mean writing all code as plugins. It means abstracting the key capabilities in agent operation into replaceable parts. Typical plugin boundaries include:

    1. Model provider plugins: encapsulate invocation protocols, authentication, retries, streaming output, and cost statistics for different model services. The upper-level loop does not care about the specific model source and depends only on a unified inference interface.
    2. Tool plugins: encapsulate file read/write, network requests, database queries, build and deployment, and other capabilities as tools with input/output contracts. Tools must declare capabilities, permissions, timeouts, and error semantics.
    3. Task planner plugins: break user goals into subtasks or select a more suitable planning strategy. Simple scenarios can use rule-based planning, while complex scenarios can switch to model-driven planning.
    4. Scheduler plugins: decide whether subtasks run serially or in parallel, their priorities and dependencies, and handle failure retries, cancellation, and degradation.
    5. Sandbox plugins: provide process, container, or lightweight virtualization isolation, and restrict file, network, and system call permissions.
    6. Storage plugins: save session state, long-term memory, task artifacts, and audit logs, and connect to object storage, databases, or local file systems.
    7. Agent Loop plugins: control the “observe—think—act—feedback” loop strategy, including maximum turns, stop conditions, tool selection strategy, and exception recovery.
    8. Session plugins: manage multi-turn context, user identity, tenant isolation, and message history.
    9. Observability and policy plugins: collect traces, logs, metrics, cost, and security policies to support production governance.

    The key to pluginization is not only “replaceability” but also “composability.” Each plugin needs to declare capabilities, version, permissions, resource quotas, and dependencies. The framework needs to provide a unified context, message model, tool invocation protocol, error semantics, timeout cancellation, and idempotency conventions. Otherwise, the more plugins there are, the harder the system becomes to maintain.

    3. Key Mechanisms of a Plugin-Based Architecture

    A usable plugin-based runtime framework should have at least the following mechanisms:

    First, discovery and resolution. Plugins can come from local directories, registries, or manifest files. The framework needs to parse plugin manifests and validate versions, dependencies, signatures, and compatibility to avoid loading components from unknown sources.

    Second, lifecycle management. Plugins usually need initialization, startup, health checks, execution, unloading, and resource reclamation. Hot replacement must be handled carefully because running sessions may hold state from old plugins. In production, blue-green switching or session-isolated versions are more reliable approaches.

    Third, capability declaration and least privilege. Tool plugins should not have full file and network permissions by default. Plugins should declare required capabilities, such as read-only files, restricted network access, or a specific key alias. The framework grants authorization at load time and audits usage at runtime.

    Fourth, execution isolation and fault domains. High-privilege tools should run in sandboxes with limits on CPU, memory, disk, network, and timeout. A plugin crash should not bring down the entire Agent Loop. The scheduler needs to catch errors and perform degradation or rollback.

    Fifth, state and consistency. Session state, task artifacts, and long-term memory should be stored in layers. Short-term context can live in memory or high-speed storage, long-term artifacts can go into object storage, and audit logs can go into a logging service. Tasks involving side effects need idempotency keys and compensation logic.

    Sixth, observability. Every plugin invocation should produce traces, logs, and metrics, recording input summaries, output summaries, latency, cost, and error codes. Without plugin-level observability, problems in a composed system are almost impossible to locate.

    Seventh, composition contracts and fallback. Multi-model routing, tool degradation, and loop strategy replacement should all have explicit policies. For example, switch to a backup model after the primary model times out, and return structured errors after a tool fails instead of letting exceptions propagate through the system.

    4. What It Is Like to Write a Plugin

    Writing a simple plugin is not complicated. The hard part is making it production-ready. At an abstract level, plugin development usually includes six steps: define the plugin type and boundary; write the manifest and capability declarations; implement adapter logic; handle timeouts, cancellation, and errors; integrate logging and metrics; and write contract tests and package/sign the plugin. The following schematic code illustrates the idea; actual interfaces should follow the framework documentation.

    1. type PluginKind =
    2. | "model" | "tool" | "planner" | "scheduler"
    3. | "sandbox" | "storage" | "loop" | "session";
    4. interface PluginManifest {
    5. name: string;
    6. version: string;
    7. kind: PluginKind;
    8. capabilities: string[];
    9. permissions: string[];
    10. }
    11. interface RuntimePlugin {
    12. manifest: PluginManifest;
    13. init(ctx: PluginContext): Promise<void>;
    14. execute(input: PluginInput, ctx: PluginContext): Promise<PluginOutput>;
    15. healthCheck?(): Promise<{ ok: boolean }>;
    16. dispose?(): Promise<void>;
    17. }

    A schematic implementation of a restricted network request tool plugin is shown below:

    1. const httpTool: RuntimePlugin = {
    2. manifest: {
    3. name: "http-fetch",
    4. version: "1.0.0",
    5. kind: "tool",
    6. capabilities: ["network:https"],
    7. permissions: ["net:outbound"]
    8. },
    9. async init(ctx) {
    10. ctx.logger.info("http-fetch initialized");
    11. },
    12. async execute(input, ctx) {
    13. const { url } = input as { url: string };
    14. const controller = new AbortController();
    15. const timer = setTimeout(
    16. () => controller.abort(),
    17. ctx.budget.timeoutMs
    18. );
    19. try {
    20. const res = await ctx.http.get(url, { signal: controller.signal });
    21. return { ok: res.ok, data: res.body };
    22. } finally {
    23. clearTimeout(timer);
    24. }
    25. },
    26. async dispose() {}
    27. };

    The important part of this code is not the interface names, but the engineering constraints: plugins must declare permissions, accept timeout budgets, be cancellable, and convert errors into structured results. A simple adapter may take half a day to write, but a production-grade plugin also needs contract tests, permission audits, fault injection, cost statistics, and version compatibility validation. The plugin framework experience is “easy to integrate, hard to govern.” Governance capability is what really determines whether it can be adopted.

    5. Under the Hype: Is It Ready for Production?

    The conclusion is that it is worth studying and piloting, especially for reading its architecture design, but it is not recommended to connect it directly to core production paths at present. There are five main reasons: plugin protocols and ecosystems are still evolving, and interface stability needs validation; plugin quality varies, creating significant supply chain security risks; high-privilege tools require strong sandboxes and auditing, otherwise they can amplify operational mistakes; composed systems have long chains, raising observability and fault-localization costs; and pluginization adds an abstraction layer, so performance and operational overhead need to be measured.

    Production admission can use a staged strategy. Low-risk internal development assistance can be piloted first. Medium-risk automation tasks can use shadow traffic, whitelisted tools, read-only permissions, and human confirmation. High-risk production operations, sensitive data processing, and core paths with strong compliance requirements should be deferred. For infrastructure, teams can use general-purpose container platforms, object storage, logging, and monitoring/alerting capabilities from cloud providers such as Baidu AI Cloud, but network isolation, key management, and audit policies must be configured according to enterprise security requirements.

    Before adoption, prepare a checklist: scenario classification, permission whitelist, sandbox isolation, timeout budget, idempotent retry, rollback plan, cost quota, evaluation set, plugin signing, log audit, and fault drills. Only when these governance capabilities are in place will the composability advantage of “everything as a plugin” become engineering productivity rather than a new source of complexity.