How OpenClaw
works under the hood
Architecture & technical flow
You already know what OpenClaw does and why it exists. Today we open the hood and look at what's inside; from the moment a message arrives on WhatsApp or Telegram to when the agent executes an action and responds.
One process,
many channels,
one agent
OpenClaw is a Node.js daemon running continuously on hardware you control: a Mac Mini, a VPS, a home server.
- Single process connects to all messaging channels
- WhatsApp, Telegram, Slack, Discord, iMessage - 50+ adapters
- The agent is the same across all of them: same state, same tools, same memory
Hub-and-spoke
architecture
The hub is the Gateway - a WebSocket server listening on port 18789, bound to localhost.
- Channel bridges - messaging platform adapters
- Control clients - desktop app, CLI, admin web UI
- Nodes - devices exposing local capabilities (camera, screen, location)
Each client connects to the same WebSocket server, declares its role on handshake, and the Gateway routes accordingly.
A message's
journey
main, group, or isolated
What the
model sees
A fresh system prompt is assembled every turn from multiple workspace files:
bootstrapMaxChars 20k / file
bootstrapTotalMaxChars 150k total
The agentic
loop
The standard agent pattern, with OpenClaw's control layers on top.
- Model responds with text (done) or a tool call (continue)
- OpenClaw executes the tool, appends result to history, re-sends to model
- Repeats until text-only response or 600s timeout
Model-agnostic: Anthropic, OpenAI, local models. Key rotation built in.
What the agent
can do - and
how to limit it
Docker sandboxing - tool execution inside an isolated container, not the host.
offEverything on hostnon-mainNon-main sessions sandboxedallEverything sandboxedDefault: no network, no write access to root fs, isolated workspace. Not a perfect sandbox - reduces blast radius, not an absolute limit.
How a stateless
model remembers
Compaction invalidates Anthropic's prompt cache - each unnecessary compaction is a reliability and cost problem.
Extending
without touching
the core
OpenClaw is plugin-first. Core is ~8MB after the 2026 refactor. Even model providers are external packages.
-
Skills -
SKILL.md+ optional scripts. 5,400+ on ClawHub. Model reads full content only when relevant. - Channel plugins - adapters for new messaging platforms
- Provider plugins - new model APIs or local inference engines
- Memory plugins - alternative backends (vector stores, knowledge graphs)
Plugin discovery: loader scans for openclaw.extensions in package.json, validates schemas, hot-loads.
Where the
real risks are
0.0.0.0.
Everything that makes it powerful is exactly what makes it dangerous: shell, filesystem, browser, email, external services.
Trust hierarchy: Operator → Gateway config → Allowed peers → AI model → Untrusted content
Hardening baseline:
- Gateway bound to loopback only
- Remote access via SSH tunnel or Tailscale
- Sandboxing enabled + tool allowlists
- Credentials in plaintext at
~/.openclaw/- protect accordingly