OpenClaw Architecture Overview
In one sentence
OpenClaw is a resident gateway + multi-channel ingress + agent main loop personal AI assistant. The gateway receives a message → feeds it to the agent → the agent repeatedly calls models and tools → the result is delivered back to each channel through the gateway. Every capability (tools / skills / plugins / providers / MCP / channels) is a pluggable registry.
Layers
Each layer in one line
- Startup and entry:
openclaw.mjsperforms a Node version check and forwards tosrc/entry.ts, which then dispatches subcommands viasrc/cli/run-main.ts. - Gateway layer:
startGatewayServeris the resident process. It accepts requests through an RPC method table and broadcasts agent events to WebSocket clients. - Agent main loop:
embedded-agent-runner'swhile(true)drives each conversation turn; a single attempt completes one LLM call and the tool_use / tool_result pairing. - Capabilities: tools are a Map; skills are Markdown instructions that the model reads from SKILL.md; plugins are discovered by directory convention; providers are split by vendor; MCP is a bidirectional bridge.
- Channels: 22 channels (WhatsApp / Telegram / Slack ...) plug in via registry + loader + plugin, scheduled by the gateway.
- Config system:
openclaw.jsonis the single source of truth; a Zod schema validates it at runtime. - Memory and context: the Context Engine abstracts the compaction contract; memory files live at the workspace root.
- Scheduling and extensions: Cron runs jobs in an isolated agent session; Tasks persist via SQLite; ACP bridges IDEs.
- Deployment: the gateway is a resident process. The daemon wraps it as a system service, or you run it in Docker / Fly.
Why this layering
Why split it this way? OpenClaw fully decouples "where messages come from" (channels), "how they are processed" (agent loop), "which capabilities are used" (tools / skills / plugins / providers), "what persists" (config / memory / scheduling), and "how it runs" (deployment). Swapping a channel doesn't touch agent logic; swapping a model doesn't touch tools; adding a plugin doesn't require core changes. The gateway is the only hub — every cross-layer coordination goes through it.
Common misreadings
- "OpenClaw is a chat bot" — not quite. The bot is just one face of the channel layer; the gateway is the product core and the agent loop is the brain.
- "Tools and skills are the same thing" — they aren't. Tools are callable functions; skills are Markdown instructions that the model decides when to read and what to do with them.
- "MCP is only a client" — OpenClaw is both an MCP server (exposing its own capabilities externally) and a client (consuming external MCP servers).
Suggested reading order
Start with Startup and entry, then Gateway core and Agent main loop, then walk down through Capabilities → Channels → Config system → Memory → Scheduling → Deployment.
Official references: OpenClaw site · Official docs · DeepWiki.