Rethinking Agent Framework Architecture: Microkernel + Plugins

    A look at how a microkernel-based, plugin-first design rethinks the Agent framework: no privileged core, reversible effects, reactive capability dependencies, and five core abstractions that make agent runtimes dynamically composable.

    1. Why Agent Frameworks Need an Architectural Rethink

    In most common Agent development frameworks, the Agent Loop sits at the center of the system. The framework ships with a fixed pipeline: receive user input, assemble the prompt, call the model, execute tools, feed results back, and loop again. Developers can swap models and register tools, but the loop itself, session management, file access, and approval flows are usually hard-coded into the framework’s core.

    This “fat kernel” design works fine for rapid prototyping, but it shows clear weaknesses once agents move to production:

    1. High customization cost: Replacing local file access with sandboxed container execution often requires forking the framework or patching around the kernel in invasive ways.
    2. Tight coupling between capabilities: Session storage, model invocation, and tool registration depend on each other, so replacing one piece can ripple through the whole system.
    3. Uncontrollable lifecycles: Dynamically loading or unloading a capability at runtime (such as temporarily attaching a new tool set) lacks any mechanism to guarantee clean state, often leaving residue behind.

    A recently open-sourced framework offers a radical answer: the framework kernel contains no “privileged capabilities” at all — everything exists as a plugin. This idea deserves careful study from every Agent developer.

    2. Microkernel Architecture: No Irreplaceable Core

    The framework is built on a plugin-based runtime container in the TypeScript ecosystem. Its design motto can be summarized as: “no privileged kernel that needs patching“. This means all of the following capabilities are pluggable plugins:

    • Model adapters (ctx.llm): connecting to different LLM services;
    • Tool registration (ctx.tools): tool discovery, registration, and invocation;
    • Session storage (ctx.sessions): how session logs are persisted;
    • The Agent main loop (ctx.agentLoop): even the loop itself can be replaced;
    • File system (ctx.fs): local FS, remote FS, or container FS, freely switchable;
    • Sandbox (ctx.sandbox): isolation strategies for command execution environments;
    • Sub-agent providers: delegation and scheduling of subtasks;
    • Prompt assembly: even prompt construction allows plugin interception and rewriting.

    In a structural view, the kernel keeps only the minimal runtime capabilities:

    1. ┌─────────────── Microkernel ───────────────┐
    2. │ Runtime context / effect management / │
    3. │ event bus / loader │
    4. └───────────────┬─────────────────────────────┘
    5. │
    6. ┌──────────┬──────────┼──────────┐
    7. │ │ │ │
    8. LLM providers Tool runtime Session storage Agent Loop / FS / Sandbox ...
    9. (all are plugins)

    In essence, it is more like an Agent Runtime than a traditional Agent Framework: the framework does the “wiring”, while plugins supply the “power”.

    3. Key Mechanism 1: Temporal Composability — Reversible Effects

    For a microkernel with dynamic plugging to actually work, a classic problem must be solved: when a plugin is unloaded, how does everything it registered disappear cleanly?

    A plugin typically performs a series of registration actions when loaded:

    • Registering several tools;
    • Subscribing to event listeners;
    • Injecting a section into the prompt;
    • Registering a model adapter;
    • Starting background services.

    If these actions are irreversible, unloading a plugin leaves behind “ghost tools” and “ghost listeners” that pollute the runtime. The framework models every registration action as a revertible effect: the loader records a corresponding undo function for each effect when the plugin loads, and rolls them back in order on unload, restoring the runtime to its original state.

    This follows the same philosophy as an OS kernel reclaiming resources when a process exits, or a React component running cleanup on unmount — but elevated to a first-class citizen at the framework level. The engineering lesson: any dynamically registered capability should be born with a corresponding “un-register” capability. This is a prerequisite for building hot-pluggable systems.

    4. Key Mechanism 2: Spatial Composability — Capability-Oriented Dependency Declaration

    The second problem: when service B, which plugin A depends on, is replaced or unloaded, how does A respond automatically?

    The traditional approach has plugin A directly reference the concrete implementation of B, creating static coupling. The framework instead adopts the idea of reactive coeffects: plugins declare only “what capability I need”, not “who provides it”. For example, a tool can declare its dependencies like this:

    1. // The tool only declares capability requirements, not implementation sources
    2. dependencies: ['ctx.fs', 'ctx.sandbox', 'ctx.approval']

    Whether that ctx.fs is backed by a local file system, remote object storage, a container file system, or a file service with ACL permission control — the provider decides “where the capability executes”, and the tool is completely unaware. When a provider is dynamically replaced, dependent components can automatically perceive and adapt through the reactive mechanism.

    This is the classic “program to interfaces, not implementations” principle applied at scale inside an Agent runtime — essentially a highly generalized dependency injection container.

    5. Five Core Abstractions: A Complete Conceptual Model

    The framework’s design documentation distills the entire system into five core concepts:

    Concept Responsibility
    Plugin The carrier and packaging unit of capabilities
    Context Runtime context; the injection channel for capabilities
    Service Dependency Declarative dependency relationships
    Typed Event A typed event bus for decoupled inter-component communication
    Reversible Effect Reversible side effects ensuring clean dynamic load/unload

    In terms familiar to programmers, the system is roughly equivalent to:

    Dependency injection container + plugin system + event bus + lifecycle management + side-effect management + configurable component tree

    6. Takeaways

    Beyond the specific implementation, this architecture sends three signals worth borrowing:

    1. The Agent Loop doesn’t have to be the center. When the loop itself becomes a plugin, the same runtime can host paradigms ranging from a “simple ReAct loop” to “complex multi-agent orchestration”, greatly improving framework adaptability.
    2. Separation of capability declaration and capability execution. Tools only describe “what I need”; providers decide “where it executes”. This lets the same Agent code run seamlessly across local dev machines, container sandboxes, and isolated cloud environments — especially important for security and compliance scenarios.
    3. Dynamic composability will become standard for Agent infrastructure. As agents evolve from one-off scripts to long-running systems, runtime hot-plugging, dependency reactivity, and state rollback will shift from “nice to have” to “must have”.

    Of course, a microkernel architecture has its costs: more abstraction layers, longer debugging chains, and extremely high demands on how plugin boundaries are defined. Whether to adopt it depends on whether your agent needs long-term evolution, multi-environment deployment, and deep customization. But regardless of whether you use it directly, understanding this “everything is a plugin” design philosophy will help you write more decoupled, more evolvable Agent systems.