#5956·nanobot

Feishu 无 in-place edit 能力,compaction notice 应可关闭(同类 #5784)

Author: shenchaovip-afkCreated Sep 28, 2026Updated Sep 28, 2026
Labelsbug

Bug Description

问题描述

nanobot/bus/notification_delivery.py 的 NOTIFICATION_AUDIENCES 把 ContextCompactionEvent 硬映射到 "channel",导致 phase='started' 和 phase='succeeded' 两个事件都被发到源频道:

19:44:18 [小狮子] Compressing context… ← phase='started' 19:44:23 [小狮子] Context compacted. ← phase='succeeded'

Telegram / Discord / WebSocket 上这是有意设计:客户端有 in-place edit 能力,先显示 "压缩中"、再原地编辑为 "已压缩",用户只看得到一条滚动消息(见 #5719、#5870 讨论)。

Feishu 上这变成了 bug:飞书 bot API 没有编辑已发消息的能力(见 #5784 QQ 同类讨论),两条消息永久留在群里,每次 session 静默 15 分钟触发一次。CLI 用户也不订阅 channel audience。

期望修法(走 #5784 的 capability 路线)

不要改 notification_delivery.py 的全局映射(会破坏 Telegram / Discord 的 in-place edit 体验)。

建议: BaseChannel 加 capability: show_compaction_notices: bool = True # 默认开,保留 Telegram/Discord 行为

FeishuChannel(及 QQ 等无 edit 能力的通道)覆盖为 False。 outbound_events.py 生成 ContextCompactionEvent 前检查该 capability,为 False 时不发。 Telegram/Discord/WebSocket 保留现有行为,Feishu/QQ 静默丢弃。与 #5784 AlfredChaos 已提的 capability PR 方向一致,可搭车合并。

相关日志

19:44:04 | INFO | - | Idle-session compact for feishu:oc_xxx:om_xxx: archived=2, visible=1, retained=3, summary=True 19:44:08 → ContextCompactionEvent(phase='started') 19:44:18 → feishu 群消息 "Compressing context…" 19:44:23 → feishu 群消息 "Context compacted."

版本

nanobot-ai 0.3.5 Python 3.11 / Windows 10 通道: feishu(WebSocket 长连接) 触发源: idle auto-compact(session_ttl_minutes: 15),heartbeat 也会触发(见 #5870)

参考 issue

#5784(closed):QQ 同类问题,AlfredChaos 将提 show_compaction_notices capability PR #5719(closed):Discord + sendProgress=false 应隐藏 notice #5870(closed):Telegram heartbeat 重复发 compaction notice #5903(open):Feishu 另一个 compaction 相关 bug(隐藏 marker 泄露)

影响文件

nanobot/bus/notification_delivery.py(NOTIFICATION_AUDIENCES dict) nanobot/agent/turn_delivery.py(_default_route publish_lifecycle=True) nanobot/channels/feishu/runtime.py(建议覆盖 show_compaction_notices=False) nanobot/channels/base.py(建议加 show_compaction_notices 字段)

Steps to Reproduce

  1. 部署一个 feishu 群 bot(session_ttl_minutes: 15,默认值)
  2. 群里安静 15 分钟以上
  3. 下一次 session 触发时(heartbeat 或新消息进入)
  4. 群里出现两条消息:Compressing context… / Context compacted.
  5. 每 15 分钟静默一次就重复一次

Expected Behavior

Feishu 群不应收到任何 compaction notice 消息。compaction 应在后台静默完成,或仅通过管理通道通知,不向普通群成员广播。

Relevant Logs

bash
19:44:04 | INFO | - | Idle-session compact for feishu:oc_xxx:om_xxx: archived=2, visible=1, retained=3, summary=True
19:44:08  → ContextCompactionEvent(phase='started')
19:44:18  → feishu 群消息 "Compressing context…"
19:44:23  → feishu 群消息 "Context compacted."

nanobot Version

0.3.5

Python Version

3.11

Operating System

Windows

Channel / Platform

Feishu (Lark)

LLM Provider

OpenAI

Configuration (Optional)

yaml

Additional Context

No response