How OpenClaw Works
The architecture at a glance — how a message flows from your phone to the AI and back.
🏗️ Architecture Overview
📨 How a Message Flows
You send a message
Via WhatsApp, Telegram, Discord, or any connected channel.
Gateway receives it
The Gateway is the central hub. It maintains all channel connections (WhatsApp via Baileys, Telegram via grammY, etc.) and routes messages.
Session is resolved
The Session Manager finds or creates a session for this sender. DMs merge into a "main" session; group chats get isolated sessions.
Agent processes the message
The Agent Runtime builds context (system prompt + memory + tools) and sends it to your configured LLM (Anthropic, OpenAI, Google, etc.).
Reply is sent back
The response streams back through the Gateway to the original channel. Media (images, audio) is converted to the channel's format automatically.
🧩 Core Components
Gateway
Central daemon process. Maintains channel connections, WebSocket API, session state. One per host.
Agent Runtime
Embedded loop that builds context, calls the LLM, handles tool results, and streams responses.
Context Engine
Assembles system prompt, memory, skills, workspace files, and conversation history into the context window.
Memory
MEMORY.md + daily logs + semantic search. Gives your agent continuity across sessions.
Skills
Installable capability packs. SKILL.md files teach the agent how to use specific tools.
Nodes
macOS/iOS/Android devices that connect to the Gateway. Provide camera, screen, canvas, location, and voice.
Model Providers
35+ providers: Anthropic, OpenAI, Google, Ollama, vLLM, and any OpenAI-compatible endpoint.
Sandbox
Isolated execution environment for agent code. Prevents destructive operations on the host.