Python: Fixed AutoGen migration and tool samples#4027
Merged
TaoChenOSU merged 12 commits intomicrosoft:mainfrom Feb 18, 2026
Merged
Python: Fixed AutoGen migration and tool samples#4027TaoChenOSU merged 12 commits intomicrosoft:mainfrom
TaoChenOSU merged 12 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes various issues in Python samples related to AutoGen migration, tool usage, and provider integrations. The changes address API misuse, type mismatches, and clean up output formatting.
Changes:
- Fixed AutoGen streaming API calls to use
run_stream()instead ofrun(stream=True) - Fixed orchestration streaming to use
executor_completedevents instead ofoutputevents for SequentialBuilder and GroupChatBuilder - Fixed swarm sample import and response type handling for handoff workflows
- Fixed Ollama samples to pass
list[Message]instead of strings toget_response() - Fixed session injection sample to use
additional_function_argumentsworkaround - Added
AzureCliCredentialto approval-with-sessions sample - Removed internal file paths from tool sample expected outputs
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| python/samples/autogen-migration/single_agent/04_agent_as_tool.py | Changed run(stream=True) to run_stream() for AutoGen API consistency |
| python/samples/autogen-migration/single_agent/03_assistant_agent_thread_and_stream.py | Changed run(stream=True) to run_stream() for AutoGen API consistency |
| python/samples/autogen-migration/orchestrations/03_swarm.py | Fixed import (orderedmultidict → typing) and wrapped user responses with HandoffAgentUserRequest.create_response() |
| python/samples/autogen-migration/orchestrations/02_selector_group_chat.py | Fixed streaming to use executor_completed events with list iteration instead of individual output events |
| python/samples/autogen-migration/orchestrations/01_round_robin_group_chat.py | Fixed streaming to use executor_completed events with list iteration instead of individual output events |
| python/samples/04-hosting/azure_functions/12_workflow_hitl/function_app.py | Sorted imports alphabetically (moved Message before Executor) |
| python/samples/02-agents/tools/tool_in_class.py | Removed internal file path from expected output in comment |
| python/samples/02-agents/tools/function_tool_with_session_injection.py | Added additional_function_arguments workaround to pass session to tools via kwargs |
| python/samples/02-agents/tools/function_tool_with_max_invocations.py | Removed internal file path from expected output in comment |
| python/samples/02-agents/tools/function_tool_with_max_exceptions.py | Removed internal file paths from expected output in comment |
| python/samples/02-agents/tools/function_tool_with_approval_and_sessions.py | Added AzureCliCredential() to AzureOpenAIChatClient initialization |
| python/samples/02-agents/providers/ollama/ollama_chat_multimodal.py | Changed get_response(message) to get_response([message]) to match API signature |
| python/samples/02-agents/providers/ollama/ollama_chat_client.py | Added Message import and changed get_response() calls to accept list[Message] instead of strings |
eavanvalkenburg
approved these changes
Feb 18, 2026
TaoChenOSU
reviewed
Feb 18, 2026
python/samples/autogen-migration/orchestrations/01_round_robin_group_chat.py
Outdated
Show resolved
Hide resolved
TaoChenOSU
approved these changes
Feb 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
executor_completedevents for SequentialBuilder and GroupChatBuilder outputagent.run(stream=True)calls to useagent.run_stream()orderedmultidict→typing) and response type mismatch for handoff responseslist[Message]toget_response()instead of plain stringsadditional_function_argumentsworkaroundAzureCliCredentialto approval-with-sessions sampleContribution Checklist