Appearance
OpenClaw多Agent架构支持在单一Gateway进程中运行多个完全隔离的AI智能体,每个Agent拥有独立工作区、模型配置、权限、会话记忆与通道绑定。
一、核心概念
关键术语
| 术语 | 说明 |
|---|---|
| Agent | 独立AI大脑,含专属id、工作区、模型、权限、会话、人设 |
| agentId | Agent唯一标识(英文小写,如main/coding/research) |
| Workspace | Agent本地文件/知识库/工具数据目录(完全隔离) |
| agentDir | Agent状态/认证/配置存储目录(~/.openclaw/agents/) |
| Channel | 消息通道(Telegram/Discord/WhatsApp/飞书/微信等) |
| Binding | 路由规则 → (通道, 账号, 群组/私聊) → 指定agentId |
多Agent核心价值
- ✅ 记忆隔离:不同Agent聊天历史/知识库完全独立
- ✅ 权限隔离:工作Agent高权限,生活Agent只读/低权限
- ✅ 模型隔离:编码用DeepSeek、写作用Claude、分析用Kimi
- ✅ 通道隔离:飞书工作、Telegram生活、Discord开发分开响应
- ✅ 成本优化:简单任务用廉价模型,复杂任务用高阶模型
二、环境准备
系统要求
| 项目 | 最低要求 | 推荐配置 |
|---|---|---|
| OS | Ubuntu 22.04+/macOS 13+/Windows 11 WSL2 | 同左 |
| 内存 | 4GB | 8GB+ |
| 存储 | 10GB | 20GB+ |
| 依赖 | Docker & Docker Compose / Node.js 20+ | 同左 |
安装OpenClaw
Docker方式(推荐):
bash
docker pull openclaw/openclaw:latest
mkdir -p ~/.openclaw && chmod 777 ~/.openclawnpm方式:
bash
npm install -g agentclaw
openclaw init目录结构
~/.openclaw/
├── config.yaml # 主配置(YAML优先于JSON)
├── openclaw.json # 备用配置
├── .env # 密钥/API Key
├── agents/ # Agent状态目录
│ ├── main/ # 默认主Agent
│ ├── coding/ # 编码Agent
│ └── research/ # 研究Agent
└── workspaces/ # 独立工作区
├── main/
├── coding/
└── research/三、创建多Agent
方式1:CLI命令
bash
# 创建新Agent
openclaw agents create coding --model deepseek --description "代码助手"
# 查看所有Agent
openclaw agents list
# 配置路由绑定
openclaw bindings add --channel telegram --bot @my_coding_bot --agent coding方式2:配置文件
编辑 ~/.openclaw/openclaw.json:
json
{
"agents": {
"list": [
{
"id": "main",
"model": "claude",
"workspace": "./workspaces/main"
},
{
"id": "coding",
"model": "deepseek",
"workspace": "./workspaces/coding",
"identity": {
"name": "Coding Assistant",
"description": "专业代码助手"
}
}
]
}
}四、路由配置
Binding规则
yaml
channels:
telegram:
bots:
- token: "your-bot-token"
accounts:
- id: "work-bot"
bindings:
- agent: "coding"
mode: "private"
- agent: "main"
mode: "group"五、启动与验证
bash
# 启动Gateway
openclaw start
# 查看Agent状态
openclaw agents status
# 测试特定Agent
openclaw chat --agent coding