docs/ARCHITECTURE.md
elizaOS is a plugin-based agent runtime implemented primarily in TypeScript (@elizaos/core), with parallel Rust and Python implementations and a cross-language interop layer. The core runtime orchestrates:
packages/typescript/src/
packages/typescript/src/runtime.tspackages/typescript/src/services/message.tspackages/typescript/src/plugin.tspackages/typescript/src/basic-capabilities/packages/typescript/src/types/packages/typescript/src/memory.tspackages/typescript/src/database.tspackages/rust/src/
packages/rust/src/runtime.rspackages/rust/src/plugin.rspackages/rust/src/wasm.rspackages/python/packages/interop/packages/prompts/plugins/examples/AgentRuntime (packages/typescript/src/runtime.ts) implements IAgentRuntime (packages/typescript/src/types/runtime.ts).packages/typescript/src/types/plugin.ts) that can register:
actions, providers, evaluatorsservices (singletons)models (LLM + embedding + image model handlers)events (runtime event handlers)routes (HTTP endpoints, namespaced by plugin name)adapter (database adapter; typically provided by @elizaos/plugin-sql)packages/typescript/src/types/memory.ts).packages/typescript/src/types/state.ts).Below is the default TypeScript pipeline as implemented by DefaultMessageService (packages/typescript/src/services/message.ts) and AgentRuntime (packages/typescript/src/runtime.ts).
Input arrives
Memory (often via createMessageMemory in packages/typescript/src/memory.ts).runtime.messageService.handleMessage(runtime, message, callback).Persist incoming message
messages table via runtime.createMemory(...).runtime.queueEmbeddingGeneration(...) (non-blocking).Compose initial state
runtime.composeState(message, includeList, onlyInclude, skipCache)provider.position, filtered by provider.private and provider.dynamic.runtime.stateCache (keyed by message.id).Process attachments (optional)
ModelType.IMAGE_DESCRIPTION.Decide whether to respond
shouldRespond prompt can be run (model selectable via SHOULD_RESPOND_MODEL or options).Generate a response plan
messageHandlerTemplate, producing XML that includes thought, actions, providers, text.USE_MULTI_STEP, MAX_MULTISTEP_ITERATIONS).Execute actions (if any)
runtime.processActions(message, responseMessages, state, callback, { onStreamChunk })Deliver response
Content.messages via runtime.createMemory(...).Run evaluators
runtime.evaluate(message, state, didRespond, callback, responseMessages)alwaysRun).Emit events
RUN_STARTED, RUN_TIMEOUT, and RUN_ENDED.At runtime initialization (AgentRuntime.initialize() in packages/typescript/src/runtime.ts):
basic-capabilitiesPlugin is present (auto-included unless already provided).registerPlugin(plugin):
plugin.init(config, runtime) runs first/${plugin.name}/...packages/typescript/src/plugin.ts:
dependencies and testDependenciesbun add (opt-out via env flags)elizaOS uses a pluggable database adapter (DatabaseAdapter in packages/typescript/src/database.ts):
@elizaos/plugin-sql).adapter.runPluginMigrations(...) (invoked by runtime.runPluginMigrations()).Memory with optional embeddings and metadata (MemoryType).The packages/interop/ package defines a cross-language contract:
packages/interop/README.md)wasm-bindgen and a TS wasm loaderctypesSee INTEROP_GUIDE.md for details.