This demo showcases the Concurrent Agents pattern using the Azure AI Agent Framework. Concurrent workflows execute multiple agents in parallel (fan-out) and aggregate their results (fan-in), enabling parallel processing for improved efficiency.
- Fan-Out Execution: Same prompt dispatched to multiple agents simultaneously
- Fan-In Aggregation: Results from all agents combined into final output
- Parallel Processing: Multiple domain experts work concurrently
- Custom Executors: Extend with specialized agent executor classes
- Custom Aggregators: Control how results are combined
| File | Description |
|---|---|
concurrent_agents.py |
Basic concurrent workflow with researcher, marketer, and legal agents |
concurrent_custom_agent_executors.py |
Using custom executor classes that own ChatAgents |
concurrent_custom_aggregator.py |
Custom aggregation logic for combining results |
concurrent_participant_factory.py |
Participant factories for stateful workflows |
concurrent_workflow_as_agent.py |
Wrap concurrent workflow as a reusable agent |
- Python 3.10 or later
- Azure OpenAI resource with a deployed model
- Azure CLI authenticated (
az login)
See the main README for complete setup instructions. Quick start:
# From project root
cp .env.example .env # Then edit with your Azure OpenAI settings
python -m venv venv
venv\Scripts\activate # Windows (or source venv/bin/activate on Linux/Mac)
pip install -r requirements.txt
az login# Basic concurrent workflow
python concurrent_agents.py
# With custom agent executors
python concurrent_custom_agent_executors.py
# With custom aggregator
python concurrent_custom_aggregator.py
# With participant factories
python concurrent_participant_factory.py
# Workflow as reusable agent
python concurrent_workflow_as_agent.py User Input
│
[Dispatcher]
/ │ \
↓ ↓ ↓
Researcher Marketer Legal
\ │ /
[Aggregator]
│
Final Output
- ConcurrentBuilder: Constructs the workflow with parallel participants
- Default Dispatcher: Fans out the same user prompt to all agents
- Parallel Execution: All agents process the input simultaneously
- Default Aggregator: Combines results into
list[ChatMessage]
===== Final Aggregated Conversation (messages) =====
------------------------------------------------------------
01 [user]:
We are launching a new budget-friendly electric bike for urban commuters.
------------------------------------------------------------
02 [researcher]:
**Insights:**
- Target Demographic: Urban commuters seeking affordable, eco-friendly transport
- Market Trends: E-bike sales growing with urbanization and sustainability focus
...
------------------------------------------------------------
03 [marketer]:
**Value Proposition:**
"Freedom to commute without breaking the bank"
...
------------------------------------------------------------
04 [legal]:
**Compliance Considerations:**
- Consumer safety regulations for electric vehicles
- Battery disposal and recycling requirements
...
- Domain Agents: Each agent specializes in a specific perspective (research, marketing, legal)
- Custom Executors: Create classes that own ChatAgents with
@handlerdecorators - AgentExecutorRequest/Response: Standard input/output types for custom executors
- Workflow Completion: Completes when all participants become idle
- Multi-Perspective Analysis: Get insights from different domain experts
- Parallel Research: Multiple researchers investigating different aspects
- Review Processes: Legal, technical, and business reviews in parallel
- Content Generation: Multiple writers creating variations simultaneously
Authentication errors:
az login --tenant <your-tenant-id>Module not found: Ensure root-level virtual environment is activated:
cd .. # Go to project root
venv\Scripts\activate
cd 02-ConcurrentAgents
python concurrent_agents.pyAzure OpenAI errors:
- Verify
AZURE_OPENAI_ENDPOINTis correct - Ensure your deployment name matches
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME - Check that your Azure subscription has access to Azure OpenAI