This article explores a microkernel architecture pattern for building durable and modular AI agents. It emphasizes a "frozen core" that brokers capabilities to pluggable WebAssembly (WASM) modules, ensuring stability and isolation. The design focuses on explicit capability-based security, fault isolation, and agent permanence through embedded memory.
Read original on Dev.to #architectureThe core idea is to treat AI agents not as transient sessions but as long-lived entities with memory and explicit capabilities. This shifts from typical AI frameworks that reset states to an architecture where a small, immutable "frozen core" manages interactions between various pluggable modules. This pattern is reminiscent of operating system design, where the kernel provides essential services and enforces policies, while applications (or in this case, agents and tools) run in isolated user space.
The microkernel, implemented in Go, is designed to be a static, unchanging binary. Its responsibilities are strictly limited to hosting a single Application Binary Interface (ABI) called the "loket" (counter), checking grants for capability requests, routing requests to providers, and enforcing the WASM sandbox. This immutability ensures that updates or failures in modules do not compromise the core system, providing high stability and easier debugging. New functionalities are added as modules, not kernel modifications.
Design Principle: Stable Core, Pluggable Edge
In system design, limiting the responsibilities of core components (like a kernel or a central API gateway) and ensuring their stability is crucial for overall system resilience. This often involves clear interfaces and a strong separation of concerns.
Every functional piece (agents, tools, LLM routers, data stores) is a separate module, adhering strictly to the single responsibility principle. Agents themselves are WebAssembly (WASM) modules run by a pure-Go WASM runtime (wazero). This provides critical isolation for both security and fault tolerance:
All capability requests flow through the "loket" (e.g., `call("store.brain", data)`). The kernel verifies an agent's grants, routes the call to the appropriate provider, and enforces sandbox rules. This explicit, auditable grant system ensures that permissions are transparent and managed centrally by the kernel, eliminating implicit permissions and ambient authority found in other systems. Each agent's memory is embedded in its own SQLite database, accessed only via granted kernel calls, ensuring privacy and portability.
Consider a scenario where an AI agent needs to access external APIs or storage. Instead of the agent directly interacting with these services, it requests a capability from the microkernel, like `call("mcp.github", ...)` for GitHub access or `call("store.brain", ...)` for its internal memory. The kernel then verifies the agent's permissions and routes the request to the appropriate handler, acting as a secure intermediary.