如何让多个 AI 助理各司其职、协同工作,而不是依靠一个“万能助手”包揽所有任务?这其实是许多团队在引入 AI 工具后,都会遇到的实际挑战。
借助 OpenClaw 的多 Agent 架构,你完全可以实现这样的场景:多个独立的飞书机器人,每个都拥有专属的角色设定;各自拥有独立的工作空间,数据互不干扰;而在需要的时候,又能通过 agentToAgent 通信机制彼此协作,共享长期记忆,实现跨渠道的信息同步。
这篇文章将完整梳理整个流程,从腾讯云服务器部署开始,到配置 5 个不同角色的飞书 Agent,再到常见的踩坑问题和实战协作案例,一次性讲透。

为什么需要多 Agent
相比一个“什么都会”的通用 AI,多 Agent 架构的优势主要体现为两点:专业化分工,以及由此带来的协作效率提升。
单一 AI 的局限
不可否认,通用 AI 确实能处理多种任务,但一旦场景变得复杂,短板便会显现:
- 记忆容量有限——难以同时维护多个专业领域的信息,聊着 A 领域的事情,B 领域的细节就可能丢失。
- 上下文容易混淆——不同类型的数据混在同一个上下文里,彼此干扰,回答可能出现“串味”。
- 缺乏持续追踪能力——无法长期独立跟踪特定领域的任务进度,今天聊完,明天就忘记了进展。
多 Agent 的优势
多 Agent 架构的核心逻辑其实很简单:专业化分工 + 协作。每个 Agent 只专注自己的领域,通过 agentToAgent 这一机制实现高效沟通,各司其职,各有所长。
前置准备
1. 腾讯云轻量应用服务器
- 推荐配置:前期选择最低配,2 核 2GB 已足够使用
- 镜像选择:OpenClaw
2. 飞书开发者账号
- 前往飞书开放平台注册账号:https://open.feishu.cn
- 如果没有企业,需要先创建一个
5 个 Agent 角色设计
从实际使用场景出发,可以设计如下 5 个 Agent,各自承担明确职责:
| Agent ID | 名称 | 职责 |
|---|---|---|
aiboss | 大总管 | 总协调助手,负责协调其他 Agent 和日常任务 |
ainews | 资讯助理 | AI 行业资讯收集,每日 8:00 和 18:00 推送 |
aicontent | 内容助理 | 文章写作、视频脚本、社交媒体内容 |
aicode | 代码助理 | 代码审查、技术方案、问题解决 |
aitask | 任务助理 | 任务跟踪、提醒、进度管理 |
配置飞书多应用
步骤 1:创建 5 个飞书应用
- 登录飞书开放平台
- 进入“应用管理” → “创建应用” → “自建应用”
- 填写应用信息:
- 应用名称:例如“AI大总管”、“AI资讯助理”
- 应用描述:简要说明该 Agent 的职责
- 应用图标:建议每个 Agent 使用不同的图标,方便区分
- 点击“创建”
重复上述步骤,依次创建 5 个独立应用。
步骤 2:获取应用凭证(务必先完成)
针对每个应用,在“凭证与基础信息”页面记录以下信息:
- App ID:格式如
cli_xxx - App Secret:格式如
i63Qyyyyy
| Agent | 应用名称 | App ID | App Secret |
|---|---|---|---|
| aiboss | AI大总管 | cli_xxxxxxxxxxxxx | your_app_secret_here |
| aicontent | AI内容助理 | cli_xxxxxxxxxxxxx | your_app_secret_here |
| ainews | AI资讯助理 | cli_xxxxxxxxxxxxx | your_app_secret_here |
| aicode | AI代码助理 | cli_xxxxxxxxxxxxx | your_app_secret_here |
| aitask | AI任务助理 | cli_xxxxxxxxxxxxx | your_app_secret_here |
步骤 3:配置应用能力(⚠️ 关键步骤)
OpenClaw 配置完成后,需要为每个应用完成以下配置:
3.1 开启机器人能力
- 进入应用详情 → “权限管理”
- 开启“机器人能力”
- 添加必要的权限:
im:message(接收消息)im:message:group_at_msg(接收群组 @ 消息)im:message:send_as_bot(发送消息)
3.2 配置事件订阅(⚠️ 长连接)
- 进入“事件订阅”
- 选择“长连接”模式
- 启用以下事件:
im.message.receive_v1(接收消息)im.message.message_read_v1(消息已读)
3.3 发布应用
- 进入“版本管理与发布”
- 创建新版本
- 填写更新日志
- 发布(可选择“开发版”或“正式版”)
OpenClaw 多 Agent 配置
部署方式选择
这里使用腾讯云轻量应用服务器的 OpenClaw 镜像进行部署。具体流程如下:
1. 购买腾讯云轻量应用服务器
参考前置准备的内容购买服务器,进入控制台 → 概要。腾讯提供的 OpenClaw WEB 配置界面(控制台 → 应用管理)如下图所示,但由于不支持多 Agent 配置,本次直接修改服务器上的配置文件。

