tan-en-yao commited on
Commit
55890db
Β·
1 Parent(s): 9485d99

feat: add multi-agent hierarchy display

Browse files
Files changed (2) hide show
  1. agents/orchestrator.py +16 -1
  2. app.py +26 -12
agents/orchestrator.py CHANGED
@@ -633,9 +633,24 @@ Return JSON:
633
  )
634
 
635
  def _create_step_callback(self, agent_key: str):
636
- """Create a step callback for tracking agent execution."""
 
 
637
  def step_callback(step: ActionStep, agent) -> None:
638
  """Callback triggered at each agent step."""
 
 
 
 
 
 
 
 
 
 
 
 
 
639
  step_data = {
640
  "agent": agent_key,
641
  "step_number": getattr(step, 'step_number', 0),
 
633
  )
634
 
635
  def _create_step_callback(self, agent_key: str):
636
+ """Create a step callback for tracking agent execution (multi-agent style)."""
637
+ agent_started = {"value": False}
638
+
639
  def step_callback(step: ActionStep, agent) -> None:
640
  """Callback triggered at each agent step."""
641
+ # Emit agent_start on first step (shows agent as parent of its tools)
642
+ if not agent_started["value"]:
643
+ agent_started["value"] = True
644
+ config = self.AGENT_CONFIG.get(agent_key, {})
645
+ self._event_queue.put(("agent_start", {
646
+ "agent": agent_key,
647
+ "name": config.get("name", agent_key),
648
+ "icon": config.get("icon", "πŸ€–"),
649
+ "description": config.get("description", ""),
650
+ "start_time": time.time(),
651
+ }))
652
+ print(f"Starting {config.get('name', agent_key)}...")
653
+
654
  step_data = {
655
  "agent": agent_key,
656
  "step_number": getattr(step, 'step_number', 0),
app.py CHANGED
@@ -188,38 +188,52 @@ def _extract_tool_input_preview(tool_name: str, input_str: str) -> str:
188
  def build_inline_progress(agent_states: dict, elapsed: float, current_activity: str = "",
189
  thinking: str = "", tool_history: list = None) -> str:
190
  """
191
- Build Claude Code-style progress display.
192
 
193
  Visual pattern:
194
- ● Tool call (action)
195
- ⎿ Result (indented)
196
- ∴ Thinking... (analysis)
 
 
197
  """
198
  lines = []
199
 
200
  # Planning header (shown at start)
201
  if elapsed < 3 and not tool_history:
202
- lines.append("πŸ€– **Planning:** Research β†’ Report\n")
203
 
204
- # Tool calls with results (Claude Code style)
205
  if tool_history:
 
 
 
 
206
  for tool in tool_history:
 
207
  name = tool.get("display_name", tool.get("tool", "Unknown"))
208
  status = tool.get("status", "running")
209
  result = tool.get("result_summary", "")
210
  input_preview = tool.get("input_preview", "")
211
 
212
- # Tool call line
 
 
 
 
 
 
 
213
  if input_preview:
214
- lines.append(f"● {name}({input_preview})")
215
  else:
216
- lines.append(f"● {name}...")
217
 
218
- # Result line (indented)
219
  if status == "done" and result:
220
- lines.append(f" ⎿ {result}")
221
  elif status == "done":
222
- lines.append(f" ⎿ Done")
223
 
224
  # Thinking/analysis section
225
  if thinking:
 
188
  def build_inline_progress(agent_states: dict, elapsed: float, current_activity: str = "",
189
  thinking: str = "", tool_history: list = None) -> str:
190
  """
191
+ Build multi-agent style progress display.
192
 
193
  Visual pattern:
194
+ ● Agent Name
195
+ β”œβ”€β”€ Tool call...
196
+ β”‚ ⎿ Result
197
+ β”œβ”€β”€ Tool call...
198
+ β”‚ ⎿ Result
199
  """
200
  lines = []
201
 
202
  # Planning header (shown at start)
203
  if elapsed < 3 and not tool_history:
204
+ lines.append("πŸ€– **Controller planning...**\n")
205
 
206
+ # Group tools by agent (multi-agent style)
207
  if tool_history:
208
+ current_agent = None
209
+ agent_icons = {"triage": "🎯", "research": "πŸ”", "report": "πŸ“‹"}
210
+ agent_names = {"triage": "Triage Agent", "research": "Research Agent", "report": "Report Agent"}
211
+
212
  for tool in tool_history:
213
+ agent = tool.get("agent")
214
  name = tool.get("display_name", tool.get("tool", "Unknown"))
215
  status = tool.get("status", "running")
216
  result = tool.get("result_summary", "")
217
  input_preview = tool.get("input_preview", "")
218
 
219
+ # Show agent header when agent changes
220
+ if agent and agent != current_agent:
221
+ current_agent = agent
222
+ icon = agent_icons.get(agent, "πŸ€–")
223
+ agent_name = agent_names.get(agent, agent.title())
224
+ lines.append(f"● {icon} **{agent_name}**")
225
+
226
+ # Tool call line (indented under agent)
227
  if input_preview:
228
+ lines.append(f" β”œβ”€β”€ {name}({input_preview})")
229
  else:
230
+ lines.append(f" β”œβ”€β”€ {name}...")
231
 
232
+ # Result line (further indented)
233
  if status == "done" and result:
234
+ lines.append(f" β”‚ ⎿ {result}")
235
  elif status == "done":
236
+ lines.append(f" β”‚ ⎿ Done")
237
 
238
  # Thinking/analysis section
239
  if thinking: