已关闭
[Bug]: VA上游故障后,SSE 流缺少final_answer/conversation_end,不够优雅 #117
huangyaoHY创建于  7月23日关闭于  7月28日
huangyaoHY成员
7月23日 创建

Checklist

🐞 Detailed Description of the Problem

3.5 SUT 代码缺陷:VA 上游报错后 SSE 流缺少 final_answer/conversation_end
影响用例:TC-057(隔离执行环境-查询尾号6605的卡余额)FAILED

现象:用户请求"查询尾号6605的卡余额",LLM 推理后委托 VA 查询,VA 返回 TASK_STATE_FAILED("执行报错(无详细信息)")。a2a_service 收到 FAILED 后只推送了 interrupt_start 事件就关闭了 SSE 流,没有生成 final_answer 或 conversation_end 事件,导致测试断言失败。其他用例(如 TC-054/055)同样遇到 VA 报错,但 VA 返回的是 COMPLETED(workflow_result 为空),Agent 能用 cascade 结果生成兜底 final_answer,因此通过。

根因(完整调用链追踪):

层级 代码位置 行为
VA 调用返回 [remote_agent_handler.py:1510-1512](file:///d:/EDPAgent/agent-runtime/applications/a2a_service/orchestrator/handlers/remote_agent_handler.py#L1510-L1512) upstream_error is not None → 调用 _finalize_failed() → 返回 (None, "", True) — finalized=True
_finalize_failed [remote_agent_handler.py:1208-1233](file:///d:/EDPAgent/agent-runtime/applications/a2a_service/orchestrator/handlers/remote_agent_handler.py#L1208-L1233) 标记 task FAILED + 清空 va_task_id + 入队 TaskStatusUpdateEvent(FAILED)
_handle_delegate [remote_agent_handler.py:325-326](file:///d:/EDPAgent/agent-runtime/applications/a2a_service/orchestrator/handlers/remote_agent_handler.py#L325-L326) elif finalized: pass — 不调用 Agent 生成兜底回复,直接返回
handle() [remote_agent_handler.py:216](file:///d:/EDPAgent/agent-runtime/applications/a2a_service/orchestrator/handlers/remote_agent_handler.py#L216) 设置 context["_stream_interrupted"] = True
Executor.run_agent [executor.py:449-456](file:///d:/EDPAgent/agent-runtime/applications/a2a_service/orchestrator/executor.py#L449-L456) 检测到 _stream_interrupted,直接 return,跳过 finalize_completed + _build_completed_status_event
dispatch.py SSE 流 [dispatch.py:394-407](file:///d:/EDPAgent/agent-runtime/applications/a2a_service/api/dispatch.py#L394-L407) TaskStatusUpdateEvent(FAILED) 被映射为 interrupt_start SSE 帧推送,之后队列关闭 → 流结束。无 final_answer_start/final_answer_end/conversation_end
核心问题:_handle_delegate 的 finalized 分支只执行 pass,不触发 Agent 生成降级回复。与 has_end_node 分支(调用 executor.run_agent(cascade_result=...) 让 Agent 生成 final_answer)形成对比。

对比正常路径(TC-054 等):VA 返回 COMPLETED → 走 has_end_node 分支 → 调用 executor.run_agent(cascade_result={...}) → Agent 用 cascade 结果生成 final_answer → 正常结束 → SSE 流完整。

Detailed Environment Information Description

VA环境:MOCK(偶发上游服务不可用的故障时触发)
定位人:熊星

Additional Information

Version Information

Thanks for your contribution 🎉!

likedislike
openJiuwen-bot成员
7月23日 评论:

欢迎来到 openJiuwen 社区

Hey @huangyaoHY , 感谢你对社区的贡献.

机器人使用手册

有关指令的使用,可以点击 此处 查看详情。开发人员可以在每个PR或Issue下方评论特定指令来触发机器人任务。

likedislike
Xxiongxing成员
7月23日 关联了pull request:feat: VA上游报错后调Agent生成降级回复,确保SSE流包含final_answer
HhuangyaoHY成员
7月28日 issue状态由 TODO 改变为 CLOSED
HhuangyaoHY成员
7月28日 关闭了 issue