Everything Is a Plugin: Designing and Building an Agent Runtime Framework

    A well-designed agent runtime framework (agent harness) determines whether a large language model's capabilities can be released reliably, controllably, and reusably. This article explores the "everything is a plugin" philosophy, under which model access, tools, skills, sessions, sandboxes, storage, the main loop, scheduling, and even the user interface are all implemented as freely replaceable and recomposable plugins. It explains how a thin meta-framework manages the plugin lifecycle through service and event routing and a reversible side-effect mechanism, how a complete agent is decomposed into capability plugins, and how different assembly strategies yield four distinct run modes. It also outlines a configuration-first developer onboarding path that lets teams build differentiated agents without modifying framework source code.

    1. Why We Need an Agent Runtime Framework

    A large language model is essentially a “reasoning kernel.” It excels at understanding intent, generating text and code, and performing multi-step reasoning. However, it cannot directly read or write files, call external APIs, control browsers, query databases, or reliably maintain state across long-running tasks. To take a model from “talking” to “doing,” you need to wrap it with a layer of engineering capability. This layer is commonly called an agent harness.

    The industry has converged on a formula that has been validated repeatedly:

    1. Model + Harness = Agent

    In this formula, the model handles decision-making and reasoning, while the harness handles execution and orchestration. The former sets the upper bound of the agent’s capability; the latter determines whether that capability can be released reliably, controllably, and reusably. A good harness therefore should not hardcode model capabilities. Instead, it should open up the question of “how to combine capabilities” to developers. This is exactly the problem the “everything is a plugin” philosophy aims to solve.

    2. Core Philosophy: Everything Is a Plugin

    Traditional agent frameworks typically adopt a “kernel plus a few extension points” structure: the core scheduling logic is fixed, with plugin interfaces exposed only at a handful of points. This approach is quick to adopt, but as soon as requirements exceed the preset boundaries, developers are often forced to modify source code, which leads to difficult upgrades and rigid composition.

    “Everything is a plugin” pushes openness to the extreme. Under this philosophy, every capability an agent needs to run — model access, toolsets, skills, session management, sandbox, storage, the main loop, task scheduling, and even the final interface presented to users — exists as a plugin that can be freely replaced and reassembled on demand. In other words, the framework itself is no longer a “collection of features” but a “capability assembly platform.”

    This design delivers three direct benefits:

    • Replaceability: Swapping the underlying model, switching the storage backend, or replacing the UI requires only replacing the corresponding plugin, with no changes to the rest.
    • Composability: Different teams can build differentiated agents for different scenarios (coding, retrieval, operations) on the same foundation.
    • Evolvability: Framework upgrades and plugin iterations are decoupled, avoiding the coupling risk of “change one place, break everything.”

    3. Architecture: How the Meta-Framework and Plugins Divide Responsibilities

    To make “everything is a plugin” practical, you need a lightweight foundation to carry the plugin lifecycle. The common approach is to introduce a “meta-framework” that does only three things:

    1. Loading and unloading plugins: Assembling plugins according to configuration and safely removing them when needed.
    2. Dependency management: Identifying dependencies between plugins, ensuring correct assembly order, and avoiding circular dependencies.
    3. Routing services and events: Providing communication channels for plugins to collaborate.

    The meta-framework itself carries no specific business capability. The actual model, tools, sessions, UI, and so on are all distinct plugins. This “thin kernel, thick plugins” division is the fundamental reason the whole architecture can remain flexible.

    3.1 Collaboration Through Services and Events

    Plugins do not reference each other directly. Instead, they collaborate through two loosely coupled mechanisms:

    • Service: A plugin exposes a capability (such as “sandbox execution” or “session state”), and other plugins obtain a handle to that service through a dependency declaration in order to call it.
    • Event: A plugin publishes an event (such as “task started” or “tool call finished”), and plugins that care about that event subscribe to it and respond, forming a publish-subscribe pattern of decoupled coordination.

    The benefit of this mechanism is that a plugin only needs to declare “what services I depend on” and “what events I care about” without knowing the specific implementation of the other party, enabling free composition at the configuration layer.

    3.2 Reversible Side Effects

    Plugins modify external state while running: registering tools, writing to storage, starting background tasks, mounting interface elements, and so on. Collectively, these are called “side effects.” When a plugin is unloaded or replaced, if these side effects are not cleared, “dirty state” remains and causes problems that are hard to diagnose.

    For this reason, a mature plugin framework introduces a reversible side-effect mechanism: every side effect produced when a plugin is activated is recorded, and on unload it is automatically undone in reverse order, ensuring “what goes on comes off” and the environment always returns to a clean state. This is similar to transaction rollback semantics and is a key prerequisite for safe hot-swapping of plugins.

    The following sample code illustrates the basic structure of a plugin and the “declare dependencies — register capabilities — roll back side effects” collaboration model (pseudocode, for illustrating the design pattern only):

    1. // Sample code: structure of a "file search tool" plugin
    2. export const fileSearchPlugin = {
    3. name: 'file-search-tool',
    4. // Dependency declaration: requires the session and sandbox services
    5. inject: ['session', 'sandbox'],
    6. apply(ctx) {
    7. // Register a tool capability with the framework; the registration itself is a side effect
    8. ctx.tools.register({
    9. name: 'search',
    10. handler: async (query) => {
    11. // Run the search in an isolated sandbox service to avoid polluting the main environment
    12. return ctx.sandbox.run({ query });
    13. },
    14. });
    15. // Subscribe to an event: record context when a tool call finishes
    16. ctx.events.on('tool:done', (payload) => {
    17. ctx.session.append(payload);
    18. });
    19. },
    20. // Called by the meta-framework on unload; automatically undoes the side effects registered in apply
    21. dispose() {
    22. // No manual cleanup needed: the framework rolls everything back based on the reversible side-effect records
    23. },
    24. };

    4. Decomposing Capabilities into Plugins

    In a world where everything is a plugin, a complete agent can be decomposed into several replaceable capability plugins:

    • Model plugin: Connects to the underlying large model and can switch between models from different vendors and of different scales.
    • Tool plugin: Wraps atomic capabilities that the model can invoke, such as retrieval, code execution, and API requests.
    • Skill plugin: Orchestrates multiple tools into higher-level “skills” that provide combined capabilities for specific tasks.
    • Session plugin: Manages multi-turn conversation context, message history, and state.
    • Sandbox plugin: Provides an isolated execution environment and enforces the safety boundary for running code and commands.
    • Storage plugin: Handles persistence and can connect to general storage options such as local files or backend object storage.
    • Loop and scheduling plugin: Drives the “think — act — observe” main loop and manages task orchestration and scheduling.
    • Interface plugin: Presents the running process and results to users, such as a web interface or a command-line interface.

    Each plugin can be replaced independently. For example, simply swapping the sandbox plugin can change the execution environment from a local container to a stronger isolation solution, without affecting the other components.

    5. Four Run Modes: Assembly Strategies for Different Scenarios

    The same plugin foundation can present itself as multiple run modes through different assembly and scheduling strategies, adapting to needs that range from “precisely controllable” to “freely creative.” The four typical modes are as follows:

    • Standard mode: The most complete set of capabilities, including tool calling, session management, and multi-step planning — suitable for general-purpose, end-to-end complex tasks.
    • Programmatic tool-calling mode: Tool-call flows are orchestrated by a program rather than the model — suitable for scenarios with relatively fixed processes and high demands for determinism and reproducibility, reducing the uncertainty introduced by the model’s free improvisation.
    • Minimal mode: Only the core loop and a few tools are assembled, stripping away redundant capabilities — fast to start and low in overhead, commonly used for capability evaluation and lightweight tasks.
    • Creative mode: Constraints are relaxed to encourage the model to plan and explore autonomously — suitable for open-ended, exploratory tasks.

    The essence of a mode is different combinations and scheduling of the same set of plugins. Developers can either use the preset modes or define their own assembly schemes based on plugins.

    6. Getting Started for Developers

    Thanks to the loose coupling and standardization of the plugin architecture, the onboarding cost is significantly reduced. The general path is as follows:

    1. Prepare the runtime: Work in a development environment equipped with a mainstream JavaScript runtime and a package manager.
    2. Launch the interface quickly: Using the package manager’s on-the-fly run command, you can directly bring up the framework’s web interface and quickly experience agent behavior across different modes.
    3. Choose or replace plugins: Declare the plugins you need through a configuration file to freely assemble the model, tools, storage, and more.
    4. Write custom plugins: Implement apply to register capabilities and inject to declare dependencies, and you can plug your own capabilities into the framework; cleanup on unload is handled automatically by the reversible side-effect mechanism.

    With this “configuration first, code as supplement” approach, developers can build agents that fit their own business needs without modifying the framework’s source code.

    7. Value and Outlook

    An agent runtime framework built on “everything is a plugin” essentially turns an agent from “a finished product” into “a system of assemblable parts.” It lowers the barrier to building agents and makes capability reuse and ecosystem collaboration possible: model vendors contribute model plugins, tool providers contribute tool plugins, and teams take what they need and assemble freely.

    From an industry perspective, this kind of framework marks a shift in the center of competition from “model capability” to “workflow solutions” — whoever can more efficiently turn model capabilities into stable, controllable, reusable agent workflows gains the initiative in real-world deployment. For developers, mastering the plugin-based design philosophy and understanding key mechanisms such as the meta-framework, services and events, and reversible side effects will be core to building your own technical moat in this trend.