Skip to content

Python: Fix/7859 discard pending state - #8819

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 33 commits into
microsoft:mainfrom
Namraa310806:fix/7859-discard-pending-state
Oct 12, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 33 commits into
microsoft:mainfrom
Namraa310806:fix/7859-discard-pending-state

Conversation

@Namraa310806

Copy link
Copy Markdown
Contributor

Motivation & Context

Fixes a state isolation bug where pending State writes from a failed or cancelled workflow superstep can leak into a later successful Workflow.run() on the same Workflow instance.

State.set() stages writes in a pending buffer, which is committed only when a superstep completes successfully. However, when a superstep fails or is cancelled, the pending writes were not discarded.

Because workflow state persists across run() calls, a later successful superstep could call State.commit() and unintentionally commit stale writes from the previous failed run.

This results in silent state corruption: state written by a failed run can become part of the committed state of a later successful run.

Description & Review Guide

  • What are the major changes?

    • Discard pending state when a superstep fails with an exception.
    • Discard pending state when a superstep is cancelled.
    • Ensure concurrent edge-runner execution cannot continue staging state after the failed superstep reaches the discard boundary.
    • Add regression tests covering failed supersteps and concurrent execution.
  • What is the impact of these changes?

    • Pending writes from failed or cancelled supersteps are no longer able to leak into later successful runs.
    • Committed state from previous successful runs is preserved.
    • Successful supersteps continue to use the existing State.commit() behavior.
    • No public API or checkpoint serialization behavior is changed.
  • What do you want reviewers to focus on?

    • Whether the failure/cancellation boundary correctly prevents pending state from a failed superstep from reaching a later commit.
    • Whether the concurrent edge-runner handling preserves the existing execution and error-propagation semantics.

Related Issue

Fixes #7859

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix) — a workflow keeps the label and title prefix in sync automatically.

Extending #7880 and fixing CI failing workflows

@Namraa310806

Copy link
Copy Markdown
Contributor Author

Eduard van Valkenburg (@eavanvalkenburg) both issues addressed (cancellation handling + removed the mid-executor commit()), with regression tests for each. Let me know if anything else needs changing.

Comment thread python/packages/core/agent_framework/_workflows/_runner.py Outdated
Merged via the queue into microsoft:main with commit e7ca6c2 Oct 12, 2026
45 checks passed
@Namraa310806
Patel Namraa (Namraa310806) deleted the fix/7859-discard-pending-state branch October 13, 2026 14:16

This branch was previously deployed

1 inactive deployment
github-app-auth — 2f99801a Deployed Oct 10, 2026 by Namraa310806 via add_label #24911
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Pending State writes from a failed superstep leak into a later successful run

3 participants