Skip to content

Python: Fix #3970: Python: [Bug]: AgentResponse.value is None when streaming workflow#4282

Closed
moonbox3 wants to merge 1 commit intomicrosoft:mainfrom
moonbox3:agent/fix-3970-8
Closed

Python: Fix #3970: Python: [Bug]: AgentResponse.value is None when streaming workflow#4282
moonbox3 wants to merge 1 commit intomicrosoft:mainfrom
moonbox3:agent/fix-3970-8

Conversation

@moonbox3
Copy link
Contributor

Automated fix for #3970.

Verification passed after 0 retries.

…s response_format (microsoft#3970)

The streaming finalizer was using the raw `options` parameter from `run()`
instead of the merged `chat_options` that include `default_options`. When
`response_format` was set via `default_options` and not passed explicitly in
the `run()` call, the finalizer received None and could not parse the value.

Changed the finalizer to read from `ctx_holder` which contains the merged
options (including default_options) after stream initialization.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 26, 2026 00:15
@github-actions github-actions bot changed the title Fix #3970: Python: [Bug]: AgentResponse.value is None when streaming workflow Python: Fix #3970: Python: [Bug]: AgentResponse.value is None when streaming workflow Feb 26, 2026
@moonbox3 moonbox3 closed this Feb 26, 2026
@moonbox3 moonbox3 deleted the agent/fix-3970-8 branch February 26, 2026 00:19
Copy link
Contributor

Copilot AI left a 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 Python streaming bug where AgentResponse.value wasn’t being parsed when response_format was provided via an agent’s default_options (commonly encountered when agents are run inside streaming workflows).

Changes:

  • Update the streaming Agent.run(..., stream=True) finalizer to use the resolved/merged chat_options.response_format from the prepared run context (instead of only the per-call options).
  • Add a unit test covering streaming with default_options["response_format"] to ensure a parsed AgentResponse.value is produced.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
python/packages/core/agent_framework/_agents.py Ensures the streaming final response uses the context-prepared response_format (includes default_options) when building AgentResponse.
python/packages/core/tests/core/test_agents.py Adds a regression test validating AgentResponse.value is parsed when streaming with default_options.response_format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants