Plugin Agent Harness Architecture: Runtime Plugin Graph and Append-Only Event Stream

    This article breaks down a plugin-based agent harness architecture built around two parallel layers: a runtime plugin graph that defines what the system is composed of, and an append-only event stream that records what the system has done. It explains how scope-based visibility, dependency resolution, cleanup ownership, and configuration-to-runtime-tree conversion make composition manageable, how facts are separated from projections for context, UI, recovery, and branching, and why keeping the execution loop thin is essential for maintainability.

    1. Why “Many Plugins” Does Not Explain a Harness

    Many agent runtime frameworks claim to be plugin-based, but the number of plugins alone does not define an architecture. What really determines maintainability is how plugins are organized, how they are observed, how they change at runtime, and how the history of a task is preserved in full. If capabilities are simply split into a large number of independent packages without addressing dependencies, scope, cleanup, and configuration evolution, the system quickly degrades into a collection of calls that is hard to trace.

    A production-grade agent runtime usually carries two kinds of complexity at the same time. The first is composition complexity: model adapters, prompt assembly, tool catalogs, sessions, storage, sandboxes, the execution loop, and UI observation. The second is history continuity: what actually happened during a run, how to recover, how to compress context, and how to branch. Mixing these two problems in a single loop is the root reason why most implementations are hard to evolve.

    A more reasonable abstraction treats the system as two parallel main lines: one maintains a runtime plugin graph of “what the system is currently composed of,” and the other maintains an append-only event stream of “what was just done.” The execution loop sits between them, obtaining models, tools, prompts, and session services from the plugin graph, then writing process facts back to the event stream.

    2. Runtime Plugin Graph: What the System Is Composed Of

    The runtime plugin graph is not a static dependency list, but a live graph that can be updated and inspected. It needs to handle five problems that are usually treated separately.

    2.1 Capability Visibility

    Which capabilities a plugin can see at its current location must be determined by scope, not global visibility. The clearer the visibility rules, the less a plugin needs to rely on implicit initialization order. In practice, a “declare what you need, inject by scope” approach lets a plugin receive only the service handles it declares.

    Illustrative configuration (neutral pseudocode):

    1. plugin: model-adapter
    2. scope: session/default
    3. requires: [credentialStore, telemetry]
    4. plugin: tool-registry
    5. scope: session/default
    6. provides: [toolCatalog]

    2.2 Wait Strategy for Required Capabilities

    When a required capability has not yet appeared, whether a plugin starts late, runs in a degraded mode, or fails outright needs an explicit policy. Separating “wait” from “fail” avoids startup races and exposes missing dependencies at runtime in a diagnosable way.

    2.3 Resolving Multiple Implementations of the Same Service Name

    Resolving the same service name to different implementations across sessions or scopes is key to isolation and multi-tenancy. For example, different sessions can use different model adapters or different sandbox backends without the plugin code being aware of the difference. Resolution rules should be predictable: local scope first, then parent scopes, and finally the default implementation.

    2.4 Cleanup Ownership on Exit

    When a plugin exits, who cleans up registrations, listeners, child processes, and file handles determines whether the system can run stably over the long term. It is recommended to bind cleanup to the plugin lifecycle itself: unloading a plugin triggers reclamation of its registrations and listeners, while a unified resource manager closes processes and handles, avoiding “created by someone, forgotten by someone.”

    2.5 From Static Configuration to a Runtime Tree

    Static configuration needs to become a runtime plugin tree that can be updated and inspected. Configuration lines are mounted one by one as plugin instances, and user patches are layered on top to form the final shape. The runtime tree should support querying the current node, dependency status, and effective scope, making “whether the configuration took effect” an observable question rather than a guess.

    3. Append-Only Event Stream: What the System Has Done

    The event stream is append-only and never modified in place. It records the real process of an agent’s work. Its value lies in separating “facts” from “projections”: facts are the single source of truth, while model context, UI traces, recovery points, and branch data are all projections.

    • Fact layer: records requests, model outputs, tool calls and results, policy decisions, and errors in the order they occur.
    • Projection layer: derives the model context window, UI timeline, compressed summaries, and recovery snapshots from facts.
    • Branching and recovery: rebuilds subsequent state from any event position, supporting retries, rollbacks, and branch experiments.

    This design keeps compression from destroying history: compression only generates a new summary projection, while the original facts remain traceable. The UI observes the same facts, avoiding two separate truths for “UI state” and “execution state.”

    4. Execution Loop: Moving Facts Between the Two Graphs

    The responsibility of the execution loop should be strictly narrowed: take services from the plugin graph, assemble the prompt and tool catalog, invoke the model, execute tools, and write results back to the event stream. It should not handle plugin management, sandbox details, or UI rendering.

    1. loop(session):
    2. ctx = project(session.events)
    3. services = graph.resolve(session.scope)
    4. plan = services.model.invoke(ctx, services.tools)
    5. for step in plan:
    6. result = services.sandbox.run(step)
    7. session.append(step, result)

    Only when the loop stays “thin” does composition complexity truly fall to the plugin graph and history continuity truly fall to the event stream.

    5. From Configuration to Runtime: Startup and Hot Updates

    During startup, the base configuration and capability packages are read, then user patches are layered on, and the loader mounts plugin instances line by line. Runtime updates follow the same path: change configuration lines, generate a new plugin tree, mount or unmount in dependency order, and trigger cleanup. Inspectability means being able to answer at any time: which capabilities exist now, whether dependencies are satisfied, what the scopes are, and what the last change produced as a diff.

    6. Design Checklist

    • Express visibility with scope to avoid global implicit dependencies.
    • Define three strategies for required capabilities: wait, degrade, and fail.
    • Resolve same-name services by scope to ensure multi-session isolation.
    • Bind cleanup to the lifecycle, with processes and handles reclaimed uniformly.
    • Treat configuration as the runtime tree, with changes that are inspectable and rollback-able.
    • Keep the event stream append-only, with context and UI as projections.
    • Keep the execution loop thin, pushing complexity down into the graph and the stream.

    Mastering these two main lines upgrades “many plugins” into a verifiable architecture: the graph explains composition, the stream explains history, and the loop only connects the two.