Skip to content

Python: Fix WorkflowAgent non-streaming return type - #8287

Open
WhaleTech (ryo-whaletech) wants to merge 1 commit into
microsoft:mainfrom
ryo-whaletech:fix/8286-workflow-agent-return-type
Open

Python: Fix WorkflowAgent non-streaming return type#8287
WhaleTech (ryo-whaletech) wants to merge 1 commit into
microsoft:mainfrom
ryo-whaletech:fix/8286-workflow-agent-return-type

Conversation

@ryo-whaletech

Copy link
Copy Markdown
Contributor

Motivation & Context

WorkflowAgent.run(stream=False) currently exposes a ResponseStream[AgentResponseUpdate, AgentResponse] return type even though the runtime false branch returns the non-streaming _run_impl() awaitable. This disagrees with SupportsAgentRun, the method documentation, and nearby agent implementations, so type checkers and IDEs see the wrong public pre-await return type.

Runtime execution is already correct. This change aligns the overload with existing behavior and the common agent contract.

Description & Review Guide

  • What are the major changes?
    • Correct the Literal[False] overload of WorkflowAgent.run() to return Awaitable[AgentResponse].
    • Add focused assert_type coverage for omitted/default stream, explicit stream=False, and stream=True.
  • What is the impact of these changes?
    • Static typing now matches the existing runtime behavior.
    • stream=True typing and runtime execution are unchanged.
    • There are no changes to storage, serialization, checkpoints, workflow execution, network calls, or provider behavior.
    • Local validation passed all five core typing checkers, focused WorkflowAgent tests, strict Pyright, Ruff syntax checks, the full core check, package builds, and git diff --check.
  • What do you want reviewers to focus on?
    • Whether the corrected overload matches the common SupportsAgentRun contract.
    • Whether the assert_type coverage is the preferred regression mechanism.
    • Whether any public or generated stub requires a matching edit; the root .pyi currently re-exports the concrete class directly.

Related Issue

Fixes #8286

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

The typing fix matches runtime behavior and includes focused regression coverage.

Pull request overview

This pull request aligns WorkflowAgent.run() typing with runtime behavior and SupportsAgentRun.

Changes:

  • Corrects non-streaming overload return types.
  • Adds assertions for default, non-streaming, and streaming calls.
File summaries
File Summary
python/packages/core/tests/workflow/test_workflow_agent.py Adds overload regression assertions.
python/packages/core/agent_framework/_workflows/_agent.py Fixes the non-streaming return annotation.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

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

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 11, 2026
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.run(stream=False) declares ResponseStream instead of Awaitable[AgentResponse]

3 participants