Skip to content

Conversation

@dbschmigelski
Copy link
Member

Description

  • Add EdgeExecutionMode enum with OR (default) and AND modes to control when graph nodes become ready to execute
  • Fix latent bug in _compute_ready_nodes_for_resume that always used AND logic regardless of intended behavior

Motivation

Currently, when multiple nodes connect to a target node, the target executes as soon as ANY predecessor completes (OR logic). Users need the ability to wait for ALL predecessors to complete before executing (AND logic) for fan-in/join patterns.

  # A, B, C all connect to Z
  builder = GraphBuilder()
  builder.add_node(agent_a, "A")
  builder.add_node(agent_b, "B")
  builder.add_node(agent_c, "C")
  builder.add_node(agent_z, "Z")
  builder.add_edge("A", "Z")
  builder.add_edge("B", "Z")
  builder.add_edge("C", "Z")
  builder.set_entry_point("A")
  builder.set_entry_point("B")
  builder.set_entry_point("C")

  # OR mode (default): Z executes when ANY of A, B, C completes
  # AND mode: Z waits until ALL of A, B, C complete
  builder.set_edge_execution_mode(EdgeExecutionMode.AND)

  graph = builder.build()

Bug Fix

_compute_ready_nodes_for_resume previously used all() unconditionally, meaning resume always applied AND logic even though the default behavior is OR. This is now fixed to respect the edge_execution_mode setting.

Related Issues

#1081

Documentation PR

None

Type of Change

New feature

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov
Copy link

codecov bot commented Jan 21, 2026

Codecov Report

❌ Patch coverage is 97.36842% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/strands/multiagent/graph.py 97.05% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

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.

1 participant