Skip to main content

System Architecture

The big picture (in plain terms)

Agentium is built like a well-run company, where each department has one job and they all work together:
  • The AI model (GPT, Claude, …) is the smart new hire who can think and write.
  • The memory is the filing cabinet that remembers every customer.
  • The tools are the systems the hire can actually operate — your database, your APIs.
  • The safety layer is the manager who approves anything risky before it happens.
  • The transport layer is the front desk — how the outside world (a website, a phone call) reaches the team.
The key design idea: each part is independent and swappable. Don’t like one database? Swap it. Want a different AI model? One line. Need voice instead of chat? Same brain, different front desk. Nothing is welded together.
For non-engineers: the one thing worth remembering is modularity. Agentium isn’t one giant block — it’s separate pieces that snap together. That’s why a team can start with a simple chatbot and grow it into a voice product or an enterprise SaaS without rebuilding from scratch.
The rest of this page is the engineering detail — how those pieces are packaged and how data flows between them.

Monorepo Structure

Agentium is organized as a monorepo with four primary packages. Each package has a focused responsibility and can be used independently or together.

Package Overview


Layered Architecture

Agentium is built in layers. Higher layers depend on lower ones and infrastructure is pluggable.
  1. SDK Layer — Agent, Team, Workflow, VoiceAgent, BrowserAgent. The primary API surface for defining behavior, orchestrating agents, and running workflows.
  2. Engine Layer — LLM Loop, Tool Executor, MemoryManager (sessions, summaries, user facts, user profile, entities, decisions, learnings), SkillManager. Core execution logic with automatic retry, tool caching, token-based history trimming, reasoning, and cross-session personalization.
  3. Safety Layer — Sandbox (isolated subprocess execution with timeout and memory limits), Approval Manager (human-in-the-loop gating before tool execution), Guardrails (input/output validation).
  4. Model Abstraction — ModelProvider interface and adapters for text models. RealtimeProvider interface for voice/streaming models. Factory functions: openai(), anthropic(), google(), ollama(), vertex(), openaiRealtime(), googleLive().
  5. Protocol Integration — MCP Client for consuming external tools, A2A Client for calling remote agents.
  6. Infrastructure — Storage (in-memory, SQLite, PostgreSQL, MongoDB), Vector Stores, and Embeddings. All pluggable.
  7. Registry & Auto-Discovery — Agents, Teams, and Workflows auto-register into a global Registry on construction. Transport layers read from the registry dynamically, so entities created at any time are immediately available over HTTP and WebSocket without restart or re-wiring.
  8. Transport (Optional) — Express REST, Socket.IO WebSocket, Voice Gateway (real-time audio streaming), Browser Gateway (live browser observation), and A2A Server. Uses the Registry for live auto-discovery of agents, teams, and workflows.
  9. Queue (Optional) — BullMQ workers for background job processing.

Data Flow — Text Agent

A typical text agent request flows through the system as follows:

Detailed Flow

  1. User Input — A string or multi-modal content (text, images, files).
  2. Agent — Receives input, loads session history from MemoryManager, injects memory context and skill instructions into the system prompt.
  3. buildMessages — Constructs the message array: system prompt (with summaries, user facts, user profile, entities, decisions, learnings, skill instructions), session history (auto-trimmed if maxTokens is set), current user message.
  4. LLM Loop — Sends messages to the model with automatic retry on transient failures (429, 5xx, network errors).
  5. ModelProvider — Translates to the provider API format.
  6. Response — Either text or tool calls.
  7. Tool Executor — If tool calls:
    • Checks human approval if requiresApproval is set on the tool or agent.
    • Runs the tool in a sandboxed subprocess if sandbox is enabled.
    • Executes the tool, appends results, and loops back to the model.
  8. MemoryManager.appendMessages — Persists the new turn to session storage and auto-summarizes overflow.
  9. MemoryManager.afterRun — Asynchronously extracts user facts, user profile, entities, and learnings from the conversation for future personalization.
  10. Output — Returns or streams the final response to the caller.

Data Flow — Voice Agent

The VoiceAgent manages:
  • VoiceSession — wraps the realtime provider connection, routes tool calls, emits events.
  • Session persistence — conversation history saved via MemoryManager, restored on reconnect.
  • Memory extraction — user facts, profile, entities, and learnings extracted from voice transcripts (non-blocking).

Data Flow — Browser Agent

The BrowserAgent supports:
  • Stealth mode — patches navigator.webdriver, WebGL, plugins to avoid bot detection.
  • Humanize mode — random delays, mouse movement curves, typing variation.
  • Credential vault — secrets never reach the LLM; only {{placeholders}} are used.
  • Video recording — Playwright-native recording of browser sessions.
  • Parallel browsing — multiple pages/tabs via BrowserProvider.
  • Cookie persistence — save and restore storageState across runs.

Event System

All agents emit typed events via the EventBus. This enables logging, analytics, transport integration, and custom middleware without coupling.

Memory Architecture

Agentium provides a unified memory system through MemoryManager. A single memory config works identically across Agent, VoiceAgent, and BrowserAgent. All stores share a single StorageDriver (InMemory, SQLite, PostgreSQL, MongoDB). All extraction is non-blocking (fire-and-forget).

Skills Architecture

Skills are pre-packaged tool bundles loaded from local directories, npm packages, or remote URLs. The SkillManager orchestrates loading and provides lazy initialization (loaded on first run, not at construction).

Registry & Auto-Discovery

Agentium includes a global Registry singleton. Every Agent, Team, and Workflow automatically registers itself on construction (unless register: false is set).
The Express router and Socket.IO gateway read from this registry at request time. Agents created after the transport layer starts become available immediately — no restart or re-wiring needed.

Performance Optimizations


Core Design Principles

  • Zero Meta-Framework Dependency — No Next.js, Remix, or framework-specific runtime. Use Agentium with any Node.js server or headless.
  • Optional Peer Dependencies — Providers (openai, anthropic, etc.) are peer dependencies. Lazy-loaded so you only bundle what you use.
  • Event-Driven — EventBus emits lifecycle events. Subscribe for logging, analytics, or custom middleware.
  • Pluggable Everything — Storage, models, vector stores, and transport are all swappable. Configure once, change later without rewriting logic.
  • Safety by Default — Sandbox execution and human-in-the-loop approval are opt-in per tool or agent-wide. Guardrails validate input and output.
  • Open Protocol Support — MCP for tool integration and A2A for agent interoperability. Connect to the broader AI ecosystem without vendor lock-in.
  • Production Resilient — Automatic retry with exponential backoff, token-based context trimming, and non-blocking background operations ensure reliability at scale.