Plugin Architecture in Open-Source AI Agent Frameworks: A Technical Breakdown
This article examines how open-source AI agent frameworks adopt a "everything is a plugin" architecture, using a recently open-sourced agent runtime as a reference sample. It explains the relationship between the thin core layer and the plugin layer, how packages are split in a TypeScript monorepo, the stages a tool call passes through, why the main agent loop should be a plugin, the engineering constraints implied by the repository structure, and the trade-offs teams should weigh before building their own agent platform.
1. Why Plugin Architecture Has Become a Key Concern for Agent Frameworks
Over the past year, AI coding tools and general-purpose agent platforms have multiplied quickly. Yet many teams run into the same problems when they try to put them into production: the main loop is hard-coded inside the framework, so switching to a different planning strategy means patching the core; the tool registry is coupled with business logic, so adding a tool requires invasive changes; and prompt assembly is scattered across the codebase, making version control and canary rollouts impossible. The result is a system that “runs, but nobody dares to change it.”
One open-source agent runtime framework recently made its source code public. Its README summarizes its positioning in two sentences: an open-source agent runtime framework built on an “everything is a plugin” architecture, driven underneath by a dependency injection and lifecycle management framework. It also clearly states that it is still in a developer preview phase and that breaking changes will follow. This article uses that repository as a sample to discuss the internal construction of this class of architecture, without evaluating the capabilities of any specific product.
Its core mechanism comes down to three things: a service container handles dependency wiring, typed events handle decoupled notifications, and rollbackable side effects handle state consistency. In terms of product form, this becomes a plugin tree assembled layer by layer during startup — even the agent main loop and the tool registry are just one replaceable line of configuration on that tree.
2. Overall Shape: A Thin Base Layer and a Plugin Layer
The most important thing to understand about this class of framework is the relationship between the “base” and the “plugin layer.” The base provides only very thin capabilities: service registration and resolution, an event bus, lifecycle hooks, and configuration loading. It has no awareness of the concept of an “agent,” nor does it recognize any specific tool.
The plugin layer carries all business semantics: session management, system prompt assembly, tool sets, the main loop, sub-agents, context compression, skill loading, workflow orchestration, external protocol integration, browser-side UI modules, and more — all exist as plugins, all at the same level, with no privileged core to patch.
This structure produces two direct outcomes:
- Four runtime entry points (interactive terminal, one-shot task, long-running service, and graphical interface) share the same plugin layer; the only difference is which bundles are stacked at startup.
- To replace the main loop strategy, you do not need to fork the framework — you only swap one plugin implementation in the configuration.
An illustrative configuration structure (pseudocode, expressing only the assembly approach):
// Stack the plugin tree by bundle at startupexport default defineConfig({plugins: [core.session, // Session and message storagecore.systemPrompt, // Prompt assemblyllm.provider, // Model integrationcore.tools, // Tool registryshell.exec, // Command execution toolfs.read, fs.write, // File toolscore.agentLoop, // Main loop (replaceable as a whole)web.bundle, // Graphical interface bundle],});
3. How Packages Are Split: Granularity Determines Replaceability
The repository is a TypeScript monorepo managed with workspaces. It contains more than two hundred packages, the vast majority of which are published product packages. The granularity of the grouped directories says a lot about the design intent: the core group contains session, system prompt, tools, agent, and main loop; alongside it sit parallel groups for model integration, file system, command execution, terminal, language services, sandbox, sub-agents, context compression, skills, workflows, external protocol integration, and clients.
Notably, the client is split just as finely: the conversation view, tool view, sidebar, model settings, and so on each become independent packages. In other words, the frontend is not a single monolithic single-page application, but is likewise split by plugin and assembled on demand. The benefits of this split are clear:
- Dependency direction is clear, and the core group does not depend backward on the UI layer;
- Each capability can be tested and replaced independently;
- Teams can develop in parallel with a small conflict surface.
The costs are equally real: the growing number of packages makes the build graph complex, raises the cost of version alignment, and leads to frequent cross-package jumps during debugging. So engineering practice must include unified build orchestration, changeset management, and dependency boundary checks — otherwise “pluginization” degrades into “fragmentation.”
4. The Stages a Tool Call Passes Through
In this kind of architecture, a tool is not an entry in a function table but a plugin registered in the registry. A single call typically goes through the following stages:
- Parsing and validation: the call arguments produced by the model are validated against the schema definition; on failure, a structured error is returned so the model can correct itself;
- Permissions and policy: based on the session configuration, the framework decides whether execution is allowed and whether human confirmation is required;
- Sandbox and resource limits: file and command tools run in a restricted environment with limits on the working directory, timeout, and output size;
- Execution and side-effect registration: state changes produced during execution are registered as rollbackable side effects;
- Result normalization: output is trimmed, redacted, and structured before being written back to the session;
- Event broadcasting: typed events notify the UI and logging sides, and the frontend renders incrementally based on them.
Rollbackable side effects are the most worthwhile idea to borrow from this mechanism. Agent tasks often fail midway or are interrupted by the user. If changes such as file writes, terminal sessions, and temporary directories are not registered uniformly, rollback can only rely on manual investigation. Binding side-effect registration and undo to unified lifecycle hooks is what makes “retry” and “undo” framework capabilities rather than business patches.
5. Why the Main Loop Should Also Be a Plugin
The main loop drives the “think — call — observe — think again” progression, and usually also includes termination condition checks, error retries, and handling for context overflow. Fixing it inside the framework amounts to welding the strategy in place. Once abstracted into a plugin, multiple implementations can coexist: a conservative single-step confirmation type, a throughput-oriented batch execution type, and a research-oriented multi-sub-agent parallel type, switchable via configuration.
Correspondingly, context compression, skill loading, and workflow orchestration are each independent as well: the compression strategy decides when to summarize history, the skill module decides which domain knowledge to inject on demand, and the workflow module handles orchestration and resume-from-breakpoint for multi-stage tasks. They collaborate with the main loop through events rather than calling each other directly.
6. The Engineering Constraints It Sets for Itself
Several hard constraints can be inferred from the repository structure, and these constraints are more instructive than a feature list:
- Full ESM, unifying module semantics and avoiding the loading ambiguity caused by dual-mode packages;
- A clear minimum runtime version, locking in language and runtime features;
- A single package manager and workspace protocol, ensuring a reproducible dependency graph;
- A large number of test files, with core paths treated as contracts enforced by tests;
- Third-party dependencies embedded as source copies under a unified namespace, reducing the risk of upstream drift;
- An explicit compatibility risk statement during the preview period, encouraging integration through an adapter layer rather than direct dependency.
7. Lessons for Building Your Own Agent Platform
If a team is preparing to build or refactor an agent platform, four points are worth borrowing: first, push the registry, prompts, and main loop down into replaceable units while keeping an extremely thin base; second, establish a unified registration and undo mechanism for side effects so that failure recovery is predictable; third, split packages by capability on both frontend and backend to avoid the UI becoming an untestable monolith; fourth, use events as the backbone for cross-layer communication to reduce point-to-point coupling.
At the same time, pluginization is not free: package count, build time, version governance, and debugging costs all rise. Whether to adopt it depends on whether the team genuinely needs frequent strategy replacement and multiple entry-point forms. If the scenario is a fixed workflow in a single context, moderate modularization is often more economical than a full plugin tree. When evaluating a specific implementation, teams can complement observability with general-purpose infrastructure such as container platforms, logging services, and monitoring and alerting, rather than placing observability inside the framework itself.
