Python: Fix #3970: Python: [Bug]: AgentResponse.value is None when streaming workflow#4282
Closed
moonbox3 wants to merge 1 commit intomicrosoft:mainfrom
Closed
Python: Fix #3970: Python: [Bug]: AgentResponse.value is None when streaming workflow#4282moonbox3 wants to merge 1 commit intomicrosoft:mainfrom
AgentResponse.value is None when streaming workflow#4282moonbox3 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…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>
AgentResponse.value is None when streaming workflowAgentResponse.value is None when streaming workflow
Contributor
There was a problem hiding this comment.
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/mergedchat_options.response_formatfrom the prepared run context (instead of only the per-calloptions). - Add a unit test covering streaming with
default_options["response_format"]to ensure a parsedAgentResponse.valueis 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. |
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.
Automated fix for #3970.
Verification passed after 0 retries.