fix(multiagent): preserve failed status reported by graph nodes#33
fix(multiagent): preserve failed status reported by graph nodes#33chaynabors wants to merge 2 commits into
Conversation
|
Surfaces an executor-reported FAILED status into failed_nodes instead of overwriting it to COMPLETED. The fix is local to the success path in _execute_node and mirrors how raised exceptions are already recorded. Obviously mergable: yes |
chaynabors
left a comment
There was a problem hiding this comment.
The bug and fix are real and the change at strands-py/src/strands/multiagent/graph.py:1082-1087 is correct: the only path to that line for a non-INTERRUPTED status (already early-returned at line 1078) is the nested MultiAgentBase branch starting at line 1027 where the executor's status is propagated into node_result, and previously that always got rewritten to COMPLETED. Routing FAILED into failed_nodes also makes graph status promotion at line 682-683 fire correctly and prevents downstream conditional edges from including the result via _build_node_input at line 1199, which filters by completed_nodes. There is no other status worth dispatching here since PENDING/EXECUTING are not valid terminal results and INTERRUPTED is handled earlier; the cancel-skip work on agent-tasks/2240 is independent and does not collide. One real gap: this PR ships zero regression coverage. Please add a test that wraps a failing nested Graph or Swarm under a parent Graph and asserts both graph.state.failed_nodes membership and graph.state.status == FAILED, otherwise the next refactor will re-introduce the bug. Also note the branch carries the unrelated idempotency commit 1b6f8a0 from the merged strands-agents#2932; please rebase onto current main so the PR shows only the graph.py fix.
e97649e to
db30265
Compare
|
Rebased onto current main to drop the unrelated idempotency commit, and added a regression test that wraps a failing nested MultiAgentBase under a parent Graph and asserts the node lands in failed_nodes with graph status FAILED. Diff is now just the graph.py fix plus the new test. |
Resolves strands-agents#683. When a graph node executor (a MultiAgentBase such as a nested Graph or Swarm, or a custom subclass) returned a NodeResult with status FAILED, the graph would unconditionally overwrite it to COMPLETED and add the node to completed_nodes, leaving execution_status and result.status disagreeing and preventing conditional edges from routing around the failure. The fix routes a FAILED node_result into failed_nodes with execution_status FAILED, matching how nodes that raise are already recorded.