-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Python: Fix streamed workflow agent continuation context by finalizing AgentExecutor streams #3882
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
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
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
Python Test Coverage Report •
Python Unit Test Overview
|
|||||||||||||||||||||||||||||||||||||||||||||
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