Repository navigation
Python: release functional workflow stream on agent response close - #10220
Open
袁永旗(Yuan Yongqi) (Yongthyuan) wants to merge 2 commits into
Open
袁永旗(Yuan Yongqi) (Yongthyuan) wants to merge 2 commits into
袁永旗(Yuan Yongqi) (Yongthyuan) wants to merge 2 commits into
Conversation
袁永旗(Yuan Yongqi) (Yongthyuan)
temporarily deployed
to
github-app-auth
November 10, 2026 08:33 — with
GitHub Actions
Inactive
袁永旗(Yuan Yongqi) (Yongthyuan)
requested a deployment
to
github-app-auth
November 10, 2026 08:34 — with
GitHub Actions
Waiting
袁永旗(Yuan Yongqi) (Yongthyuan)
temporarily deployed
to
github-app-auth
November 10, 2026 08:36 — with
GitHub Actions
Inactive
Contributor
Author
|
@microsoft-github-policy-service agree |
5 of 7 tasks
This branch was previously deployed
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
Closing a streaming
FunctionalWorkflowAgentresponse leaves its owned workflow marked as running. The next sequentialagent.run()raisesRuntimeError: Workflow is already running, even afterawait response.close()returns. This affects cancellation or disconnect cleanup followed by another turn.Description & Review Guide
workflow_stream.closeas a cleanup hook on the outerResponseStream, using the existing cleanup lifecycle to close the owned stream and release the run guard.Related Issue
Fixes #10164.
This submits the original patch I shared on November 7. On November 9, a maintainer marked the issue
ready-for-implementationand assigned it to me. The branch preserves that original commit and incorporates the latestmain.AI Assistance
AI assistance details: implementation, regression tests, local validation, and this description were prepared with AI assistance. I personally ran the original minimal reproduction and observed the reported failure.
Contribution Checklist
ready-for-implementationby a maintainer.The two early-close regressions fail against the original implementation and pass with this fix. The original minimal reproduction now prints
result: 2. Ruff lint and format, strict source Pyright, and test Pyright, mypy, Pyrefly, ty, and zuban checks pass for the changed files using the repository's pinned versions. Pyrefly reports three warnings in unchanged tests; the workflow tests emit the existing experimental-feature warning.