Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug] Telegram 私聊流式输出失败:sendMessageDraft Text must be non-empty #7353

Description

@KSAMNI

What happened / 发生了什么

在 Astrbot v4.22.2 中,开启流式输出后,Telegram 私聊会持续触发以下错误:
[Telegram] sendMessageDraft 失败: Text must be non-empty
日志中 _draft_sender_loop 每 0.5 秒尝试发送一次空文本,导致连续 WARN。
网页测试对话的流式输出完全正常,问题仅出现在 Telegram 私聊场景。

Reproduce / 如何复现?

📚 如何复现 / How to reproduce

  1. Astrbot 版本:v4.22.2(已包含 PR feat(telegram): supports sendMessageDraft API #5726
  2. AI 配置 → 其他配置 → 流式输出 开启
  3. Telegram 机器人私聊任意消息
  4. 观察日志,立即出现连续 sendMessageDraft 失败: Text must be non-empty

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

📚 环境信息 / Environment

⦁ Astrbot 版本:v4.22.2
⦁ python-telegram-bot 版本:22.7(已满足 ≥22.6 要求)
⦁ 平台:Telegram(私聊)
⦁ LLM 流式:网页测试正常(排除 LLM 侧问题)
⦁ 部署方式:(请在此补充你的部署方式,例如 Docker / 直接运行 / Windows 等)

📚 预期行为 / Expected behavior

私聊应正常使用 sendMessageDraft 实现打字机效果,不出现空文本错误,流式输出顺畅。

📚 实际行为 / Actual behavior

私聊时 _draft_sender_loop 在 LLM 第一个 token 到达前就发送了空 text,触发 Telegram API 强制校验失败,流式输出整体中断(群聊不受影响,仍正常)。

OS

Windows

Logs / 报错日志

[2026-04-04 17:58:03.457] [Core] [INFO] [respond.stage:200]: 应用流式输出(telegram)
[2026-04-04 17:58:03.457] [Core] [INFO] [telegram.tg_event:513]: [Telegram] 流式输出: 使用 sendMessageDraft (私聊)
[2026-04-04 17:58:04.251] [Core] [WARN] [v4.22.2] [telegram.tg_event:409]: [Telegram] sendMessageDraft 失败: Text must be non-empty
...(后续每 0.5 秒重复出现多次)
📚 补充说明

⦁ 该问题出现在 PR #5726(2026-03-03 引入 sendMessageDraft)之后。
⦁ Telegram Bot API 本身无额外版本要求,python-telegram-bot 已更新到最新。
⦁ 临时关闭“流式输出”开关可立即规避,但希望官方能加强 _draft_sender_loop 对初始空缓冲区的判断逻辑。

Image

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • Yes!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:platformThe bug / feature is about IM platform adapter, such as QQ, Lark, Telegram, WebChat and so on.bugSomething isn't working

    Type

    No type

    Fields

    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