[Bug] SSE 事件类型与后端 runtime 对齐检查 #4

Closed
opened 2026-05-04 22:45:11 +08:00 by admin · 0 comments
Owner

问题描述

前端 AgentChat.vue 监听以下 SSE 事件类型:think, tool_call, tool_result, final, error。

后端 agent_chat.py 的 _sse_stream() 函数通过 event.get("type", "message") 动态确定事件类型,取决于 AgentRuntime.run_stream() yield 的 dict 中的 type 字段。

需要确认 agent_runtime/core.py 中 run_stream() 实际 yield 的事件类型是否与前端完全匹配。如果前后端事件类型不一致,对应的事件会被前端静默忽略 (catch 块只跳过不做处理),导致:

  • 思考链不完整
  • 工具调用步骤缺失
  • 流式更新卡住

涉及文件

  • 前端: frontend/src/views/AgentChat.vue:467-501
  • 后端: backend/app/api/agent_chat.py:71-76
  • 后端: backend/app/agent_runtime/core.py

建议

  1. 检查 agent_runtime/core.py 中 run_stream() 产生的实际事件类型
  2. 统一前后端的事件类型枚举或常量
  3. 对未知事件类型至少打印 console.warn 便于排查

严重程度

中 - 可能导致流式功能部分失效

## 问题描述 前端 AgentChat.vue 监听以下 SSE 事件类型:think, tool_call, tool_result, final, error。 后端 agent_chat.py 的 _sse_stream() 函数通过 event.get("type", "message") 动态确定事件类型,取决于 AgentRuntime.run_stream() yield 的 dict 中的 type 字段。 需要确认 agent_runtime/core.py 中 run_stream() 实际 yield 的事件类型是否与前端完全匹配。如果前后端事件类型不一致,对应的事件会被前端静默忽略 (catch 块只跳过不做处理),导致: - 思考链不完整 - 工具调用步骤缺失 - 流式更新卡住 ## 涉及文件 - 前端: frontend/src/views/AgentChat.vue:467-501 - 后端: backend/app/api/agent_chat.py:71-76 - 后端: backend/app/agent_runtime/core.py ## 建议 1. 检查 agent_runtime/core.py 中 run_stream() 产生的实际事件类型 2. 统一前后端的事件类型枚举或常量 3. 对未知事件类型至少打印 console.warn 便于排查 ## 严重程度 中 - 可能导致流式功能部分失效
admin self-assigned this 2026-05-04 22:45:11 +08:00
admin closed this issue 2026-05-04 23:56:50 +08:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: admin/aiagent#4