Fix GraphFlow state corruption on interrupt/resume#7220
Open
veeceey wants to merge 1 commit intomicrosoft:mainfrom
Open
Fix GraphFlow state corruption on interrupt/resume#7220veeceey wants to merge 1 commit intomicrosoft:mainfrom
veeceey wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Fixes microsoft#7043 When a GraphFlow workflow is interrupted during agent transitions, the state can become corrupted with work remaining but an empty ready queue. This causes resume attempts to fail with "Digraph execution is complete" even though agents haven't finished executing. The root cause is that the ready queue population happens during message processing (in update_message_thread), but if the workflow is interrupted between when an agent completes and when the next agent is enqueued, the state is saved with remaining work but no agents ready. Changes: - Add _validate_and_repair_state() method to detect and repair corrupted states on load - Check if work remains but ready queue is empty (corrupted state) - Reconstruct ready queue by finding nodes that should be ready: - For "all" activation: nodes with remaining count = 0 - For "any" activation: nodes that were previously enqueued - Call validation automatically in load_state() This ensures workflows can always resume from saved state, even if interrupted mid-transition. Signed-off-by: Varun Chawla <varun_6april@hotmail.com>
Author
|
All checks passing, DCO signed, ready for merge |
Author
|
Friendly ping - any chance someone could take a look at this when they get a chance? Happy to make any changes if needed. |
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.
Summary
Fixes #7043
When a GraphFlow workflow is interrupted during agent transitions, the state can become corrupted with work remaining but an empty ready queue. This causes resume attempts to fail with "Digraph execution is complete" even though agents haven't finished executing.
Problem
The root cause is that the ready queue population happens during message processing (in
update_message_thread), but if the workflow is interrupted between when an agent completes and when the next agent is enqueued, the state is saved with:remainingshows work left to doreadyqueue is empty (no agents enqueued)_apply_termination_conditionsees empty ready queue and terminatesSolution
Added state validation and repair logic:
_validate_and_repair_state()method detects corrupted states on loadremaining count == 0load_state()to repair on every resumeTesting
Manual unit test confirms the fix works:
This ensures workflows can always resume from saved state, even if interrupted mid-transition.