Python: [BREAKING] Moved to a single get_response and run API#3379
Merged
eavanvalkenburg merged 102 commits intomicrosoft:mainfrom Feb 5, 2026
Merged
Python: [BREAKING] Moved to a single get_response and run API#3379eavanvalkenburg merged 102 commits intomicrosoft:mainfrom
eavanvalkenburg merged 102 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR consolidates the Python Agent Framework's streaming and non-streaming APIs into a unified interface. The primary changes include:
Changes:
- Unified
run()andget_response()methods withstreamparameter replacing separaterun_stream()andget_streaming_response()methods - Migration from decorator-based (
@use_instrumentation,@use_function_invocation) to mixin-based architecture for telemetry and function invocation - Introduction of
ResponseStreamclass for unified stream handling with hooks, finalizers, and teardown support - Renamed
AgentExecutionExceptiontoAgentRunException
Reviewed changes
Copilot reviewed 84 out of 85 changed files in this pull request and generated 28 comments.
Show a summary per file
| File | Description |
|---|---|
_types.py |
Added ResponseStream class for unified streaming, updated prepare_messages to handle None |
_clients.py |
Refactored BaseChatClient with unified get_response() method, introduced FunctionInvokingChatClient mixin |
openai/_responses_client.py |
Consolidated streaming/non-streaming into single _inner_get_response() method |
openai/_chat_client.py |
Similar consolidation for chat completions API |
openai/_assistants_client.py |
Unified assistants API with stream parameter |
_workflows/_workflow.py |
Consolidated run() and run_stream() into single run(stream=bool) method |
_workflows/_agent.py |
Updated WorkflowAgent.run() to use stream parameter |
| Test files (multiple) | Updated all tests to use run(stream=True) and get_response(stream=True) |
| Sample files (multiple) | Updated samples to demonstrate new unified API |
| Provider clients | Updated all provider implementations (Azure, Anthropic, Bedrock, Ollama, etc.) to use mixins |
python/packages/core/agent_framework/openai/_assistants_client.py
Outdated
Show resolved
Hide resolved
python/packages/core/tests/workflow/test_agent_executor_tool_calls.py
Outdated
Show resolved
Hide resolved
07afd46 to
dd65afa
Compare
Member
32f0473 to
5c78d91
Compare
TaoChenOSU
reviewed
Jan 30, 2026
python/packages/anthropic/agent_framework_anthropic/_chat_client.py
Outdated
Show resolved
Hide resolved
python/packages/core/agent_framework/_workflows/_agent_executor.py
Outdated
Show resolved
Hide resolved
ebfc3b0 to
92995e6
Compare
Member
Author
|
Fixes lingering CI failures: import missing response types in streaming telemetry finalizers, move AG-UI tests to ag_ui_tests with config updates, and track service thread IDs in AG-UI test client.\n\nChecks: uv run poe fmt/lint/pyright/mypy; uv run poe all-tests. |
moonbox3
reviewed
Feb 3, 2026
a8f7c92 to
a5dadf8
Compare
dmytrostruk
approved these changes
Feb 4, 2026
92df8e3 to
a99fdba
Compare
- Refactor streaming function invocation to use get_final_response() on inner streams - Fix MiddlewareTermination to accept result parameter for passing results - Fix _AutoHandoffMiddleware to use MiddlewareTermination instead of context.terminate - Fix AgentMiddlewareLayer.run() to properly forward function/chat middleware - Remove duplicate middleware registration in AgentMiddlewareLayer.__init__ - Fix exception handling in _auto_invoke_function to properly capture termination - Fix mypy errors in core package - Update tests to use stream=True parameter for unified run API
- Merge testutils.py into conftest.py for azurefunctions integration tests - Merge dt_testutils.py into conftest.py for durabletask integration tests - Convert all integration tests to use fixtures instead of direct imports (fixes ModuleNotFoundError with --import-mode=importlib) - Add sample_helper fixture for azurefunctions tests - Add agent_client_factory and orchestration_helper fixtures for durabletask - Integration tests now skip with descriptive messages when services unavailable - Restructure devui tests into tests/devui/ with proper conftest.py - Add test organization guidelines to CODING_STANDARD.md - Remove __init__.py from test directories per pytest best practices
The hook was skipping all tests in the test session, not just integration tests. Now it only skips items in the integration_tests directory.
Use patch.object on the imported module instead of @patch with string path to ensure the mock takes effect regardless of import timing.
Increase from 2 to 8 seconds to allow time for: - Python startup and module imports - Azure OpenAI client creation - Agent registration with DTS worker - Worker connection to DTS This helps prevent test failures in CI where the first tests may run before the worker is fully ready to process requests.
The _consume_stream method now expects a ResponseStream that can provide a final AgentResponse via get_final_response(). Update the test to use ResponseStream with AgentResponse.from_updates as the finalizer.
0da7fb1 to
7990238
Compare
dmytrostruk
approved these changes
Feb 5, 2026
dmytrostruk
approved these changes
Feb 5, 2026
This was referenced Feb 11, 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
Summary
ResponseStream[ChatResponseUpdate, ChatResponse]toResponseStream[AgentResponseUpdate, AgentResponse], but the object has a classmethod calledwrapthat is used to wrap the ResponseStream from the chat client into the new ResponseStream in the Agent.Description
Contribution Checklist
Fixes #3585
Fixes #3607
Fixes #3617
Fixes #3581
Fixes #3610