Skip to content

fix(multiagent): preserve failed status reported by graph nodes#33

Open
chaynabors wants to merge 2 commits into
mainfrom
agent-tasks/683
Open

fix(multiagent): preserve failed status reported by graph nodes#33
chaynabors wants to merge 2 commits into
mainfrom
agent-tasks/683

Conversation

@chaynabors

Copy link
Copy Markdown
Owner

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.

@chaynabors

Copy link
Copy Markdown
Owner Author

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 chaynabors left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@chaynabors

Copy link
Copy Markdown
Owner Author

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.

@github-actions github-actions Bot added size/s and removed size/m labels Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] The status of the AgentResult or MultiAgentResult gets overwritten to status.COMPLETED

1 participant