fix(graph): treat cancel_node as control flow, not fatal error#2258
Open
Zelys-DFKH wants to merge 1 commit intostrands-agents:mainfrom
Open
fix(graph): treat cancel_node as control flow, not fatal error#2258Zelys-DFKH wants to merge 1 commit intostrands-agents:mainfrom
Zelys-DFKH wants to merge 1 commit intostrands-agents:mainfrom
Conversation
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.
Description
When
cancel_nodeis set in aBeforeNodeCallEventhook, the intent is to skip a node and keep the graph running. What actually happens:_execute_noderaisesRuntimeErrorafter emittingMultiAgentNodeCancelEvent, which propagates through_execute_nodes_paralleland kills the graph. Downstream nodes never run, the overall status becomesFAILED, and on interrupt-and-resume workflows the session is left with no recovery path — the next call starts a fresh graph instead of continuing.The fix marks the skipped node as
Status.COMPLETED, records it instate.completed_nodes,state.results, andstate.execution_order, yieldsMultiAgentNodeStopEvent, and returns._find_newly_ready_nodespicks up downstream nodes fromcompleted_batchas usual.get_agent_results()returns[]for theRuntimeErrorresult, so downstream nodes see no output from the skipped node. No new status enum needed. Also corrected thecancel_nodedocstring, which still said "status FAILED".Related Issues
Resolves #2240
Documentation PR
N/A
Type of Change
Bug fix
Testing
Ran
hatch run prepare. Updatedtest_graph_cancel_node(parametrized ×2) to check for normal completion instead of raising. Addedtest_graph_cancel_node_downstream_executes: cancelsstep_avia hook and verifiesstep_bstill runs, with both nodes incompleted_nodesandresults. No public API changes, so no impact on consuming repos.hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.