OpenClaw 多飞书机器人部署与多 Agent 团队协作实战

这次实践的目标很明确:在 Windows 上稳定跑通 OpenClaw,接入飞书机器人,做到一个机器人对应一个 Agent 角色,支持多模型并行,最终形成可执行的多 Agent 团队。目前落地状态已验证:渠道为 Feishu 多账号在线,路由按 accountId 精确绑定到对应 Agent,角色覆盖产品经理、技术开发、测试质保、代码评审、文档维护及发布运维。
一、跨系统安装与 Gateway 排障
1. 从零安装 OpenClaw
环境前置检查
先确认 Node 和 npm 版本,建议 Node.js >= 22,npm >= 10。如果版本过低,请先升级再安装 OpenClaw。
node -v && npm -v
按系统执行安装命令
macOS / Linux:
curl -fsSL https://openclaw.ai/install.sh | bash
Windows(PowerShell):
iwr -useb https://openclaw.ai/install.ps1 | iex
安装完成后统一验证版本号(如 2026.x.x):
openclaw --version
首次初始化
推荐运行以下命令完成向导配置,包括选择模型供应商、完成认证及写入本地配置:
openclaw onboard --install-daemon
健康检查
安装后建议立即进行健康检查,确保网关连通性正常:
openclaw doctor
openclaw status
openclaw health
openclaw gateway status
openclaw gateway probe
通过标准:doctor 无致命错误,gateway probe 显示 Reachable: yes,本地网关目标通常为 ws://127.0.0.1:18789。
最小可用调用测试
尝试发送一条消息验证连通性:
openclaw agent --agent main -m "你好,请回复:安装连通通过" --json
只要返回 JSON 且无致命报错(即使出现 gateway fallback),即视为成功。
解决 openclaw 命令找不到(PATH)
如果终端无法识别命令,需检查环境变量:
macOS / Linux:
npm prefix -g && echo "$PATH"
Windows(PowerShell):
npm prefix -g; $env:Path
修复原则是将 $(npm prefix -g)/bin 或 npm prefix -g 输出目录加入系统 PATH。
打开控制台确认运行态
默认地址一般为 http://127.0.0.1:18789/:
openclaw dashboard
接入 Feishu
安装完成后应尽快接入飞书渠道:
- 安装插件:
openclaw plugins install @openclaw/feishu - 添加渠道:
按提示选择openclaw channels addFeishu,填入开放平台的App ID与App Secret。 - 重启并检查网关:
openclaw gateway restart openclaw gateway status openclaw logs --follow - 首次私聊机器人后完成配对:
openclaw pairing list feishu --json openclaw pairing approve feishu <配对码>
至此,OpenClaw 的'安装 + 网关 + 渠道 + 配对'闭环才算完整。
2. 常见安装报错处理
问题:npm error code 1
在 PowerShell 执行安装时可能遇到此报错。经验是不要只看中间 warning,继续查看日志,最终版本通常可用。验证方法:
openclaw --version # 例如 2026.2.24
问题:Gateway 状态异常
现象:openclaw gateway status 显示服务缺失,或 probe 报 1006 或 RPC 失败。可通过前台启动确认服务本体:
openclaw gateway run --verbose
若观察到 listening on ws://127.0.0.1:18789,说明主进程正常。
问题:Windows 下 --force 报 lsof not found
Windows 没有 lsof 工具,直接去掉 --force 参数即可:
openclaw gateway run --verbose
二、模型连通与会话参数
1. 会话选择参数
Agent 命令有时缺少会话定位参数会报错。修复方式是在命令中显式指定 --agent:
openclaw agent --agent main -m "你好,请回复:连通测试通过" --json
2. 网关回退机制
如果看到 Gateway agent failed; falling back to embedded 提示,不必惊慌。关键看最终 JSON 是否 status: ok,这不代表请求失败。
三、Feishu 集成与配对机制
1. 首次消息反馈
飞书首次私聊机器人时,常见返回如下:
OpenClaw: access not configured. Your Feishu user id: ou_xxx Pairing code: XXXXXXXX Ask the bot owner to approve with: openclaw pairing approve feishu XXXXXXXX
2. 审批命令实践
通用审批方式:
openclaw pairing approve feishu <配对码>
按账号审批方式:
openclaw pairing approve --channel feishu --account <accountId> <配对码>
实践中需注意:某些请求在全局队列可见,但在 --account 过滤下为空。最稳妥做法配合检查:
openclaw pairing list feishu --json
四、多机器人 + 多 Agent 团队搭建
我们最终搭建了 6 个飞书机器人角色,并做了账号到 Agent 的一一绑定。
1. 角色设计
- 总控(产品经理)
- 技术开发
- 测试质保
- 代码评审(架构把关)
- 文档与知识库维护
- 发布运维
2. 路由原则
核心不是'一个默认 Agent',而是'按渠道账号精确路由'。配置示例:
{"agentId":"pm-agent","match":{"channel":"feishu","accountId":"pm"}}
同理分别配置 dev / qa / review / docs / ops 对应各自 Agent。
3. 结果验证命令
openclaw channels status --json --probe
openclaw config get bindings --json
openclaw agents list --json
验证标准:所有目标账号 probe.ok = true,bindings 包含每个 accountId -> agentId,各 Agent 可独立响应。
五、模型分工与策略
1. 默认模型策略
团队主体使用:
openai-codex/gpt-5.2
2. 单独模型策略(文档 Agent)
文档机器人专门使用:
ollama/gpt-oss:20b-cloud
将'模型选择'从全局配置下沉到具体 Agent,好处在于成本可控、任务与能力匹配清晰,且故障隔离更好(某个 provider 出问题,不拖垮全部机器人)。
六、踩坑重点:身份错位修复
实际出现过:在终端 pm-agent 自测正常,但飞书里却回答成'默认小爪'。排查后发现核心原因通常有两类:
- 路由没命中目标 Agent,实际走到了
main - Agent 身份文件是模板,未完成角色固化
修复动作:
- 看渠道日志中的
dispatching to agent (session=...) - 校验
bindings是否确实匹配channel + accountId - 在该 Agent 工作区写明
IDENTITY.md - 在
AGENTS.md加'身份锁定规则' - 必要时重启 Gateway,清旧进程缓存
七、常用运维命令速查
服务与连通
openclaw gateway start
openclaw gateway status
openclaw gateway probe
openclaw channels status --json --probe
Agent 调试
openclaw agent --agent pm-agent -m "你是谁?只回复名称。"
openclaw agent --agent dev-agent -m "你是谁?只回复名称。"
openclaw agent --agent review-agent -m "你是谁?只回复名称。"
配对与审批
openclaw pairing list feishu --json
openclaw pairing approve feishu <配对码>
openclaw pairing approve --channel feishu --account ops <配对码>
启停
openclaw gateway stop
openclaw gateway restart
八、落地建议
- 先做单机器人闭环,再扩成多机器人
- 每加一个机器人就立刻做'配对 + 路由 + 身份自检'
- 不要把'身份定义'只放在口头约定,必须写入工作区文件
- 把日志检查变成固定动作:
status -> probe -> logs -> bindings - 模型策略按角色拆分,不要盲目全员同模型
九、结语
这次实践最大的收获不是'把机器人接上了',而是把整套方法跑通了:能安装、能排障、能路由、能分工、能稳定运营。当你把'渠道账号、Agent 角色、模型策略、身份文件、日志验证'这 5 件事统一起来,OpenClaw 才真正从'会聊天'进入'可协作生产'的阶段。


