-
Notifications
You must be signed in to change notification settings - Fork 739
Python: Samples using heterogeneous agents #1878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Python: Samples using heterogeneous agents #1878
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds two new sample files demonstrating workflow orchestration patterns with heterogeneous agents (using different Azure OpenAI client types). The samples show how to combine different client implementations in sequential and handoff workflows.
- Adds
sequential_heterogeneous_agents.pyshowing a sequential workflow using both AzureOpenAIChatClient and AzureOpenAIResponsesClient - Adds
handoff_heterogeneous_agents.pydemonstrating a handoff pattern with mixed client types (AzureOpenAIChatClient, AzureOpenAIAssistantsClient, AzureOpenAIResponsesClient, and OpenAIChatClient)
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| python/samples/getting_started/workflows/orchestration/sequential_heterogeneous_agents.py | New sample demonstrating sequential workflow with heterogeneous agents using AzureOpenAIChatClient and AzureOpenAIResponsesClient |
| python/samples/getting_started/workflows/orchestration/handoff_heterogeneous_agents.py | New sample showing handoff workflow pattern with four different agent client types (Azure Chat, Azure Assistants, Azure Responses, OpenAI Chat) |
| """ | ||
|
|
||
|
|
||
| def create_agents() -> tuple[ChatAgent, ChatAgent, ChatAgent, ChatAgent]: |
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function signature should accept a parameter for consistency with similar samples. In handoff_simple.py and handoff_specialist_to_specialist.py, the create_agents() function accepts a chat_client parameter to promote reusability. This sample should follow the same pattern, even though it creates agents from different client types. Consider accepting optional client instances as parameters or at least document why this pattern deviates from other handoff samples.
| # Triage agent: Acts as the frontline dispatcher | ||
| # NOTE: The instructions explicitly tell it to call the correct handoff tool when routing. | ||
| # The HandoffBuilder intercepts these tool calls and routes to the matching specialist. | ||
| triage = AzureOpenAIChatClient(credential=AzureCliCredential()).create_agent( |
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a new AzureCliCredential() instance for each client is inefficient. The credential should be created once and reused across all Azure clients. Consider creating the credential once in main() or create_agents() and passing it to all clients that need it.
| ) | ||
|
|
||
| # Refund specialist: Handles refund requests | ||
| refund = AzureOpenAIAssistantsClient(credential=AzureCliCredential()).create_agent( |
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a new AzureCliCredential() instance for each client is inefficient. The credential should be created once and reused across all Azure clients. Consider creating the credential once in main() or create_agents() and passing it to all clients that need it.
| ) | ||
|
|
||
| # Order/shipping specialist: Resolves delivery issues | ||
| order = AzureOpenAIResponsesClient(credential=AzureCliCredential()).create_agent( |
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a new AzureCliCredential() instance for each client is inefficient. The credential should be created once and reused across all Azure clients. Consider creating the credential once in main() or create_agents() and passing it to all clients that need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback
| ) | ||
|
|
||
| # General support specialist: Fallback for other issues | ||
| support = OpenAIChatClient().create_agent( |
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a new AzureCliCredential() instance for each client is inefficient. The credential should be created once and reused across all Azure clients. Consider creating the credential once in main() or create_agents() and passing it to all clients that need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback
Motivation and Context
Description
Contribution Checklist