Understand how OpenClaw (formerly Clawdbot and Moltbot) is structured and operates
OpenClaw is built around a Gateway-centric architecture where a single long-running process manages all channel connections and provides a unified control plane. This design ensures reliability, security, and simplicity.
The Gateway (openclaw gateway) is the heart of OpenClaw. It's a single process that:
Key Principle: One Gateway per host is recommended. It's the only process allowed to own the WhatsApp Web session, ensuring stability and preventing conflicts.
OpenClaw uses a loopback-first approach for security:
ws://127.0.0.1:18789 (localhost only)--bind tailnet with authentication tokens/__openclaw__/canvas/ for node WebViewsWhatsApp / Telegram / Discord / iMessage (+ plugins)
│
▼
┌───────────────────────────┐
│ Gateway │ ws://127.0.0.1:18789 (loopback-only)
│ (single source) │
│ │ http://<gateway-host>:18793
│ │ /__openclaw__/canvas/ (Canvas host)
└───────────┬───────────────┘
│
├─ Pi agent (RPC)
├─ CLI (openclaw …)
├─ Chat UI (SwiftUI)
├─ macOS app (OpenClaw.app)
├─ iOS node via Gateway WS + pairing
└─ Android node via Gateway WS + pairing
The agent loop is the core processing cycle:
This loop runs continuously, maintaining context and state across conversations.
main session by defaultOpenClaw stores everything as files and folders in your workspace (~/clawd by default):
~/.clawdbot/moltbot.json (path maintained for backward compatibility with Clawdbot/Moltbot)~/.clawdbot/credentials/~/clawd/AGENTS.md, SOUL.md, TOOLS.md~/clawd/skills/<skill>/SKILL.mdThis file-based approach means you can:
OpenClaw supports routing messages to different agents based on:
This allows you to run multiple specialized agents, each with their own context, skills, and configuration.
OpenClaw uses advanced streaming techniques:
The Gateway exposes a WebSocket API for:
Agents communicate via RPC (Remote Procedure Call) for: