This document provides a high-level technical introduction to the OpenClaw codebase, its architecture, and core components. It serves as an entry point for developers who need to understand the system's structure before diving into specific subsystems.
Purpose: Introduce the overall system architecture, key code entities, configuration model, and development workflow.
Scope: This page covers the architectural layers and major subsystems. For specific implementation details, see:
OpenClaw is a self-hosted, multi-channel AI agent gateway that bridges messaging platforms (WhatsApp, Telegram, Discord, Slack, Signal, iMessage, and others) to AI coding agents. It runs as a single persistent process that manages sessions, routes messages, executes tools, and coordinates agent interactions.
Key characteristics:
gateway process serves all channels and clients@mariozechner/pi-agent-core, @mariozechner/pi-ai, @mariozechner/pi-coding-agent)OpenClawSchema)Sources: package.json1-443 README.md1-581 src/config/zod-schema.ts1-694
Sources: package.json1-443 README.md186-202 src/config/types.ts1-36
OpenClaw uses a strict, schema-validated configuration file at ~/.openclaw/openclaw.json (JSON5 format with comments and trailing commas).
The configuration is defined by OpenClawSchema and includes these top-level sections:
| Section | Schema | Purpose |
|---|---|---|
gateway | Gateway settings | Port, bind address, auth mode, reload behavior |
agents | AgentsSchema | Agent list, defaults, workspace paths |
channels | ChannelsSchema | Channel-specific config (WhatsApp, Telegram, Discord, etc.) |
models | ModelsConfigSchema | Model providers, auth profiles, fallbacks |
tools | ToolsSchema | Tool policy, sandbox settings, browser config |
session | SessionSchema | Session scoping, reset policy, thread bindings |
messages | MessagesSchema | Message delivery, chunking, media handling |
bindings | BindingsSchema | Multi-agent routing rules |
memory | MemorySchema | Memory backend selection (QMD or builtin) |
plugins | Plugin entries | Extension config and hooks |
hooks | HooksSchema | Webhook endpoints and mappings |
cron | Cron settings | Job scheduling and execution |
browser | Browser config | Playwright/CDP settings, profiles |
secrets | SecretsConfigSchema | SecretRef definitions (env/file/exec) |
Key code entities:
loadConfig() - Main config loader src/config/config.ts1-24validateConfigObjectWithPlugins() - Zod validation with plugin schemasOpenClawSchema - Root Zod schema src/config/zod-schema.ts162-694gateway.reload.mode - Controls hot reload behavior (hybrid, hot, restart, off)Sources: src/config/zod-schema.ts1-694 src/config/config.ts1-24 docs/gateway/configuration.md1-489
OpenClaw supports multiple messaging platforms simultaneously through a provider pattern. Each channel has:
dmPolicy, groupPolicy)| Channel | Provider Package | Config Key | DM Policy |
|---|---|---|---|
@whiskeysockets/baileys | channels.whatsapp | pairing (default) | |
| Telegram | grammy | channels.telegram | pairing (default) |
| Discord | @buape/carbon | channels.discord | pairing (default) |
| Slack | @slack/bolt | channels.slack | pairing (default) |
| Signal | signal-cli | channels.signal | allowlist |
| iMessage | imsg (legacy) | channels.imessage | N/A (macOS only) |
| BlueBubbles | HTTP API | channels.bluebubbles | allowlist |
| Google Chat | Plugin | plugins.entries.googlechat | Via plugin config |
| Mattermost | Plugin | plugins.entries.mattermost | Via plugin config |
Channel loading pattern:
plugins.load.paths and registered through plugin SDKChannelMonitor interfaceSources: package.json332-384 src/config/zod-schema.ts417-694 README.md152-154
The agent execution system uses a layered orchestration model:
Key execution functions (in order of invocation):
runReplyAgent() - Top-level entry point, manages typing indicators and memory flushingrunAgentTurnWithFallback() - Implements model fallback logicrunEmbeddedPiAgent() - Handles retry/fallback across auth profilesrunEmbeddedAttempt() - Single turn execution with Pi SDKTool provisioning:
ToolsSchema defines global tool policyagents.defaults.sandbox.mode): off, non-main, allSources: package.json55-66 src/config/zod-schema.ts3-23
OpenClaw supports two memory backends via plugin slot selection:
Memory backend selection:
memory.backend: "qmd" - External QMD process (supports MCP via mcporter)memory.backend: "builtin" - Embedded SQLite with FTS5 and sqlite-vecConfig entities:
MemorySchema src/config/zod-schema.ts114-121MemoryQmdSchema src/config/zod-schema.ts100-112memory.citations - Controls citation decoration (auto, on, off)Sources: src/config/zod-schema.ts44-121 package.json163-165
OpenClaw runs as a persistent background service (systemd on Linux, launchd on macOS).
| Command | Purpose |
|---|---|
openclaw gateway install | Install systemd/launchd service unit |
openclaw gateway start | Start the service |
openclaw gateway stop | Stop the service |
openclaw gateway restart | Restart the service |
openclaw gateway status | Check service status and RPC probe |
openclaw gateway run | Run gateway in foreground (dev mode) |
| Path | Purpose | Config/Env Override |
|---|---|---|
~/.openclaw/openclaw.json | Main config file | OPENCLAW_CONFIG_PATH |
~/.openclaw/sessions.json | Session state | N/A |
~/.openclaw/credentials/ | OAuth/API key store | N/A |
~/.openclaw/workspace/ | Default agent workspace | agents.defaults.workspace |
~/.openclaw/logs/ | Log files | logging.file |
~/.openclaw/.env | Environment variables | N/A |
Profile isolation:
--dev flag → ~/.openclaw-dev/--profile <name> → ~/.openclaw-<name>/OPENCLAW_STATE_DIR env var for custom state rootSources: src/config/paths.ts (referenced but not provided), docs/cli/index.md63-68 README.md52-90
OpenClaw uses a plugin system for extensibility:
Plugin SDK exports (scoped by subsystem):
openclaw/plugin-sdk/core - Core plugin utilitiesopenclaw/plugin-sdk/telegram - Telegram channel APIsopenclaw/plugin-sdk/discord - Discord channel APIsopenclaw/plugin-sdk/slack - Slack channel APIsPlugin config:
plugins.load.paths - Array of paths to load plugins fromplugins.entries.<id>.enabled - Enable/disable specific pluginsplugins.entries.<id>.config - Plugin-specific configurationplugins.entries.<id>.hooks.allowPromptInjection - Control prompt-mutating hooksSources: package.json37-215 src/config/zod-schema.ts149-161
| Platform | Build Command | Output |
|---|---|---|
| iOS | pnpm ios:build | Xcode project (via xcodegen) |
| Android | pnpm android:assemble | APK in apps/android/app/build/outputs/ |
| macOS | pnpm mac:package | Signed .app bundle |
iOS/macOS specifics:
Android specifics:
Sources: package.json217-330 apps/ios/project.yml1-200 apps/android/app/build.gradle.kts1-169
The main CLI entry point is openclaw.mjs, which delegates to the command tree built by buildProgram().
Command structure:
openclaw [--dev] [--profile <name>] <command>--dev, --profile, --no-color, --json, --versionCommand domains:
onboard, configure, config, doctorgateway, daemon (legacy alias)message, channels, pairingagent, agents, acp, sessionsmodels, memory, browser, cron, hooks, skills, pluginsnodes, devices, nodesecurity, secrets, approvals, sandboxSources: src/cli/program.ts1-3 docs/cli/index.md1-547
Current version: 2026.3.2 (build 20260301)
Version locations:
version: "2026.3.3" package.json3CFBundleShortVersionString: "2026.3.2" apps/ios/Sources/Info.plist22versionName: "2026.3.2" apps/android/app/build.gradle.kts25CFBundleShortVersionString: "2026.3.2" apps/macos/Sources/OpenClaw/Resources/Info.plist18## 2026.3.3 CHANGELOG.md5Release channels:
stable - Tagged releases, npm dist-tag latestbeta - Prerelease tags, npm dist-tag betadev - Moving head of main, npm dist-tag devSources: package.json3 CHANGELOG.md1-605 apps/ios/Sources/Info.plist22 apps/android/app/build.gradle.kts24-25
Refresh this wiki
This wiki was recently refreshed. Please wait 7 days to refresh again.