Python: discard pending State on failed/cancelled superstep (#7859) - #8306
Open
LI (ktz03) wants to merge 2 commits into
Open
Python: discard pending State on failed/cancelled superstep (#7859)#8306LI (ktz03) wants to merge 2 commits into
LI (ktz03) wants to merge 2 commits into
Conversation
Call State.discard() on runner failure and cancellation paths so staged writes cannot leak into a later successful run on the same Workflow. Fixes microsoft#7859.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Cleanup can still be skipped during event streaming and cancellation outside the polling block.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Prevents failed workflow supersteps from leaking staged Python state into later runs.
Changes:
- Discards pending state on failure and cancellation paths.
- Adds a workflow-reuse regression test for failures.
File summaries
| File | Description |
|---|---|
_runner.py |
Adds pending-state cleanup paths. |
test_runner.py |
Tests state isolation after failure. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 3
- Review effort level: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
- Scope cancel/BaseException cleanup across the full superstep until commit - Discard pending state before yielding failure events - Add cancellation regression that stages state then reuses the workflow
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
State.set()stages writes in_pending, but the runner never calledState.discard()on failure/cancellation. Because aWorkflowreuses the sameRunnerImpl/Stateacrossrun()calls, a later successful run couldcommit()stale pending writes from a prior failed superstep.Fixes #7859.
Description & Review Guide
self._state.discard()on the failed-iteration and cancellation paths inRunnerImpl.run_until_convergence().set_state, then succeeds on a second run and asserts the leaked key is absent from committed state.Related Issue
Fixes #7859
No other open PR targets this issue.
Contribution Checklist