@@ -50,7 +50,7 @@ def __init__(self):
5050 def _extract_response_text (self , data ) -> str :
5151 """
5252 Extract text content from various agent_framework response types.
53-
53+
5454 Handles:
5555 - ChatMessage: Extract .text
5656 - AgentResponse: Extract .text
@@ -59,15 +59,15 @@ def _extract_response_text(self, data) -> str:
5959 """
6060 if data is None :
6161 return ""
62-
62+
6363 # Direct ChatMessage
6464 if isinstance (data , ChatMessage ):
6565 return data .text or ""
66-
66+
6767 # Has .text attribute directly (AgentResponse, etc.)
6868 if hasattr (data , "text" ) and data .text :
6969 return data .text
70-
70+
7171 # AgentExecutorResponse - has agent_response and full_conversation
7272 if hasattr (data , "agent_response" ):
7373 # Try to get text from agent_response first
@@ -79,7 +79,7 @@ def _extract_response_text(self, data) -> str:
7979 last_msg = data .full_conversation [- 1 ]
8080 if isinstance (last_msg , ChatMessage ) and last_msg .text :
8181 return last_msg .text
82-
82+
8383 # List of items - could be AgentExecutorResponse, ChatMessage, etc.
8484 if isinstance (data , list ) and len (data ) > 0 :
8585 texts = []
@@ -91,7 +91,7 @@ def _extract_response_text(self, data) -> str:
9191 if texts :
9292 # Return the last non-empty response (most recent)
9393 return texts [- 1 ]
94-
94+
9595 return ""
9696
9797 # ---------------------------
@@ -195,12 +195,12 @@ async def init_orchestration(
195195
196196 # Assemble workflow with callback
197197 storage = InMemoryCheckpointStorage ()
198-
198+
199199 # New SDK: participants() accepts a Sequence (list) of agents
200200 # The orchestrator uses agent.name to identify them
201201 participant_list = list (participants .values ())
202202 cls .logger .info ("Participants for workflow: %s" , list (participants .keys ()))
203-
203+
204204 builder = (
205205 MagenticBuilder ()
206206 .participants (participant_list ) # New SDK: pass as list
@@ -241,7 +241,7 @@ async def get_current_or_new_orchestration(
241241 """
242242 current = orchestration_config .get_current_orchestration (user_id )
243243 needs_rebuild = current is None or team_switched or force_rebuild
244-
244+
245245 if needs_rebuild :
246246 if current is not None and (team_switched or force_rebuild ):
247247 reason = "team switched" if team_switched else "force rebuild for new task"
@@ -387,7 +387,7 @@ async def run_orchestration(self, user_id: str, input_task) -> None:
387387 event_type_name = type (event ).__name__
388388 if event_type_name != "AgentRunUpdateEvent" :
389389 self .logger .info ("[EVENT] %s" , event_type_name )
390-
390+
391391 # Handle orchestrator events (plan, progress ledger)
392392 if isinstance (event , MagenticOrchestratorEvent ):
393393 self .logger .info (
@@ -403,7 +403,7 @@ async def run_orchestration(self, user_id: str, input_task) -> None:
403403 elif isinstance (event , AgentRunUpdateEvent ):
404404 message_id = event .data .message_id if hasattr (event .data , 'message_id' ) else None
405405 executor_id = event .executor_id
406-
406+
407407 # Stream the update
408408 try :
409409 await streaming_agent_response_callback (
@@ -417,7 +417,7 @@ async def run_orchestration(self, user_id: str, input_task) -> None:
417417 "Error in streaming callback for agent %s: %s" ,
418418 executor_id , e
419419 )
420-
420+
421421 # Track message for formatting
422422 if message_id != last_message_id :
423423 last_message_id = message_id
@@ -427,14 +427,14 @@ async def run_orchestration(self, user_id: str, input_task) -> None:
427427 agent_name = event .participant_name
428428 agent_call_counts [agent_name ] = agent_call_counts .get (agent_name , 0 ) + 1
429429 call_num = agent_call_counts [agent_name ]
430-
430+
431431 self .logger .info (
432432 "[REQUEST SENT (round %d)] to agent: %s (call #%d)" ,
433433 event .round_index ,
434434 agent_name ,
435435 call_num
436436 )
437-
437+
438438 if call_num > 1 :
439439 self .logger .warning ("Agent '%s' called %d times" , agent_name , call_num )
440440
@@ -448,7 +448,7 @@ async def run_orchestration(self, user_id: str, input_task) -> None:
448448 # Send the agent response to the UI
449449 if event .data :
450450 response_text = self ._extract_response_text (event .data )
451-
451+
452452 if response_text :
453453 self .logger .info ("Sending agent response to UI from %s" , event .participant_name )
454454 agent_response_callback (
0 commit comments