[BREAKING] Python: Fix workflow as agent streaming output#3649
Merged
TaoChenOSU merged 17 commits intomicrosoft:mainfrom Feb 5, 2026
Merged
Conversation
Member
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements breaking changes to fix workflow-as-agent streaming output (closes #3126). The changes consolidate output event handling by removing AgentRunEvent and AgentRunUpdateEvent in favor of WorkflowOutputEvent, introduce output executor filtering via with_output_from, and fix workflow-as-agent to properly stream agent responses.
Changes:
- Removes
AgentRunEventandAgentRunUpdateEventclasses, consolidating onWorkflowOutputEventfor all executor outputs - Adds
with_output_frombuilder method to filter which executors emit workflow outputs, with validation - Changes
WorkflowAgentto run workflows in non-streaming mode when invoked viarun()(previously always streamed)
Reviewed changes
Copilot reviewed 66 out of 68 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
_events.py |
Removes deprecated event classes |
_agent_executor.py |
Removes output_response parameter, always yields outputs via WorkflowOutputEvent |
_workflow.py |
Adds output executor filtering support |
_workflow_builder.py |
Adds with_output_from method, removes deprecated add_agent |
_agent.py |
Implements proper streaming/non-streaming mode handling for workflow-as-agent |
_validation.py |
Adds output executor validation |
| Builder files | Add with_intermediate_outputs to control output filtering |
| Sample files | Updated to handle new event patterns |
| Test files | Comprehensive updates for new behavior |
moonbox3
approved these changes
Feb 4, 2026
dmytrostruk
approved these changes
Feb 5, 2026
dmytrostruk
approved these changes
Feb 5, 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
Closes #3126
Description
AgentRunEventandAgentRunUpdateEvent. Replace withWorkflowOutputEvent.AgentExecutorwill always emitWorkflowOutputEventcarrying eitherAgentReponseorAgentResponseUpdatewhen they become available. Theoutput_responseflag is removed.with_output_fromto allow developers to configure which executors in the workflow can surfaceWorkflowOutputEvents.WorkflowAgentfor using workflow as an agent now runs the workflow in non-streaming mode if it's invoked viarun. Previously, the underlying workflow would run in streaming mode regardless of if it's invoked viarunorrun_stream.With the changes above, the workflow as an agent will have the following pattern:
WorkflowOutputEvents.WorkflowOutputEvents are considered as the outputs of a workflow.WorkflowOutputEvents will be converted toAgentResponseorAgentResponseUpdate.WorkflowOutputEvents. It's implemented as a simple filter.WorkflowOutputEvent:a.
AgentResponseUpdatewill be directly yielded without modification.b.
AgentResponsewill be converted to anAgentResponseUpdateby extracting contents from messages, dropping message IDs. The original response is preserved inraw_representation.c.
ChatMessagewill be converted to anAgentResponseUpdateby extracting contents. The original message is preserved inraw_representation.d. A list of
ChatMessagewill be converted to multipleAgentResponseUpdate, one per message.c. Any other data type will be converted to
Contentof typetextand put into anAgentResponseUpdate.WorkflowOutputEvent:a.
AgentResponseUpdatewill result in an exception.b.
AgentResponsewill be directly returned without modification.c. A single
ChatMessageor a list ofChatMessages will be returned in anAgentResponse. The original messages are preserved inraw_representation.d. Any other data type will be converted to
Contentof typetextand placed in aChatMessage.RequestInfoEvents stay unchanged in this PR.Note:
WorkflowOutputEvents don't signal the end state of a workflow. A workflow run can emit any number ofWorkflowOutputEvents (including zero). Any data the workflow generates should be considered outputs of the workflow.Contribution Checklist