Inside an Agent Framework's Core: From Plugin Container to Spacetime Composition

    When you peel back the layers of an agent framework, you first see the upper modules—models, tools, memory, and the agent loop. Dig deeper and you find a runtime kernel that wires them together and manages their lifecycles and dependencies. This article explains why treating that kernel as a mere plugin framework underestimates it: drawing on the concepts of spatial and temporal composition, it shows how the kernel actually solves a more fundamental problem—how components can depend on each other in space and evolve over time while the system stays reliable, observable, and recoverable. It covers dependency graphs, scoped lifecycles, hot-swapping with draining and rollback, event-sourced session state, and practical design guidelines for developers and architects building production-grade agent systems.

    Inside an Agent Framework’s Core: From Plugin Container to Spacetime Composition

    Peel an agent framework apart layer by layer, and the first things you see are the upper-level modules: models, tools, memory, and the agent loop. Go one level deeper and you find a runtime kernel responsible for composing them and managing their lifecycles and dependencies.

    On first contact, it’s easy to mistake this kernel for a “plugin framework”: every capability registers itself into a shared context and can be loaded, unloaded, and replaced. That reading isn’t wrong, but stopping there greatly undervalues what the kernel does. Read further—especially through the 88-page paper on spacetime compositionality, combined with the hot-swapping and event-log mechanisms in the source code—and you realize that “plugin framework” is just the shell. Underneath, the kernel is solving a more fundamental problem: how can components depend on one another in space and evolve over time, while the system remains reliable, observable, and recoverable?

    1. The Limits of the Plugin Framework View

    The word “plugin” naturally evokes registries, extension points, and load/unload semantics. The core promise of a plugin system is that the host depends only on abstract interfaces, never on concrete implementations; plugin developers implement the agreed interfaces, and the host wires them in at runtime. This model is mature in domains like editors and build tools, but it falls short in agent scenarios.

    The reason is that components in an agent are not a flat set of peer plugins:

    • Tools need to call the model;
    • Memory depends on the current session’s context;
    • The agent loop orchestrates tools, memory, and the model all at once;
    • The event log is written to jointly by memory and the loop.

    These are directed dependencies, not flat entries in a registry. A simple plugin manager doesn’t know “who initializes first, who gets destroyed first,” nor what state downstream dependents will observe when a component is replaced.

    More importantly, agent execution is a long-running, stateful process. A user may hold dozens of conversation turns in a single session, during which tool implementations, memory strategies, and model routing may all change. If you treat these as plain plugins, upgrading a component is like swapping a part mid-flight: with no dependency ordering, no state migration, and no failure rollback, one swap can corrupt the session.

    2. Spatial Composition: Organizing Components into a Dependency Graph

    “Spatial composition” answers the structural question: at any given moment, which components make up the system, how are they connected, and how are their dependencies resolved and managed?

    In a mature runtime, components are not dropped into one big dictionary; they are modeled as a dependency graph. Each component is a node, and each dependency is a directed edge. When registering a component, you declare not only “what I am” but also “what I need” and “which scope my lifecycle belongs to.”

    Illustrative code:

    1. runtime.register({
    2. name: 'llm',
    3. scope: 'singleton',
    4. factory: ctx => createLlm(ctx.config)
    5. });
    6. runtime.register({
    7. name: 'toolRegistry',
    8. scope: 'singleton',
    9. deps: ['llm'],
    10. factory: ctx => new ToolRegistry(ctx.llm)
    11. });
    12. runtime.register({
    13. name: 'memory',
    14. scope: 'session',
    15. deps: ['sessionContext', 'eventLog'],
    16. factory: ctx => new SessionMemory(ctx.sessionContext, ctx.eventLog)
    17. });
    18. runtime.register({
    19. name: 'agentLoop',
    20. scope: 'session',
    21. deps: ['llm', 'toolRegistry', 'memory'],
    22. factory: ctx => new AgentLoop(ctx.llm, ctx.toolRegistry, ctx.memory)
    23. });

    What the container receives is a directed graph, not an array of strings. It can perform topological sorting automatically: create the config object first, then the model client, then the tool registry; once the session scope begins, create the session context and event log first, then the memory component and the agent loop. The runtime can also detect circular dependencies and fail fast at startup, rather than letting a call hang somewhere deep in the call path.

    Spatial composition also shows up in scope design:

    • singleton: one instance shared across the entire runtime—suitable for expensive, session-independent components like model clients and config objects;
    • session: one instance per session—suitable for components that need isolation, such as memory, context, and conversation state;
    • transient: a new instance per task or per call—suitable for lightweight, stateless, short-lived tool objects.

    This maps to real business needs far better than a plain plugin registry. The same model interface may be reused by multiple tools; the same session memory must never be cross-wired to another user; and a temporary computation result shouldn’t linger in memory long-term.

    Even more important: when a component is replaced, its dependents still reference the same logical name. The agent loop, for example, doesn’t care which vector retrieval strategy the memory component uses—it depends only on the abstract interface. When a new implementation is registered under the same logical node, the dependency graph doesn’t need to be redrawn and dependents don’t need code changes. This style of replacement is far more robust than “uninstall the old plugin, install the new one,” because it preserves semantic continuity for downstream consumers.

    3. Temporal Composition: Lifecycles, Hot-Swapping, and Event Logs

    If spatial composition defines “what the system looks like at a given moment,” temporal composition defines “how those components travel from the past into the future.”

    A component’s lifecycle can be modeled explicitly as multiple phases: register, create, initialize, run, drain, stop, destroy. The order isn’t arbitrary—it’s derived from the dependency graph: bottom-up on startup, top-down on shutdown.

    For example, on shutdown the agent loop should stop accepting new tasks first, then the tool registry stops, and finally the underlying model client closes. Do it in reverse—close the model first while upper-layer tools are still calling it—and you get the classic “the dependent is still working, but the dependency is already gone” reference error.

    The hardest part of temporal composition isn’t startup; it’s replacement while the system is running.

    Hot-swapping is not just swapping an object in a registry. A usable replacement protocol includes at least these steps:

    1. The new version registers with the runtime but doesn’t receive real traffic yet;
    2. Dependents migrate to the new version gradually—by traffic percentage (canary) or by session;
    3. The old version enters a draining state: it accepts no new tasks and only finishes in-flight requests;
    4. Only after the new version is verified does the old version get destroyed;
    5. If the new version fails to initialize or misbehaves at runtime, dependents can roll back to the old version.

    This mechanism matters enormously for agent systems. A production agent service may be running tens of thousands of sessions concurrently. If upgrading a memory component, a tool implementation, or model routing requires a full restart, every active session is interrupted. Without draining, in-flight tool calls fail outright. Without rollback, a single misconfiguration can take the whole platform down.

    The session event log is the key enabler of temporal composition. Per session, it appends events: session created, user message, tool call, tool result, model output, state update, component version switch, and so on. Each event carries at minimum a session ID, sequence number, timestamp, event type, and payload.

    With the event log, the system can restore session state after a component swap:

    • When the new memory component starts, it reads the session’s event stream from the log;
    • If a snapshot exists, it restores from the snapshot plus incremental events;
    • If no snapshot exists, it replays from the beginning;
    • The old memory component enters read-only draining and produces no new state;
    • Only after the new component is verified consistent does it officially take over subsequent events.

    The event log is not ordinary logging. It’s not just for troubleshooting—it is the source of truth for state changes. Because every state transition lands in the event stream, components don’t need to hold large amounts of global mutable state internally. Even if the process crashes, the session can be recovered from the log; even if a component implementation is broken by a bad change, replay can pinpoint exactly which event introduced the problem.

    4. Why It’s More Than a Plugin Framework

    Put a “plugin framework” and a “spacetime-composition runtime” side by side, and the differences become clear.

    Dimension Traditional Plugin Framework Spacetime-Composition Runtime
    Component relationships Flat registration, lookup by name Dependency graph, scopes, automatic ordering
    Lifecycle Load / unload Create, initialize, run, drain, destroy
    State management Each plugin manages its own Event log + container coordination
    Replacement Uninstall, then reinstall Old and new coexist, draining, rollback
    Core goal Feature extensibility Continuous system evolution

    A traditional plugin framework answers “can the system be extended?” A spacetime-composition runtime answers “can the system remain stable while continuously changing?”

    From this perspective, models, tools, memory, and the agent loop are merely “the entities being composed.” What truly matters is how the runtime manages the dependencies, ordering, state, and versions among them. Plugin-ability is only part of what the system exposes externally—not the whole story.

    5. Practical Advice for Developers and Architects

    If you are designing or evaluating an agent framework, use the following questions to test whether it has genuine spacetime-composition capability:

    1. When registering a component, do you declare only its interface—without dependencies and scope?
    2. Is initialization order derived automatically from the dependency graph, or specified manually by developers?
    3. When replacing a component, is there a draining mechanism, version switching, and failure rollback?
    4. Can session state be rebuilt from the event log, rather than living only in in-memory objects?
    5. Is teardown order executed in reverse dependency order?

    For developers, several practical principles apply:

    • Don’t read global variables inside components; obtain dependencies through injection;
    • Don’t encode initialization logic via registration order; declare dependencies explicitly;
    • Don’t keep session state only in memory objects; write critical state changes to the event log;
    • Don’t assume a component will never be replaced; design state boundaries to be replaceable, rollback-able, and recoverable.

    For production environments, this kind of runtime design is especially important. Enterprise-grade agent services typically carry long sessions, high concurrency, and frequent version updates. “Upgrades without interruption, recoverable failures, auditable operations” are baseline requirements. Getting component lifecycles and the event log right determines the ceiling of system stability far more than simply shipping more plugins.

    So the underlying kernel is not yet another plugin framework. It is a more rigorous modeling of “composable systems”: in space, components connect through a dependency graph; in time, they evolve through lifecycles and the event log. Once you understand this, the word “plugin” will no longer block your view when you look at the bottom of an agent framework.