Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions python/samples/03-workflows/orchestrations/concurrent_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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):
Comment thread
moonbox3 marked this conversation as resolved.
continue
for i, msg in enumerate(output.messages, start=1):
Comment thread
benke520 marked this conversation as resolved.
name = msg.author_name if msg.author_name else "user"
print(f"{'-' * 60}\n\n{i:02d} [{name}]:\n{msg.text}")

Expand All @@ -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;
Expand All @@ -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."
Expand All @@ -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**
Expand Down
Loading