Python: preserve response update metadata in WorkflowAgent forwarding - #7999
Open
HeZzz (HeZ2z) wants to merge 3 commits into
Open
Python: preserve response update metadata in WorkflowAgent forwarding#7999HeZzz (HeZ2z) wants to merge 3 commits into
HeZzz (HeZ2z) wants to merge 3 commits into
Conversation
Forward finish_reason, continuation_token, agent_id and a shallow copy of additional_properties when WorkflowAgent reconstructs AgentResponseUpdate objects from workflow events, matching the documented as-is forwarding contract.
Contributor
There was a problem hiding this comment.
Pull request overview
Preserves metadata when WorkflowAgent forwards streaming response updates.
Changes:
- Forwards response metadata, including continuation tokens.
- Adds streaming regression coverage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
_workflows/_agent.py |
Copies metadata into forwarded updates. |
test_workflow_agent.py |
Tests metadata preservation. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Use an explicit None check instead of a truthiness check so an explicitly empty additional_properties dict is not converted to None, preserving the forwarding contract.
Author
|
@microsoft-github-policy-service agree |
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 & Context
WorkflowAgentwraps a workflow and forwards executor emissions through_convert_workflow_event_to_agent_response_updates(). The method documentation promises thatoutputandintermediateevents are forwarded as-is, but when reconstructing anAgentResponseUpdatethe code only copiedcontents,role,author_name, IDs,created_atandraw_representation— silently dropping several response metadata fields.Consumers streaming through
WorkflowAgent.run(stream=True)therefore sawNonefor fields that were present on the executor's original update. This differs from running the same agent directly, breaksAgentResponse.from_updates()reconstruction for those fields, and can make long-running operations unresumable (lostcontinuation_token).Description & Review Guide
What are the major changes?
_convert_workflow_event_to_agent_response_updates()now forwardsfinish_reason,continuation_token,agent_id, andadditional_properties(as a shallow copy, so the forwarded update cannot alias the payload still referenced by the executor) when reconstructing anAgentResponseUpdate.AgentResponseUpdatewith all metadata populated and asserts each field survives the wrapping.What is the impact of these changes?
Nonecontinue to behave exactly as before. No breaking change.What do you want reviewers to focus on?
additional_propertiesmatches the project's preferred convention (vs.copy.copy).AgentResponse,Message,list[Message]) should receive the same treatment in this PR or a follow-up.Related Issue
Fixes #7952
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.