Python: Fix streamed workflow agent continuation context by finalizing AgentExecutor streams#3882
Merged
moonbox3 merged 5 commits intomicrosoft:mainfrom Feb 12, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a streaming resume/continuation bug by ensuring agent streaming paths finalize ResponseStream instances (so result hooks run and state is persisted), and updates streaming thread-id handling to rely on conversation_id rather than response_id.
Changes:
- Update
AgentExecutorstreaming to callawait stream.get_final_response()and merge/dedupeuser_input_requests. - Update streaming thread-id updates to extract and use
conversation_idfrom raw streaming updates. - Add regression tests for stream finalization hooks and for thread-id behavior in streaming.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| python/packages/core/agent_framework/_workflows/_agent_executor.py | Finalizes agent response streams and dedupes user_input_requests after streaming completes. |
| python/packages/core/agent_framework/_agents.py | Changes streaming thread-id update logic to extract conversation_id from raw streaming updates. |
| python/packages/core/tests/workflow/test_agent_executor.py | Adds regression test ensuring AgentExecutor streaming finalizes streams and runs result hooks. |
| python/packages/core/tests/core/test_agents.py | Adds tests asserting streaming thread-id uses conversation_id and does not fall back to response_id. |
| python/packages/core/agent_framework/azure/_responses_client.py | Formatting-only changes (no functional behavior change). |
| python/samples/getting_started/orchestrations/handoff/handoff_with_tool_approval_checkpoint_resume.py | Updates sample to use streaming workflow runs and prints streamed agent output during resume. |
...mples/getting_started/orchestrations/handoff/handoff_with_tool_approval_checkpoint_resume.py
Outdated
Show resolved
Hide resolved
Member
Python Test Coverage Report •
Python Unit Test Overview
|
|||||||||||||||||||||||||||||||||||||||||||||
eavanvalkenburg
approved these changes
Feb 12, 2026
TaoChenOSU
reviewed
Feb 12, 2026
TaoChenOSU
reviewed
Feb 12, 2026
python/samples/03-workflows/orchestrations/handoff_with_tool_approval_checkpoint_resume.py
Show resolved
Hide resolved
TaoChenOSU
approved these changes
Feb 12, 2026
giles17
approved these changes
Feb 12, 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
Fixes a streaming resume bug in
AgentExecutorwhere continuation context could be lost, causing provider errors like:No tool call found for function call output with call_id ...The issue is that
AgentExecutor._run_agent_streamingiterated streamed updates and rebuilt the final response from collected updates, instead of finalizing theResponseStreamviaget_final_response(). That bypassed stream result hooks, which are responsible for persisting thread/conversation state needed for follow-up tool output continuation.Description
AgentExecutorstreaming flow to callawait stream.get_final_response()after iteration.user_input_requestsfrom:with request-id deduplication.
conversation_idextracted from raw streaming updates (instead ofresponse_id).conversation_id,response_id,AgentExecutorstreaming executes stream result hooks by finalizing the stream.Contribution Checklist