Skip to content

[BUG] reset_on_revisit doesn't work with cycles/feedback loops in Graph #684

@dazotaro

Description

@dazotaro

node not in self.state.completed_nodes

The reset_on_revisit feature in Graph multiagent pattern fails to enable cycles/feedback loops because _find_newly_ready_nodes filters out completed nodes before they can be revisited.

Bug Details

The problematic code:

def _find_newly_ready_nodes(self) -> list["GraphNode"]:
      """Find nodes that became ready after the last execution."""
      newly_ready = []
      for _node_id, node in self.nodes.items():
          if (
              node not in self.state.completed_nodes  # <- BUG: prevents revisiting
              and node not in self.state.failed_nodes
              and self._is_node_ready_with_conditions(node)
          ):
              newly_ready.append(node)
      return newly_ready

Expected Behavior

When reset_on_revisit=True and a feedback edge condition is satisfied, completed nodes should be re-executed with their state reset.

Actual Behavior

Completed nodes are never reconsidered for execution, making feedback loops impossible even when reset_on_revisit=True.

Impact

Cannot implement feedback loops (e.g., error correction cycles) in Graph-based multi-agent systems.

Suggested Fix

Allow completed nodes to be added to newly_ready when incoming edge conditions are satisfied and revisiting is enabled.

Metadata

Metadata

Assignees

Labels

area-multiagentMulti-agent relatedbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions