Python: Samples using heterogeneous agents#1878
Python: Samples using heterogeneous agents#1878markwallace-microsoft wants to merge 2 commits intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
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]: |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
@copilot open a new pull request to apply changes based on this feedback
| ) | ||
|
|
||
| # General support specialist: Fallback for other issues | ||
| support = OpenAIChatClient().create_agent( |
There was a problem hiding this comment.
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.
@copilot open a new pull request to apply changes based on this feedback
|
Hi @markwallace-microsoft do we still need this PR? I don't see Copilot referencing a new PR? |
Motivation and Context
Description
Contribution Checklist