diff --git a/python/samples/03-workflows/orchestrations/concurrent_agents.py b/python/samples/03-workflows/orchestrations/concurrent_agents.py index 30aea5936f..0b40a463c9 100644 --- a/python/samples/03-workflows/orchestrations/concurrent_agents.py +++ b/python/samples/03-workflows/orchestrations/concurrent_agents.py @@ -2,9 +2,8 @@ import asyncio import os -from typing import Any -from agent_framework import Agent, Message +from agent_framework import Agent, AgentResponse from agent_framework.foundry import FoundryChatClient from agent_framework.orchestrations import ConcurrentBuilder from azure.identity import AzureCliCredential @@ -18,8 +17,8 @@ Build a high-level concurrent workflow using ConcurrentBuilder and three domain agents. The default dispatcher fans out the same user prompt to all agents in parallel. -The default aggregator fans in their results and yields output containing -a list[Message] representing the concatenated conversations from all agents. +The default aggregator fans in their results and yields AgentResponse objects +containing only the participants' assistant messages. Demonstrates: - Minimal wiring with ConcurrentBuilder(participants=[...]).build() @@ -80,8 +79,9 @@ async def main() -> None: if outputs: print("===== Final Aggregated Conversation (messages) =====") for output in outputs: - messages: list[Message] | Any = output - for i, msg in enumerate(messages, start=1): + if not isinstance(output, AgentResponse): + continue + for i, msg in enumerate(output.messages, start=1): name = msg.author_name if msg.author_name else "user" print(f"{'-' * 60}\n\n{i:02d} [{name}]:\n{msg.text}") @@ -91,11 +91,7 @@ async def main() -> None: ===== Final Aggregated Conversation (messages) ===== ------------------------------------------------------------ - 01 [user]: - We are launching a new budget-friendly electric bike for urban commuters. - ------------------------------------------------------------ - - 02 [researcher]: + 01 [researcher]: **Insights:** - **Target Demographic:** Urban commuters seeking affordable, eco-friendly transport; @@ -115,7 +111,7 @@ async def main() -> None: ... ------------------------------------------------------------ - 03 [marketer]: + 02 [marketer]: **Value Proposition:** "Empowering your city commute: Our new electric bike combines affordability, reliability, and sustainable design—helping you conquer urban journeys without breaking the bank." @@ -126,7 +122,7 @@ async def main() -> None: ... ------------------------------------------------------------ - 04 [legal]: + 03 [legal]: **Constraints, Disclaimers, & Policy Concerns for Launching a Budget-Friendly Electric Bike for Urban Commuters:** **1. Regulatory Compliance**