Commit Β·
b7d7f2a
1
Parent(s): 98bb628
feat: persist agent execution hierarchy after completion
Browse files
app.py
CHANGED
|
@@ -249,6 +249,44 @@ def build_inline_progress(agent_states: dict, elapsed: float, current_activity:
|
|
| 249 |
return "\n".join(lines)
|
| 250 |
|
| 251 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
def process_report(message: str, image, history: list, session_logs: list, session_orchestrator, reasoning_state: str):
|
| 253 |
"""
|
| 254 |
Process infrastructure report through multi-agent system with real-time UI updates.
|
|
@@ -631,15 +669,22 @@ def process_report(message: str, image, history: list, session_logs: list, sessi
|
|
| 631 |
yield build_outputs()
|
| 632 |
|
| 633 |
elif event_type == "complete":
|
| 634 |
-
#
|
| 635 |
total_duration = data.get("total_duration_formatted", "")
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 639 |
|
| 640 |
history[progress_msg_idx] = {
|
| 641 |
"role": "assistant",
|
| 642 |
-
"content":
|
| 643 |
}
|
| 644 |
|
| 645 |
# Update reasoning trace with final self-evaluation results
|
|
|
|
| 249 |
return "\n".join(lines)
|
| 250 |
|
| 251 |
|
| 252 |
+
def build_agent_summary(tool_history: list, total_duration: str = "") -> str:
|
| 253 |
+
"""
|
| 254 |
+
Build a compact summary of agent execution for final display.
|
| 255 |
+
|
| 256 |
+
Shows the agent hierarchy with completed tools (no timing indicator).
|
| 257 |
+
"""
|
| 258 |
+
if not tool_history:
|
| 259 |
+
return ""
|
| 260 |
+
|
| 261 |
+
lines = ["**π€ Agent Execution**"]
|
| 262 |
+
current_agent = None
|
| 263 |
+
agent_icons = {"triage": "π―", "research": "π", "report": "π"}
|
| 264 |
+
agent_names = {"triage": "Triage Agent", "research": "Research Agent", "report": "Report Agent"}
|
| 265 |
+
|
| 266 |
+
for tool in tool_history:
|
| 267 |
+
agent = tool.get("agent")
|
| 268 |
+
name = tool.get("display_name", tool.get("tool", "Unknown"))
|
| 269 |
+
result = tool.get("result_summary", "")
|
| 270 |
+
|
| 271 |
+
# Show agent header when agent changes
|
| 272 |
+
if agent and agent != current_agent:
|
| 273 |
+
current_agent = agent
|
| 274 |
+
icon = agent_icons.get(agent, "π€")
|
| 275 |
+
agent_name = agent_names.get(agent, agent.title())
|
| 276 |
+
lines.append(f"β {icon} **{agent_name}**")
|
| 277 |
+
|
| 278 |
+
# Tool with result (compact)
|
| 279 |
+
if result:
|
| 280 |
+
lines.append(f" ββ {name} β {result}")
|
| 281 |
+
else:
|
| 282 |
+
lines.append(f" ββ {name} β")
|
| 283 |
+
|
| 284 |
+
if total_duration:
|
| 285 |
+
lines.append(f"\n*Completed in {total_duration}*")
|
| 286 |
+
|
| 287 |
+
return "\n".join(lines)
|
| 288 |
+
|
| 289 |
+
|
| 290 |
def process_report(message: str, image, history: list, session_logs: list, session_orchestrator, reasoning_state: str):
|
| 291 |
"""
|
| 292 |
Process infrastructure report through multi-agent system with real-time UI updates.
|
|
|
|
| 669 |
yield build_outputs()
|
| 670 |
|
| 671 |
elif event_type == "complete":
|
| 672 |
+
# Build final response with agent execution summary above
|
| 673 |
total_duration = data.get("total_duration_formatted", "")
|
| 674 |
+
|
| 675 |
+
# Build agent summary from tool_history
|
| 676 |
+
agent_summary = build_agent_summary(tool_history, total_duration)
|
| 677 |
+
|
| 678 |
+
# Combine: agent summary + separator + final report
|
| 679 |
+
final_content = data["message"]
|
| 680 |
+
if agent_summary:
|
| 681 |
+
final_content = f"{agent_summary}\n\n---\n\n{data['message']}"
|
| 682 |
+
elif total_duration:
|
| 683 |
+
final_content += f"\n\n---\n*Processed in {total_duration}*"
|
| 684 |
|
| 685 |
history[progress_msg_idx] = {
|
| 686 |
"role": "assistant",
|
| 687 |
+
"content": final_content
|
| 688 |
}
|
| 689 |
|
| 690 |
# Update reasoning trace with final self-evaluation results
|