Skip to main content

System Architecture

The elizaOS runtime follows a modular, plugin-based architecture that orchestrates all agent functionality. For lifecycle details, see Runtime and Lifecycle. For extension architecture, see Plugin Architecture.

Core Components

The runtime orchestrates these essential components:
  • AgentRuntime: Central orchestrator managing agent lifecycle
  • Plugin System: Extends functionality through modular components
  • Memory System: Hierarchical storage for conversations and knowledge
  • State Management: Aggregates context from multiple sources
  • Service Layer: Background processes and integrations
For related documentation, see Plugin Architecture, Memory, and Services.

AgentRuntime Class

The AgentRuntime class is the central engine that manages agent lifecycle, processes messages, and coordinates all system components.

Core Interface

Key Responsibilities

1. Action Processing

The runtime orchestrates action selection and execution:

2. State Composition

Builds comprehensive context by aggregating data from providers:

3. Plugin Management

Registers and initializes plugin components:

Runtime Lifecycle

Initialization Sequence

  1. Runtime Creation: Instantiate with character and configuration
  2. Character Loading: Load agent personality and settings
  3. Plugin Loading: Register plugins in dependency order
  4. Service Startup: Initialize background services
  5. Ready State: Agent ready to process messages

Plugin Loading Order

Configuration

Runtime Configuration

The runtime accepts configuration through multiple sources:

Environment Variables

Core runtime environment variables:
  • NODE_ENV - Runtime environment (development/production)
  • LOG_LEVEL - Logging verbosity
  • DATABASE_URL - Database connection string
  • API_PORT - Server port for API endpoints
  • AGENT_ID - Unique agent identifier

Settings Management

Access configuration through the runtime:

Database Abstraction

The runtime implements IDatabaseAdapter for data persistence:

Memory Operations

Message Processing Pipeline

The runtime processes messages through a defined pipeline:

Processing Steps

  1. Message Receipt: Receive and validate incoming message
  2. Memory Storage: Persist message to database
  3. State Composition: Build context from providers
  4. Action Selection: Choose appropriate actions
  5. Action Execution: Run selected action handlers
  6. Evaluation: Post-process results
  7. Response Generation: Create and send response

Error Handling

The runtime implements comprehensive error handling:

Performance Considerations

State Caching

The runtime caches composed state for performance:

Service Pooling

Services are singleton instances shared across the runtime:

Best Practices

Runtime Initialization

  • Initialize plugins in dependency order
  • Start services after all plugins are loaded
  • Verify character configuration before starting
  • Set up error handlers before processing

Resource Management

  • Clean up services on shutdown
  • Clear state cache periodically
  • Monitor memory usage
  • Implement connection pooling

Error Recovery

  • Implement retry logic for transient failures
  • Log errors with context
  • Gracefully degrade functionality
  • Maintain audit trail

Integration Points

The runtime provides multiple integration points:
  • Plugins: Extend functionality through the plugin system
  • Events: React to runtime events
  • Services: Add background processes
  • Models: Integrate AI providers
  • Database: Custom database adapters
  • API: HTTP endpoints through routes

See Also

Memory System

Learn about the fundamental storage layer

Events

Understand the communication backbone

Providers

Explore how to supply data to the runtime

Models

Discover AI model management