The Problem
Building production AI agents is hard. You’re juggling:- Plugin management across multiple providers and capabilities
- State persistence that doesn’t break between restarts
- Multi-agent orchestration without race conditions
- Deployment complexity from local dev to serverless edge
Quick Start with ElizaOS
TheElizaOS class handles configuration, plugin resolution, and multi-agent orchestration automatically.
Add Capabilities
Actions, Providers, and Evaluators
Define Personality
Character configuration
Deploy Anywhere
Local, Docker, Serverless, Edge
Connect Platforms
Discord, Telegram, Twitter, and more
Deployment Patterns
Serverless / Edge Deployment
For serverless environments, use ephemeral mode:Async Mode with Callbacks
For WebSocket or streaming scenarios:Multi-Agent Communication
Send messages to multiple agents in parallel:Agent Discovery
Events
ElizaOS extendsEventTarget for lifecycle events:
Health Monitoring
What You Get
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
AgentRuntime Class
TheAgentRuntime 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
- Runtime Creation: Instantiate with character and configuration
- Character Loading: Load agent personality and settings
- Plugin Loading: Register plugins in dependency order
- Service Startup: Initialize background services
- 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 verbosityDATABASE_URL- Database connection stringAPI_PORT- Server port for API endpointsAGENT_ID- Unique agent identifier
Settings Management
Access configuration through the runtime:Database Abstraction
The runtime implementsIDatabaseAdapter for data persistence:
Memory Operations
Message Processing Pipeline
The runtime processes messages through a defined pipeline:Processing Steps
- Message Receipt: Receive and validate incoming message
- Memory Storage: Persist message to database
- State Composition: Build context from providers
- Action Selection: Choose appropriate actions
- Action Execution: Run selected action handlers
- Evaluation: Post-process results
- 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
Advanced Runtime Methods
Beyond the core interface, the runtime exposes additional methods for advanced use cases.Run Tracking
Track agent execution runs for debugging, analytics, and action chaining:Action Results
Retrieve results from executed actions for action chaining:Embedding Generation
Queue memories for async embedding generation:high- Immediate processing (user queries)normal- Default priority (conversations)low- Background processing (bulk imports)
Conversation Length
Get the current conversation length setting:Service Management
Advanced service discovery and management:ElizaOS Type Guard
Check if the runtime has an ElizaOS instance attached:Connection Management
Batch setup of entities, rooms, and connections:World Management
Update world configuration:Message Routing
Register custom message handlers for different platforms: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
Streaming Responses
Implement real-time streaming with SSE/WebSocket
Action Planning
Build multi-step action workflows
Background Tasks
Run async operations with task workers
Deploy to Cloud
Ship your agent to production in minutes

