Skip to content

[BUG] QQ WebSocket 周期性断开时 reply 工具连续重试浪费 LLM 调用 #1702

@CGl123

Description

@CGl123

检查项

  • 我确认此问题在所有分支的最新版本中依旧存在
  • 我确认在 Issues 列表中并无其他人已经提出过与此问题相同或相似的问题
  • 我使用了 Docker

使用的分支

dev

具体版本号

1.0.0-pre.19

遇到的问题

QQ WebSocket(maim_message ↔ NapCat ws://localhost:8000/ws)存在约 2.5 小时的周期性断开-重连。在断开窗口(~45-52s)内,Maisaka planner 调用 reply 工具时,底层 get_global_api().send_message() 返回 false → DeliveryReceipt(status=FAILED, error="旧链发送失败")

问题:planner 将 success: false 视为普通失败,自动重试 4 次。每次重试都:

  1. 调用 planner 模型重新决策
  2. 调用 replyer 模型重新生成回复
  3. 发送仍然失败

→ 窗口期内白白消耗 4 轮 LLM 调用,且生成的回复全部作废。

报错信息

Bot 侧 (app_*.log.jsonl):

15:37:00 | maim_message | 平台 qq WebSocket 已断开
15:37:00 | sender | [API Server Fallback] API Server未开启,跳过fallback
15:37:00 | send_service | Platform IO 发送失败: ... error=旧链发送失败
15:37:00 | maisaka_reasoning_engine | 回复工具未生成可见消息,将继续下一轮循环
15:37:16 | maim_message | 未找到目标平台: qq          ← 第2次重试失败
15:37:16 | send_service | 发送失败
15:37:27 | ...                                        ← 第3次重试失败
15:37:39 | ...                                        ← 第4次重试失败
15:37:52 | maim_message | 平台 qq WebSocket 已连接    ← 重连成功
15:38:03 | send_service | 成功发送消息                ← 后续正常

适配器侧 (Napcat-Adapter screen):

15:37:52 | ws_connection:479 | 正在连接到 ws://localhost:8000/ws
15:37:52 | ws_connection:484 | 已成功连接到 ws://localhost:8000/ws
15:37:52 | ws_connection:649 | 连接被重置,标记为断开  (ConnectionResetError)
15:37:52 | message_sending:28 | 发送消息失败: ...
15:37:52 | message_sending:29 | 请检查与MaiBot之间的连接

WS 断开规律(历史数据):

断开时间 重连时间 间隔
12:50:39 12:51:31 52s
13:06:02 13:06:47 45s
15:37:00 15:37:52 52s
16:22:03 16:22:47 44s

如何重现此问题

  1. 启动 bot + 适配器 + NapCat 正常运行
  2. 等待约 2.5 小时(NapCat WS 自然断开周期)
  3. 在 WS 断开窗口内向 bot 发消息触发回复
  4. 观察 reply 工具连续失败、planner 反复重试

可能造成问题的原因

uni_message_sender.py:_send_message() 在 WS 断开时返回 FalseLegacyPlatformDriver 包装为 DeliveryReceipt(status=FAILED) 返回给 Maisaka tool handler → planner 循环将 success: false 解释为"工具执行失败,应重试",而非"消息通道暂时不可用,不应重试"。

缺少对"通道不可用" vs "内容错误"的区分。

系统环境

Linux (Ubuntu 24.04), 本地运行

Python 版本

Python 3.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions