Phase 2 / Ep 11: Agent 管理 —— agents add, list, switch

⏱ 预计阅读 3 分钟 更新于 2026/4/13

🎯 学习目标:掌握多 Agent 架构的创建和管理。

1. 为什么要多个 Agent?

一个 Agent 做所有事情 = 一个员工身兼十职。专业化分工才是最佳实践。

graph LR
    subgraph Gateway["🦀 Gateway"]
        Router["Router"]
    end
    Router --> A1["🧑‍💼 personal\n日常助手\nbasic 权限"]
    Router --> A2["💻 code-agent\n编程助手\ncoding 权限"]
    Router --> A3["📊 ops-agent\n运维监控\nfull 权限(容器内)"]

2. 核心命令

# 列出所有 Agent
openclaw agents list

# 创建新 Agent
openclaw agents add code-agent
openclaw agents add ops-agent

# 切换默认 Agent
openclaw agents switch code-agent

# 查看 Agent 详情
openclaw agents info code-agent

# 删除 Agent
openclaw agents remove ops-agent

3. 工作空间隔离

每个 Agent 有独立的工作空间:

~/.openclaw/agents/
├── personal/          # 默认 Agent
│   ├── SOUL.md
│   ├── USER.md
│   ├── TOOLS.md       # basic 权限
│   ├── memory/
│   └── sessions/
├── code-agent/        # 编程 Agent
│   ├── SOUL.md        # 不同的人格
│   ├── TOOLS.md       # coding 权限
│   ├── skills/
│   │   └── git-assist/
│   └── sessions/
└── ops-agent/         # 运维 Agent
    ├── SOUL.md
    ├── TOOLS.md       # full 权限
    └── sessions/

4. CLI vs Telegram 对照

操作 CLI Telegram
列出 Agent openclaw agents list /agents
创建 Agent openclaw agents add name N/A
切换 Agent openclaw agents switch name /switch name
Agent 信息 openclaw agents info name /agent info

下节预告: Ep 12,日志系统——当 Agent 出问题时,如何用 logs 和 sessions 快速定位故障。