Web UI / Console keeps showing “Stop responding” when Annotation Reply ends without workflow events

用户在 Dify 的自托管(Self Hosted)环境中,使用 Web UI 聊天、共享应用页面或 Console 调试/预览功能时触发。具体操作流程为:

Web UI / Console keeps showing "Stop responding" when Annotation Reply ends without workflow events

Web UI / Console keeps showing “Stop responding” when Annotation Reply ends without workflow events

快速结论:该报错发生在 Dify 的 Annotation Reply 快速匹配场景中。当后端回复命中用户自定义的标注(Annotation)时,前端 UI 在收到完整的 message_end SSE 事件后仍然显示“Stop responding”按钮,无法退出“生成中”状态。优先排查后端是否在 message_end 的 metadata 中移除了 annotation_reply 字段。

问题场景

用户在 Dify 的自托管(Self Hosted)环境中,使用 Web UI 聊天、共享应用页面或 Console 调试/预览功能时触发。具体操作流程为:

  • 创建一个带有 Annotation Reply 路径的 App 或 Chatflow。
  • 输入一条能够命中预设标注的文本。
  • 等待回答完全渲染后,UI 仍显示“Stop responding”按钮。

报错原文

Observed problematic SSE sequence:
ping -> message -> message_end

After `message_end`, if no workflow was started for this response, the UI should exit the responding state immediately. The answer is complete and `message_end` has already arrived, but the UI still shows **"Stop responding"**.

原因分析

根本原因:后端在两个位置将 annotation_replymessage_end 的 metadata 中剥离,导致前端无法检测到标注命中响应:

  1. api/core/app/apps/base_app_generate_response_converter.py 中执行 del metadata["annotation_reply"]
  2. api/core/app/apps/advanced_chat/generate_task_pipeline.py 中执行 del extras["annotation_reply"]

前端代码(web/app/components/base/chat/chat/hooks.ts,约第 885-900 行)依赖 messageEnd.metadata?.annotation_reply 来检测是否命中标注,并通过 handleResponding(false) 结束“生成中”状态。当此 metadata 被移除后,前端无法关闭响应状态。

环境排查

  • Dify 版本:main 分支(2026/6/12 及附近版本,因 Issue 提交于该日期)
  • 部署方式:Self Hosted(Source)
  • 检查后端日志中 message_end SSE 事件的 metadata 是否包含 annotation_reply 字段
  • 确认前端 Web 控制台(Console)中 messageEnd 事件的 metadata 对象结构

解决步骤

  1. 应用后端修复(可优先尝试,PR #37001):合并 PR #37001,确保后端在生成 message_end 时不再删除 annotation_reply metadata。具体修改涉及 base_app_generate_response_converter.pygenerate_task_pipeline.py 中移除 del metadata["annotation_reply"]del extras["annotation_reply"] 两行代码。
  2. 应用前端修复(PR #34948):合并 PR #34948,确保前端在无 workflow 事件时也能正确释放响应锁(responding lock)。
  3. 注意:两个 PR 均为“未合并”(open, not merged)状态,需要同时应用才能完全修复此问题。若仅应用一个,可能仍然存在异常。
  4. 临时规避方案:如果暂时无法合并 PR,可以考虑修改 Annotation Reply 的触发逻辑,避免在无 workflow 的场景下使用标注回复,转而使用其他流程。

验证方法

在应用修复后,重复问题场景中的步骤:创建一个带 Annotation Reply 的 App,输入一条命中标注的文本,观察回答完全渲染后 UI 是否立即退出“Stop responding”状态,且 Console 中无残留的响应锁定。如有条件,可在浏览器开发工具中检查 SSE 事件流,确认 message_end 的 metadata 中包含 annotation_reply 字段。

参考来源

langgenius/dify #37362

相关 Issue:#37000#36245

GamsGo AI

AI 工具推荐

想把多个 AI 模型放在一个入口?

GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。

了解 GamsGo AI

推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。

celebrityanime
celebrityanime
文章: 12663

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注