-
Notifications
You must be signed in to change notification settings - Fork 275
feature(graph): Allow cyclic graphs #497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Please concider #571 |
Co-authored-by: Nick Clegg <nac542@gmail.com>
def should_continue( | ||
self, | ||
max_node_executions: Optional[int], | ||
execution_timeout: Optional[float], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we should have a default timeout value?
@@ -213,8 +270,48 @@ def set_entry_point(self, node_id: str) -> "GraphBuilder": | |||
self.entry_points.add(self.nodes[node_id]) | |||
return self | |||
|
|||
def reset_on_revisit(self, enabled: bool = True) -> "GraphBuilder": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: if the only purpose of this function is to True, then having a boolean parameter is unnecessary?
if any(colors[node_id] == WHITE and has_cycle_from(node_id) for node_id in self.nodes): | ||
raise ValueError("Graph contains cycles - must be a directed acyclic graph") | ||
# Warn about potential infinite loops if no execution limits are set | ||
if self._max_node_executions is None and self._execution_timeout is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we could help users avoid infinite loops?
Description
This PR removes the cyclic graph validation from the multiagent graph implementation, based on customer feedback. Previously, the graph implementation enforced a Directed Acyclic Graph (DAG) structure, which limited certain use cases. By removing this restriction, we now support cyclic graphs, enabling more flexible agent workflows such as:
The changes are minimal and focused on removing the cycle detection algorithm while maintaining all other validation checks.
Related Issues
Addresses customer feedback requesting support for cyclic agent graphs
Documentation PR
TODO
Type of Change
New feature
Testing
hatch test
andhatch run test-integ
to ensure no regressionsChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.