diff --git a/modules/sub_agent_manager.py b/modules/sub_agent_manager.py index 3a785c3..3c8a431 100644 --- a/modules/sub_agent_manager.py +++ b/modules/sub_agent_manager.py @@ -566,11 +566,9 @@ class SubAgentManager: """返回子智能体任务概览,用于前端展示。""" overview: List[Dict[str, Any]] = [] for task_id, task in self.tasks.items(): - status = task.get("status") - if status not in {"pending", "running"}: - continue if conversation_id and task.get("conversation_id") != conversation_id: continue + snapshot = { "task_id": task_id, "agent_id": task.get("agent_id"), @@ -585,7 +583,8 @@ class SubAgentManager: "conversation_id": task.get("conversation_id"), "sub_conversation_id": task.get("sub_conversation_id"), } - # 对于运行中的任务,尝试获取最新状态 + + # 运行中的任务尝试同步远端最新状态 if snapshot["status"] not in TERMINAL_STATUSES: remote = self._call_service("GET", f"/tasks/{task_id}", timeout=5) if remote.get("success"): @@ -593,5 +592,13 @@ class SubAgentManager: snapshot["remote_message"] = remote.get("message") snapshot["last_tool"] = remote.get("last_tool") task["last_tool"] = snapshot["last_tool"] + else: + # 已结束的任务带上最终结果/系统消息,方便前端展示 + final_result = task.get("final_result") or {} + snapshot["final_message"] = final_result.get("system_message") or final_result.get("message") + snapshot["success"] = final_result.get("success") + overview.append(snapshot) + + overview.sort(key=lambda item: item.get("created_at") or 0, reverse=True) return overview