openclaw 自带的官方飞书插件不支持 bot 之间的 mention 操作,我修复了 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
请不要在回答技术问题时复制粘贴 AI 生成的内容
alenryuichi
V2EX    程序员

openclaw 自带的官方飞书插件不支持 bot 之间的 mention 操作,我修复了

  •  
  •   alenryuichi 2 月 28 日 2211 次点击

    开门见山

    地址: https://github.com/Alenryuichi/clawdbot-feishu

    实测可以让 main agent 发送 @去调用其他 agent ,组成 multi-agent 开发团队 pr 已提交到官方插件库,还没过

    为什么不用非 mention 模式?

    因为要控制 bot 之间的主次层级,不能让所有 bot 都响应每条消息,会出现 ping-pong 问题!

    并且飞书的 bot 即使在非 mention 模式下,也会忽略其他机器人发的消息!

    效果如下:

    飞书 multi-agent 效果

    背景

    我希望在飞书群聊中部署一个多 Agent 团队:

     Tech Lead Bot - 负责技术决策和任务分配 iOS Dev Bot - 负责 iOS/Swift 相关问题 Go Dev Bot - 负责后端/Go 相关问题 理想场景:用户提问 → Tech Lead 分析后 @mention 专家 → 专家回复 → 专家之间可以互相讨论 

    我用了很多方法,都行不通,主要是飞书的限制,如下 :

    核心限制:飞书 message_receive_v1 事件

    飞书的 Bot 消息接收事件 (im.message.receive_v1) 有一个关键限制:

    Bot 发送的消息不会触发其他 Bot 的 message_receive_v1 事件

    这意味着:

    用户 @Bot → Bot 收到事件 → Bot 回复

    BotA @BotB → BotB 收不到任何事件

    这是飞书平台层面的设计,无法通过配置或 API 绑过。

    最终成功的方案:Bot-to-Bot Relay (合成事件)

    原理 既然飞书不会推送 Bot 间的消息事件,我们在应用层"模拟"这个过程:

    BotA 回复消息 → 解析消息中的 @mention → 创建"合成事件" → 直接调用 BotB 的消息处理函数

    实现架构

    ┌─────────────────────────────────────────────────────────────────┐ │ OpenClaw Gateway │ ├─────────────────────────────────────────────────────────────────┤ │ │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │ │ Tech Lead │ │ iOS Dev │ │ Go Dev │ │ │ │ Bot │────│ Bot │────│ Bot │ │ │ └─────────────┘ └─────────────┘ └─────────────┘ │ │ │ │ │ │ │ │ │ ┌─────────────────────────────────────────────────────┐ │ │ │ Bot Registry (bot-relay.ts) │ │ │ │ - 注册所有 Bot 的 OpenID │ │ │ │ - 解析 @mention 标签 │ │ │ │ - 创建合成事件并触发目标 Bot │ │ │ └─────────────────────────────────────────────────────┘ │ │ │ │ │ │ │ ┌─────────────────────────────────────────────────────┐ │ │ │ Shared History (shared-history.ts) │ │ │ │ - 跨 Bot 共享聊天记录 │ │ │ │ - 持久化到 JSONL 文件 │ │ │ └─────────────────────────────────────────────────────┘ │ │ │ └─────────────────────────────────────────────────────────────────┘ 

    核心代码模块

    文件 功能 bot-relay.ts Bot 注册、 @mention 解析、合成事件触发 shared-history.ts 跨 Bot 聊天记录共享( JSONL 持久化) reply-dispatcher.ts Bot 回复后触发 relay monitor.ts 启动时注册所有 Bot 

    @mention 格式要求

    为了让 relay 系统能解析 @mention ,Bot 必须使用特定格式:

    <at user_id="ou_xxxx">Go 助手</at> 

    成功实现的功能

    Tech Lead → iOS/Go Bot:Tech Lead 可以 @mention 并触发子 Bot

    共享上下文:所有 Bot 都能看到完整的聊天历史

    动态队友发现:每条消息都会注入可用队友列表

    20 条回复    2026-03-04 20:36:04 +08:00
    KKKKale
        1
    KKKKale  
       2 月 28 日
    感谢 up ,我前几天也在折腾这个,最后是让他们在内部调用沟通,再显式在群里发一条 @消息(给人看)
    alenryuichi
        2
    alenryuichi  
    OP
       2 月 28 日
    @KKKKale openclaw 内部的 subagent_send 对么,我也用了一次那个,不过感觉太冗余,不自然。 然后现在用了这个,会更自然一些
    KKKKale
        3
    KKKKale  
       2 月 28 日
    @alenryuichi 对,那个实现不干净。说起来,亲这个 fork 有 pr 给原 repo 咩?可不可以在配置里面加一个选项或者开关,合给原 repo
    mikaelson
        4
    mikaelson  
       2 月 28 日
    你们的 openclaw 拿来做什么。好奇一下。
    zouzou0208
        5
    zouzou0208  
       2 月 28 日
    alenryuichi
        6
    alenryuichi  
    OP
       2 月 28 日
    @KKKKale 合了 不过原 repo 审核很慢啊。 到时候看看原 repo 作者的评论了
    alenryuichi
        7
    alenryuichi  
    OP
       2 月 28 日
    @zouzou0208 赞,不过我现在用 discord 了。 哈哈 飞书+discord ,各有好多。
    alenryuichi
        8
    alenryuichi  
    OP
       2 月 28 日
    @mikaelson 啥都能干,几乎就是数字人了
    mikaelson
        9
    mikaelson  
       2 月 28 日
    @alenryuichi #8 举点实际使用场景?部署了一个不知道拿来干嘛。。
    liujan
        10
    liujan  
       2 月 28 日 via iPhone
    感觉用飞书发送消息给 openclaw ,反应好慢,经常发一条消息,过了差不多 10 分钟才有回应,很多时候直接就没回应了,直接在网页端就很快,不知道为什么
    robinlovemaggie
        11
    robinlovemaggie  
       2 月 28 日 via Android
    @liujan 你应该是把飞书分就到了墙外线路上了
    alenryuichi
        12
    alenryuichi  
    OP
       9 天前
    @liujan websocket 很快的,应该你选的模型问题?
    iPeta
        13
    iPeta  
       8 天前
    卧槽牛逼,这个思路,之前一直没有想好如何解决这个问题,感谢楼主分享
    MasterMonkey
        14
    MasterMonkey  
       8 天前
    请教下,大家 2 月 7 号的版本能用,我的飞书配置一直有问题?
    shuoshuxx
        15
    shuoshuxx  
       7 天前
    这个思路牛逼,但我用了楼主这个,好像还是不行,具体要怎么操作呢
    alenryuichi
        16
    alenryuichi  
    OP
       6 天前
    @shuoshuxx agent 提示词也要改的。你 bot mention 的原格式是这个么:为了让 relay 系统能解析 @mention ,Bot 必须使用特定格式:

    <at user_id="ou_xxxx">Go 助手</at>
    alenryuichi
        17
    alenryuichi  
    OP
       6 天前
    @shuoshuxx 下载这个库之后,直接让本地的 claude 来部署就好了,我测试没问题的
    alenryuichi
        18
    alenryuichi  
    OP
       6 天前
    @mikaelson 解决日常生活中的重复性问题,关注信息推送,开源项目快速参与,自研项目等
    livary24
        19
    livary24  
       6 天前
    安装之后会影响 openclaw 版本升级吗?
    alenryuichi
        20
    alenryuichi  
    OP
       5 天前
    @livary24 不会,插件而已。 不是 openclaw 主路径,毕竟这是 feishu 插件的改版。 后续升级 feishu 插件会覆盖。 不过你可以让 claude code 辅助升级
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     6065 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 29ms UTC 03:03 PVG 11:03 LAX 20:03 JFK 23:03
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86