Skip to main content

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
Most frameworks give you primitives. You still wire everything together yourself.
5 minutes to your first agent. No infrastructure setup, no config files to manage. Just code.

Quick Start with ElizaOS

The ElizaOS 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 extends EventTarget 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
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

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:
Usage:

Action Results

Retrieve results from executed actions for action chaining:
Example - Action chaining:

Embedding Generation

Queue memories for async embedding generation:
Priority levels:
  • high - Immediate processing (user queries)
  • normal - Default priority (conversations)
  • low - Background processing (bulk imports)

Conversation Length

Get the current conversation length setting:
Returns the configured maximum conversation length from character settings.

Service Management

Advanced service discovery and management:
Example - Wait for service:

ElizaOS Type Guard

Check if the runtime has an ElizaOS instance attached:
Usage:

Connection Management

Batch setup of entities, rooms, and connections:
Example - Platform integration:

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