docs/CORE_CONCEPTS.md
The TypeScript runtime is AgentRuntime (packages/typescript/src/runtime.ts). It implements IAgentRuntime (packages/typescript/src/types/runtime.ts) and owns:
plugins, actions, providers, evaluators, services, routes, modelsadapter (database adapter)messageService (default: DefaultMessageService)stateCache: Map<string, State> keyed by message idawait runtime.initialize({ skipMigrations?: boolean }) will:
basic-capabilitiesPlugin if not already presentregisterPlugin(plugin)@elizaos/plugin-sql)adapter.init()) if not readyruntime.messageService = new DefaultMessageService()All persistent data is stored as Memory objects (packages/typescript/src/types/memory.ts) with:
content (the user/agent payload)embedding (vector for semantic search)metadata including MemoryType (message, document, fragment, description, custom)The helper createMessageMemory(...) in packages/typescript/src/memory.ts creates a message-shaped Memory with sensible defaults.
Persistence is abstracted behind DatabaseAdapter (packages/typescript/src/database.ts). The runtime calls adapter methods such as:
createMemory, getMemoryById, searchMemories, updateMemory, deleteMemoryrunPluginMigrations(...) to apply plugin schemaselizaOS models "where" a conversation happens and "who" is participating using three core concepts:
elizaOS has both an internal room concept and a "channel" concept, but "channel" is treated as platform-specific metadata:
roomId (Room.id).ChannelType (Room.type, and often also Content.channelType).Room.channelId.Before you process messages, ensure the runtime knows about the participant and conversation context:
worldId and roomId (many examples use stringToUuid(...)).runtime.ensureConnection({ entityId, roomId, worldId, ... }) to ensure:
createMessageMemory(...)) and call:
runtime.messageService.handleMessage(runtime, message, callback)You can see this exact pattern in:
examples/chat/typescript/chat.tsexamples/aws/typescript/handler.tsexamples/cloudflare/src/worker.tsState (packages/typescript/src/types/state.ts) is the ephemeral context used for prompt composition and action execution:
values: key/value variables for prompt templatesdata: structured caches (provider results, action results, room/world/entity objects, etc.)text: concatenated provider text (what typically gets injected into prompts)Providers are state builders: they fetch/compute context before a model call and contribute it to State.
Providers (Provider in packages/typescript/src/types/components.ts) return a ProviderResult:
state.text (often injected into prompts)state.values (template substitution)state.data.providers[providerName]runtime.composeState(...) (packages/typescript/src/runtime.ts) will:
private and dynamic)provider.positionprovider.get(runtime, message, cachedState)State, cache it by message.idelizaOS treats LLM calls, embeddings, and image description as "models".
Plugins register model handlers via plugin.models (packages/typescript/src/types/plugin.ts). The runtime calls them through:
runtime.useModel(modelType, params) (packages/typescript/src/types/runtime.ts)When multiple handlers exist for a model type, the runtime selects based on priority.
Actions (Action in packages/typescript/src/types/components.ts) are the primary "tool" mechanism.
The default message pipeline is:
actions in its XML outputruntime.processActions(...) executes those actionsAction execution supports two modes (runtime.isActionPlanningEnabled()):
Evaluators (Evaluator in packages/typescript/src/types/components.ts) run after response generation (and after actions) via runtime.evaluate(...).
Use evaluators for:
Plugins can register handlers for runtime lifecycle events (plugin.events).
The default message pipeline emits events including RUN_STARTED, RUN_TIMEOUT, and RUN_ENDED (see packages/typescript/src/services/message.ts).
Core prompt templates live in packages/prompts/prompts/ and are used by the runtime and message service:
In TypeScript, prompt assembly is typically done by composePromptFromState(...) (used in packages/typescript/src/services/message.ts).
This repo contains:
packages/typescript/) — primary reference implementationpackages/rust/) — performance / WASM / systems integrationpackages/python/) — ML ecosystem integrationCross-language plugins are enabled by packages/interop/ (see INTEROP_GUIDE.md).