“EXFOLIATE! EXFOLIATE!” —— a space lobster (probably)
Introduction
In an age where AI assistants are everywhere, most products host user data in the cloud and provide services via an API. But if you want an AI assistant that is truly your own — one that runs on your own devices, connects to the messaging tools you use, and executes the automation tasks you write — then OpenClaw may be the answer you’ve been looking for.
After several days of deep research and source reading, in this article I’ll walk you through OpenClaw’s architecture design, its core components, and how it achieves a “local-first, privacy-first” AI assistant experience.
What Is OpenClaw?
OpenClaw is a self-hosted personal AI assistant gateway, developed by the team behind Pi. Its core idea can be summed up in one sentence:
AI that actually does things. It runs on your devices, in your channels, with your rules.
Main Features
- Multi-platform messaging integration: 20+ channels including WhatsApp, Telegram, Slack, Discord, Signal, iMessage, Feishu, LINE, and more
- Local-first architecture: The Gateway runs on your devices (macOS, Linux, Windows WSL2)
- Multi-agent support: Run multiple independent AI agents simultaneously
- Rich tool ecosystem: Browser control, scheduled tasks, file system operations, Canvas visualization
- Companion mobile apps: iOS/Android node apps with voice wake-up and continuous conversation
- Skill system: An extensible skill system that defines new capabilities via SKILL.md
Architecture Overview
OpenClaw uses a layered architecture design, with the Gateway at its core, around which all components are built:
|
Core Design Principles
- Single Gateway: One Gateway instance controls all messaging channels, avoiding multi-instance conflicts with libraries like Baileys/WhatsApp
- WebSocket long connections: All clients communicate with the Gateway over WebSocket, supporting real-time event pushes
- Local-first: Binds to
127.0.0.1:18789by default, keeping data local - Explicit security: All high-risk operations (like executing commands) require explicit configuration, rather than being open by default
Core Components in Detail
1. Gateway
The Gateway is the control plane of the whole system, responsible for:
- Channel management: Maintaining connections to platforms like WhatsApp and Telegram
- Message routing: Routing messages to different Agents according to configuration
- Session management: Maintaining session state, history, and context
- Tool execution: Managing tool execution and security policies
The Gateway uses TypeBox to define protocol schemas, ensuring type safety:
|
2. Agent Runtime
OpenClaw uses the embedded runtime of pi-mono, but session management and tool invocation are entirely controlled by OpenClaw itself.
Workspace is the core concept of an Agent:
|
These files are automatically injected into the Agent’s context at session startup, becoming part of the system prompt.
3. Skills System
Skills are OpenClaw’s extension mechanism, using a format compatible with AgentSkills:
|
|
Workspace Skills (highest) → ~/.openclaw/skills → Bundled Skills (lowest)
|
The Mystery of the Session Key
OpenClaw uses sessionKey to route messages to the right session:
|
session.dmScope configures the isolation level for DMs:
main: All DMs go to the main session (default)per-channel-peer: Independent session per channel + userper-account-channel-peer: For multi-account scenarios
Security Architecture: Trust Boundaries and Execution Control
OpenClaw uses a personal-assistant trust model, rather than multi-tenant isolation:
Default assumption: the Gateway runs within a trusted operator boundary.
Three Layers of Security Defense
Network layer:
- Binds to
127.0.0.1by default (local only) - Supports Token/Password authentication
- Device pairing (auto-approved locally, explicitly approved remotely)
- Binds to
Channel layer:
- DM pairing policy (pairing/allowlist/open/disabled)
- Group mention requirement
- Allowlist control
Tool layer:
tools.profilecontrols the available tool settools.exec.safeBinsrestricts executable binariestools.exec.askconfigures pre-execution confirmation (off/on-miss/always)- Sandbox mode (Docker isolation)
Why Does the exec Tool Need Special Configuration?
In OpenClaw 2026.3.8, the exec tool by default does not include interpreters like bash/python in safeBins, because:
|
This is a deliberate security design — the ability to execute arbitrary code must be explicitly enabled.
Extensions: The Plugin System and MCP
OpenClaw’s architecture encourages extending functionality via Plugins:
- Extensions: Located in the
extensions/directory, such as Feishu, Matrix, Mattermost - NPM packages: Plugins that can be published and installed independently
- MCP support: Bridging MCP servers through mcporter
The design philosophy of MCP (Model Context Protocol) is similar to OpenClaw’s Skill system — both aim to standardize how AI tools are integrated.
Practical Deployment Modes
Mode One: Local Development Workstation
|
Suits: developers, privacy-sensitive users
Mode Two: VPS + Tailscale
|
Suits: users who need access anywhere, anytime
Mode Three: Docker Deployment
|
Suits: server environments, scenarios needing isolation
Hands-On Experience with the WeRead Skill
In my attempt to create a Skill for WeRead, I came to understand OpenClaw’s working mechanism deeply:
Challenges Encountered
- Tool not injected: In the default config, the
exectool is enabled, but interpreters (python3/bash) require explicit safeBins configuration - System Prompt structure: Skills are just a “manual” for the LLM; the actual tool definitions are controlled by the Gateway
- Timeout issue: Local model calls may time out;
timeoutSecondsneeds to be set reasonably
The Final Approach
For scenarios that need to run local scripts, the most stable approach at present is:
- Shell Wrapper: Define a function in
~/.bashrcto bypass OpenClaw’s tool system - Feishu Bot: Trigger via Webhook and let the bot execute the command directly
- Wait for fixes: Follow GitHub Issues and wait for improvements to tool configuration
Summary: OpenClaw’s Unique Value
In an age where AI services are increasingly centralized, OpenClaw offers a decentralized alternative:
| Feature | Cloud AI service | OpenClaw |
|---|---|---|
| Data privacy | Data uploaded to a provider | Data kept local |
| Customization | Limited by platform capabilities | Fully extensible (Skills/Plugins) |
| Integration | Closed ecosystem | Open channels (20+ messaging platforms) |
| Cost | API call fees | Self-hosting cost |
| Reliability | Depends on the provider | Fully under your own control |
OpenClaw is best for:
- Privacy-first users: Those unwilling to upload sensitive conversations to the cloud
- Heavy customization: Those needing deep integration of specific tools and flows
- Multi-platform: Those managing messages across multiple messaging channels
- Tech enthusiasts: Developers willing to invest time in self-hosting and customization
Reference Resources
- OpenClaw official site
- Official documentation
- GitHub repository
- Discord community
- AgentSkills specification
This article is based on a source-code analysis of OpenClaw 2026.3.8. The project iterates quickly, and some details may change with future versions.
评论
0 条评论