Skip to content

Python: Populate WorkflowAgent response for empty streams - #8389

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
microsoft:mainfrom
ryo-whaletech:fix/8388-workflow-agent-empty-stream-response
Sep 16, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
microsoft:mainfrom
ryo-whaletech:fix/8388-workflow-agent-empty-stream-response

Conversation

@ryo-whaletech

Copy link
Copy Markdown
Contributor

Motivation & Context

A workflow can complete successfully without caller-facing output. Its fully consumed streaming run still finalizes to an empty AgentResponse, but ContextProvider.after_run currently sees SessionContext.response is None. The provider lifecycle contract says the response is populated when this hook runs.

Description & Review Guide

  • What are the major changes? Build the provider-visible response with the existing AgentResponse.from_updates finalizer even when no updates were forwarded, and add a focused zero-output regression test with a non-streaming control.
  • What is the impact of these changes? On successful empty streams, after_run providers receive an empty finalized response instead of None. Non-empty streams, non-streaming runs, yielded updates, and public API signatures are unchanged. Existing history and memory providers add no output messages for the empty response.
  • What do you want reviewers to focus on? Whether finalizing an empty update sequence for the provider hook correctly implements the documented lifecycle.

Related Issue

Fixes #8388

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved review issues were identified.

Pull request overview

This PR ensures after_run providers receive an empty AgentResponse for zero-output workflow runs.

Changes:

  • Finalizes empty streamed update sequences before provider callbacks.
  • Adds regression coverage for streaming and non-streaming zero-output runs.
File summaries
File Summary
python/packages/core/tests/workflow/test_workflow_agent.py Adds zero-output lifecycle regression coverage.
python/packages/core/agent_framework/_workflows/_agent.py Finalizes provider-visible responses for empty streams.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite (auto)

Note

Copilot is running an experiment and ran this review at Lite.


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@eavanvalkenburg

Copy link
Copy Markdown
Member

Thanks for the contribution. The approval-gated workflows ran, but the current head is not green: Python - Tests failed on Python 3.11/Ubuntu, the remaining Python test matrix jobs were cancelled, and Merge Gatekeeper failed. Could you please fix the failing test/checks, then re-request review? Thanks!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the complete diff and found no actionable issues. All reported checks for the current head are green.

Merged via the queue into microsoft:main with commit 0fb9e35 Sep 16, 2026
41 checks passed

This branch was previously deployed

1 inactive deployment
github-app-auth — bbb9b10c Deployed Sep 15, 2026 by ryo-whaletech via add_label #22925
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: WorkflowAgent leaves SessionContext.response unset for zero-output streams

3 participants