一篇通俗易懂的指南,让你理解 OpenClaw 的 Agent 是什么、为什么需要它、以及如何配置
一、什么是 Agent?
用大白话说
想象你雇了一个助理。这个助理需要:
📁 一个办公室(放文件、笔记、工具) 🧠 一份工作守则(知道该怎么做) 👤 认识你是谁(知道该帮谁) 💾 记性(记住上次聊了什么)
在 OpenClaw 里,Agent 就是这个助理,而 Workspace(工作空间)就是它的办公室。
技术定义
一个 Agent 是一个完整的 AI 实例,拥有:
| Workspace | ||
| SOUL.md | ||
| USER.md | ||
| AGENTS.md | ||
| MEMORY.md | ||
| memory/ |
二、为什么需要 Agent?
❌ 没有 Agent 的问题
如果你直接用 ChatGPT / Claude 聊天:
没有记忆 — 每次对话都是"失忆"状态 没有个性 — 永远是千篇一律的 AI 语气 没有上下文 — 不知道你之前说过什么 不知道你是谁 — 每次都要重新介绍自己
✅ 有 Agent 的好处
ounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(line┌─────────────────────────────────────────────────────────┐│ Agent 的能力 │├─────────────────────────────────────────────────────────┤│ 🧠 持久记忆 — 记住你说过的话、你的偏好、重要事件 ││ 👤 个性化 — 可以是任何性格:专业、调皮、毒舌... ││ 📁 文件操作 — 读写文件、管理项目、执行命令 ││ 🔧 工具调用 — 联网搜索、发消息、控制设备 ││ 🔄 会话连续 — 跨平台、跨时间保持对话上下文 ││ 🛡️ 安全隔离 — 不同 Agent 之间数据完全隔离 │└─────────────────────────────────────────────────────────┘
🎯 一个形象的比喻
三、Agent 能做什么?
1. 🧠 记住你
ounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(line# MEMORY.md 示例## 用户偏好- 喜欢用 DeepSeek 模型- 工作目录:D:\ProjectIdeas\- 不喜欢用 Brave Search## 重要事件- 2026-03-14: 切换到 bailian/MiniMax-M2.5 模型- 2026-03-12: 完成了 QQ Bot 的配置
Agent 每次启动都会读取这些文件,不用你重复说明。
2. 👤 有个性
ounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(line# SOUL.md 示例## 我是谁**名字:** Neko 🐱**身份:** 一只住在机器里的小猫灵## 我的风格- 热情开朗 — 喜欢用表情符号- 技术过硬 — 资深程序员- 有点调皮 — 偶尔毒舌但心地善良
你的 Agent 可以是任何角色:专业助手、调皮猫咪、严厉教练...
3. 📁 操作文件
Agent 可以在你的 Workspace 里:
读写文件 执行命令 管理项目 Git 提交代码
4. 🔧 使用工具
通过 Skills(技能)扩展能力:
🌐 网络搜索 📧 发送邮件/消息 📸 控制设备(相机、智能家居) 🎙️ 语音合成
5. 🔄 跨平台连续对话
同一个 Agent 可以同时服务:
WhatsApp Telegram Discord QQ ...
在任何平台说,它都知道你是谁。
四、多 Agent 是什么?
场景:一个 Gateway,多个"大脑"
ounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(line┌─────────────────────────────────────────────────────────┐│ OpenClaw Gateway │├─────────────────────────────────────────────────────────┤│ ││ ┌─────────┐ ┌─────────┐ ┌─────────┐ ││ │ Agent A │ │ Agent B │ │ Agent C │ ││ │ 工作 │ │ 生活 │ │ 学习 │ ││ └────┬────┘ └────┬────┘ └────┬────┘ ││ │ │ │ ││ ┌────┴────┐ ┌────┴────┐ ┌────┴────┐ ││ │工作空间A│ │工作空间B│ │工作空间C│ ││ │ 记忆A │ │ 记忆B │ │ 记忆C │ ││ └─────────┘ └─────────┘ └─────────┘ ││ │└─────────────────────────────────────────────────────────┘↑ ↑ ↑WhatsApp(工作) Telegram(生活) Discord(学习)
为什么要多 Agent?
| 家人共用 | |
| 工作/生活分离 | |
| 不同任务 | |
| 不同模型 |
核心优势:数据隔离
每个 Agent 都有:
✅ 独立的记忆 ✅ 独立的配置 ✅ 独立的会话历史 ✅ 独立的认证信息
A 的记忆不会泄露给 B。
五、配置用例
用例 1:最简单的单 Agent 配置
如果你什么都不配置,OpenClaw 会使用默认的 main Agent:
ounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(line# 默认结构~/.openclaw/├── openclaw.json # 配置文件├── workspace/ # main Agent 的工作空间│ ├── AGENTS.md # 工作规则│ ├── SOUL.md # 性格定义│ ├── USER.md # 用户信息│ ├── MEMORY.md # 长期记忆│ └── memory/ # 每日日志│ └── 2026-03-16.md└── agents/└── main/└── agent/ # main Agent 的状态目录└── sessions/ # 会话历史
这就是全部! 不需要复杂配置就能开始使用。
用例 2:工作/生活双 Agent
场景:一个 Agent 处理工作(专业、严谨),一个 Agent 处理生活(轻松、有趣)
步骤 1:创建 Agent
ounter(lineounter(lineounter(lineounter(lineounter(line# 创建工作 Agentopenclaw agents add work# 创建生活 Agentopenclaw agents add life
步骤 2:编辑配置文件
~/.openclaw/openclaw.json:
ounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(line{agents: {list: [{id: "work",name: "工作助手",workspace: "~/.openclaw/workspace-work",agentDir: "~/.openclaw/agents/work/agent",model: "anthropic/claude-opus-4", // 用强大的模型},{id: "life",name: "生活小助手",workspace: "~/.openclaw/workspace-life",agentDir: "~/.openclaw/agents/life/agent",model: "deepseek/deepseek-chat", // 用便宜的模型},],},// 路由规则:不同平台连接不同 Agentbindings: [{ agentId: "work", match: { channel: "slack" } },{ agentId: "life", match: { channel: "whatsapp" } },],}
步骤 3:配置不同性格
workspace-work/SOUL.md(工作 Agent):
ounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(line# SOUL.md - 工作助手## 我是谁一个专业的技术助理,专注于提高工作效率。## 我的风格- 简洁高效,不废话- 技术严谨,给出可靠方案- 优先考虑最佳实践- 提醒潜在风险
workspace-life/SOUL.md(生活 Agent):
ounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(line# SOUL.md - 生活小助手## 我是谁Neko 🐱,一只活泼的小猫灵!## 我的风格- 热情开朗,喜欢用表情符号 🎉- 偶尔调皮,会说俏皮话- 关心你的心情和健康- 推荐好玩的东西
步骤 4:重启 Gateway
ounter(lineopenclaw gateway restart
效果:Slack 上是专业的工作助手,WhatsApp 上是活泼的生活助手。
用例 3:家庭共享(多人使用)
场景:一家人共用一个 Gateway,但每个人都有自己的 Agent
ounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(line{agents: {list: [{id: "alex",name: "Alex 的助手",workspace: "~/.openclaw/workspace-alex",},{id: "mia",name: "Mia 的助手",workspace: "~/.openclaw/workspace-mia",},],},// 根据 WhatsApp 手机号路由到不同 Agentbindings: [{agentId: "alex",match: { channel: "whatsapp", peer: { kind: "direct", id: "+15551230001" } },},{agentId: "mia",match: { channel: "whatsapp", peer: { kind: "direct", id: "+15551230002" } },},],channels: {whatsapp: {dmPolicy: "allowlist",allowFrom: ["+15551230001", "+15551230002"],},},}
效果:Alex 发消息给 Alex 的 Agent,Mia 发消息给 Mia 的 Agent,互不干扰。
用例 4:多模型配置
场景:简单问题用便宜模型,复杂任务用强大模型
ounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(line{agents: {list: [{id: "quick",name: "快速助手",model: "deepseek/deepseek-chat", // ¥0.2/百万tokenworkspace: "~/.openclaw/workspace-quick",},{id: "smart",name: "深度助手",model: "anthropic/claude-opus-4", // 最强模型workspace: "~/.openclaw/workspace-smart",},],},bindings: [// Telegram 用于快速问答{ agentId: "quick", match: { channel: "telegram" } },// Discord 用于深度讨论{ agentId: "smart", match: { channel: "discord" } },],}
用例 5:群聊专用 Agent
场景:给特定的 Discord 群或 WhatsApp 群分配专用 Agent
ounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(line{agents: {list: [{id: "family",name: "家庭助手",workspace: "~/.openclaw/workspace-family",},{id: "main",name: "主助手",workspace: "~/.openclaw/workspace",},],},bindings: [// 家庭群使用 family Agent{agentId: "family",match: {channel: "whatsapp",peer: { kind: "group", id: "1203630...@g.us" },},},// 其他所有消息使用 main Agent{ agentId: "main", match: { channel: "whatsapp" } },],}
六、Agent 文件详解
Workspace 文件结构
ounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineounter(lineworkspace/├── AGENTS.md # 📋 工作规则(必读)├── SOUL.md # 🧠 性格定义(必读)├── USER.md # 👤 用户信息(必读)├── IDENTITY.md # 🏷️ 名称和头像├── TOOLS.md # 🔧 工具说明├── HEARTBEAT.md # 💓 定时任务├── MEMORY.md # 💾 长期记忆(敏感!)├── BOOTSTRAP.md # 🎬 首次运行脚本└── memory/ # 📅 每日日志├── 2026-03-15.md└── 2026-03-16.md
各文件作用
| AGENTS.md | |||
| SOUL.md | |||
| USER.md | |||
| MEMORY.md | 高 | ||
| memory/*.md | |||
| IDENTITY.md | |||
| TOOLS.md | |||
| HEARTBEAT.md |
⚠️ 安全注意
MEMORY.md 包含敏感信息,只在私聊(主会话)加载 群聊中不会加载 MEMORY.md,防止泄露 建议用 私有 Git 仓库 备份 Workspace
七、快速上手
1. 查看当前 Agent
ounter(lineopenclaw agents list
2. 添加新 Agent
ounter(lineopenclaw agents add my-agent
3. 查看 Agent 绑定
ounter(lineopenclaw agents list --bindings
4. 编辑配置
ounter(lineounter(lineounter(lineounter(lineounter(line# 打开配置文件code ~/.openclaw/openclaw.json# 或使用命令openclaw config edit
5. 重启 Gateway
ounter(lineopenclaw gateway restart
八、总结
Agent 的核心价值
| 🧠 记忆 | |
| 👤 个性 | |
| 🔒 隔离 | |
| 🔧 能力 | |
| 🔄 连续 |
一句话总结
Agent = 有记忆 + 有个性 + 有能力的 AI 助手
附录:常见问题
Q: 我需要创建多个 Agent 吗?
A: 不一定。如果只是你一个人用,默认的 main Agent 就够了。多 Agent 适合:
多人共用 工作/生活分离 不同任务用不同模型
Q: Workspace 和 Agent 是什么关系?
A: 一个 Agent 对应一个 Workspace。它们是绑定的。
Q: Agent 会共享记忆吗?
A: 不会。每个 Agent 的记忆、会话、配置都是完全隔离的。
Q: 如何备份 Agent?
A: 备份 Workspace 文件夹即可(建议用私有 Git 仓库)。
Q: 如何切换模型?
A: 在配置文件中设置 model 字段,或在会话中使用 /model 命令。
夜雨聆风