This demo showcases the Sequential Agents pattern using the Azure AI Agent Framework. Sequential workflows chain multiple agents together where the output of one agent becomes the input for the next, maintaining a shared conversation context throughout.
- Shared Conversation Context: All agents share and build upon the same conversation history
- Agent Chaining: Agents execute in a defined sequence (writer → reviewer)
- Custom Executors: Extend with custom executor classes for specialized processing
- Participant Factories: Create stateful workflows with proper isolation between instances
| File | Description |
|---|---|
sequential_agents.py |
Basic sequential workflow with writer and reviewer agents |
sequential_custom_executors.py |
Mixing agents with custom summarizer executors |
sequential_participant_factory.py |
Using participant factories for stateful workflows |
sequential_workflow_as_agent.py |
Wrap sequential 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 sequential workflow
python sequential_agents.py
# With custom executors
python sequential_custom_executors.py
# With participant factories
python sequential_participant_factory.py
# Workflow as reusable agent
python sequential_workflow_as_agent.pyUser Input → Writer Agent → Reviewer Agent → Final Output
↓ ↓
[Shared Conversation Context]
- SequentialBuilder: Constructs the workflow by chaining participants
- Shared Conversation:
list[ChatMessage]flows through each participant - Agent Responses: Each agent appends its assistant message to the context
- Final Output: Complete conversation history returned when workflow completes
===== Final Conversation =====
------------------------------------------------------------
01 [user]
Write a tagline for a budget-friendly eBike.
------------------------------------------------------------
02 [writer]
Ride farther, spend less—your affordable eBike adventure starts here.
------------------------------------------------------------
03 [reviewer]
This tagline clearly communicates affordability and the benefit of extended
travel, making it appealing to budget-conscious consumers.
- Internal Adapters: The orchestration includes adapter nodes for input normalization and completion
- Custom Executors: Implement
@handleracceptinglist[ChatMessage]andWorkflowContext - Participant Factories: Use lambdas to create stateful participants with proper isolation
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 01-SequentialAgents
python sequential_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