How to Assemble a Pluggable AI Agent Runtime
AI agent products are rarely monolithic programs written once and for all. Instead, a runtime assembles them at startup by stacking pluggable capabilities onto an empty plugin tree, then applying user patches. This article explains this assembly model, including how to structure base capability packages, terminal-specific overrides, and minimal user patches; which slots belong in the default stack versus session-level presets; how to keep model-visible information consistent with runtime logs; and how to treat sub-agents and external runtimes as replaceable plugin rows. It also covers the "rebuildable from logs" invariant and the criteria for judging whether a plugin deserves a place in the default stack.
From an Empty Root Configuration to a Complete Product
An agent product is usually not a monolithic program with all behavior hardcoded. Instead, the runtime assembles it at startup: a set of pluggable capabilities is stacked, in order, onto an empty plugin tree, and user patches are applied on top. Understanding this assembly model helps you decide which plugins genuinely belong in the default stack, which should be left to session-level presets, and how to keep the information visible to the model consistent with runtime logs.
One common convention is that the configuration root is normalized to an empty list at startup, with all product capabilities coming from subsequent layers. The benefit is that the host never secretly carries default plugins: every behavior can be traced back to an explicit package or patch, which makes auditing, rollback, and diffing straightforward.
The layering typically has three tiers:
- Base capability packages covering timing, model adapter seams, session state, local structured queries, the agent loop, tools and system prompts, sandboxing, approvals, skills, goals, planning modes, context compression, sub-agents, workflows, and retrieval.
- Terminal-specific override packages, for example disabling a set of host-side tools and injecting a different set through a preset mounted per session.
- User patches, which change only the differences rather than duplicating the entire tree.
This “empty tree plus layering” approach is far better than hardcoding if-else branches in code: the same runtime can grow into agents with very different shapes — one focused on local tools and approvals, another on browser-side tools, and yet another where the loop itself is replaced with a different scheduling implementation.
Which Slots Should a Base Capability Package Fill?
What makes a package worthy of recommendation as a default is not a long feature list, but filling the runtime’s slots completely with clear boundaries.
- Timing and observability handle timeouts, retry windows, and per-stage durations, preventing loops from hanging indefinitely when external services misbehave.
- Model integration should be a seam rather than a hardwired protocol. Adapters own message formatting, streaming chunks, and abort signals.
- Sessions and local queries provide recoverable conversations and structured retrieval, enabling references across turns.
- Agent and loop factories decide “how to think and act.” The loop itself should be registered as a replaceable effect: when it is unmounted, creating an instance should fail explicitly rather than silently falling back to an incomplete implementation.
- Tools and system prompts should come as a pair: the prompt describes the capability boundary, while the tool provides real side effects.
- Sandboxing and approval policies turn high-risk operations from “the model wants to” into “policy allows it.”
- Skills, goals, and planning modes upgrade one-shot conversations into decomposable tasks.
- Compression governs context-window management.
- Sub-agents and workflows support parallel or staged execution.
- Retrieval capabilities are mounted on the host tree or on session presets depending on the terminal.
Override packages for web or remote sessions commonly disable a batch of local tools in the host tree and inject a different set via a preset mounted for each session. This keeps tool lifecycles aligned with the session, makes permission models and network boundaries clearer, and avoids leaking capabilities that only make sense for a local process to remote endpoints.
Why the Loop Factory Must Be Unloadable
Making the loop a factory mounted in an effect slot, rather than scattering it across business code, has two benefits. First, replacing the scheduling strategy — synchronous step-by-step, checkpointed, or human-gated — requires no changes to callers. Second, when the slot is empty, the runtime fails immediately, forcing the product to declare which loop it uses and preventing half-configured environments from going live.
In practice, the factory interface should define a minimal contract: it receives the session and tool registry, produces a cancellable run handle, and returns a structured termination reason when it finishes. On the testing side, you can inject an empty factory or a recording factory to verify assembly order without actually invoking a model.
Logging Rule: Whatever the Model Sees Must Be Rebuildable
A simple and highly effective constraint: anything the model can see must be reconstructible from logs, enforced at runtime with assertions. This includes system prompts, tool definitions, tool results, approval decisions, pre- and post-compression summary boundaries, and summaries returned by sub-agents.
The payoffs are incident postmortems, replayable evaluations, and compliance evidence. In implementation, log events should share the same serialization path as the messages delivered to the model, avoiding the situation where “one copy is logged and another copy is sent to the model.” For binary or very large payloads, log only a hash and a truncation policy — but still declare the truncation in the prompt, otherwise the model-side and log-side views diverge.
Sub-Agents: Treat External Runtimes as Plugin Rows
Sub-agents do not require you to build an entire protocol from scratch. You can mount external agent runtimes as plugin rows in the same tree: one variant communicates over a subprocess and application service protocol, another through an official software development kit. The key is not “importing a configuration file” but treating the other runtime as a replaceable component subject to your own sandboxing, approval, and logging rules.
When integrating, standardize through a unified adaptation layer: normalize task inputs, progress events, final artifacts, and failure codes; restrict filesystem and network access; and map the other runtime’s logs into your own “model-visible means rebuildable” event stream. This way, the same product can run its native loop or delegate subtasks without breaking the audit trail.
Data-Driven to the Core: Loops and Adapters Are Replaceable
The value of pluginization is not the number of plugins but whether the core mechanism is data-driven. When the loop, model adaptation, tool tables, and approval policies can all be replaced by configuration rows, the same runtime can grow into a local assistant, a session-level web agent, or a production workflow with strong approvals.
To judge whether a plugin is worth recommending, check three things:
- Does it fill a clearly defined slot?
- Can it be independently unloaded?
- Does it preserve the logging and permission invariants?
In practice: keep the root configuration empty, keep capability packages reproducible, keep user patches minimal, and add continuous-integration assertions for “unloading the loop causes failure” and “all model-visible fields land in the logs.” When that holds, plugin recommendations rest not on reputation but on verifiable assembly contracts.