2. 配置模型
以 GLM-4.7 为例,进入控制台 → 应用管理,选择智普 AI Coding Plan,输入 KEY 保存即可。

3. 登录服务器
根据实际配置选择对应的登录方式,进入服务器后台。

4. 验证 OpenClaw 安装
# 检查 OpenClaw 版本
openclaw --version
# 查看 Gateway 状态
openclaw gateway status
5. 配置方式选择
腾讯云 OpenClaw 镜像支持两种配置方式:
| 配置方式 | 优点 | 缺点 | 适用场景 |
|---|---|---|---|
| Web 界面配置 | 可视化操作,简单直观 | 功能有限,不支持高级配置 | 快速体验、简单场景 |
| 直接编辑 JSON | 完整功能、灵活强大 | 需要了解 JSON 格式 | 自定义配置、多 Agent 等 |
本次采用直接编辑 openclaw.json 的方式,原因有两点:Web 界面不支持多 Agent 高级配置;JSON 配置更灵活,能实现完整功能。
# 打开配置文件
vi /root/.openclaw/openclaw.json
配置完成后,重启 Gateway 使配置生效:
openclaw gateway restart
步骤 1:创建独立 Workspace
每个 Agent 都需要独立的工作空间,确保数据完全隔离:
# 创建 5 个独立工作区
mkdir -p /root/.openclaw/workspace-boss
mkdir -p /root/.openclaw/workspace-news
mkdir -p /root/.openclaw/workspace-content
mkdir -p /root/.openclaw/workspace-code
mkdir -p /root/.openclaw/workspace-task
步骤 2:编辑 openclaw.json
打开配置文件:
vi /root/.openclaw/openclaw.json
2.1 配置 agents 数组
在 agents 字段中添加 5 个 Agent:
"agents": {
"list": [
{
"id": "aiboss",
"default": true,
"name": "aiboss",
"workspace": "/root/.openclaw/workspace-boss",
"model": {
"primary": "glmcode/glm-4.7"
}
},
{
"id": "aicontent",
"name": "aicontent",
"workspace": "/root/.openclaw/workspace-aicontent",
"model": {
"primary": "glmcode/glm-4.7"
}
},
{
"id": "ainews",
"name": "ainews",
"workspace": "/root/.openclaw/workspace-ainews",
"model": {
"primary": "glmcode/glm-4.7"
}
},
{
"id": "aicode",
"name": "aicode",
"workspace": "/root/.openclaw/workspace-aicode",
"model": {
"primary": "glmcode/glm-4.7"
}
},
{
"id": "aitask",
"name": "aitask",
"workspace": "/root/.openclaw/workspace-aitask",
"model": {
"primary": "glmcode/glm-4.7"
}
}
]
}
2.2 配置飞书多账户
在 channels.feishu 字段中添加 5 个账户:
"channels": {
"feishu": {
"enabled": true,
"accounts": {
"aiboss": {
"appId": "cli_xxxxxxxxxxxxx",
"appSecret": "your_app_secret_here"
},
"aicontent": {
"appId": "cli_xxxxxxxxxxxxx",
"appSecret": "your_app_secret_here"
},
"ainews": {
"appId": "cli_xxxxxxxxxxxxx",
"appSecret": "your_app_secret_here"
},
"aitask": {
"appId": "cli_xxxxxxxxxxxxx",
"appSecret": "your_app_secret_here"
},
"aicode": {
"appId": "cli_xxxxxxxxxxxxx",
"appSecret": "your_app_secret_here"
}
}
}
}
2.3 配置 bindings 路由
在 bindings 数组中添加消息路由规则:
"bindings": [
{
"match": {
"channel": "feishu",
"accountId": "aiboss"
},
"agentId": "aiboss"
},
{
"match": {
"channel": "feishu",
"accountId": "aicontent"
},
"agentId": "aicontent"
},
{
"match": {
"channel": "feishu",
"accountId": "ainews"
},
"agentId": "ainews"
},
{
"match": {
"channel": "feishu",
"accountId": "aicode"
},
"agentId": "aicode"
},
{
"match": {
"channel": "feishu",
"accountId": "aitask"
},
"agentId": "aitask"
}
]
2.4 开启 agentToAgent 通信
在 tools 字段中配置:
"tools": {
"agentToAgent": {
"enabled": true,
"allow": ["aiboss", "aicontent", "ainews", "aicode", "aitask"]
}
}
步骤 3:为每个 Agent 创建核心文件
在每个 workspace 中创建以下文件。
3.1 IDENTITY.md(身份信息)
# 以 aiboss 为例
cat > /root/.openclaw/workspace-boss/IDENTITY.md << 'EOF'
# IDENTITY.md - AIBoss
- **Name**: AIBoss
- **Role**: 大总管,团队协调者
- **Emoji**: 