-
Notifications
You must be signed in to change notification settings - Fork 252
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
WHITE, GRAY, BLACK = 0, 1, 2 | ||
colors = {node_id: WHITE for node_id in self.nodes} | ||
|
||
def has_cycle_from(node_id: str) -> bool: |
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.
How do users now prevent infinite loops? Do you have an example that shows a cyclical agent graph breaking after a certain condition is met?
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.
+1
Please concider #571 |
This is particularly useful for cyclic graphs where nodes may be executed | ||
multiple times and need to start fresh on each cycle. | ||
""" | ||
if hasattr(self.executor, "messages"): |
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.
I know self.execution_status = Status.PENDING
makes sense for allowing cycles.
But, is resetting messages and state always desired. I could go either way, more so calling out that this seems like an assumption that we may want customer input on. Alternatively, is this not needed because the Feedback loops where output from later stages can influence earlier stages
is accomplished only from the incoming messages so the previous messages we treat as being "baked in" to the incoming ones?
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.
Related, should we consider adding a reset method to Agent so if we add new features we don't have to worry about also resetting them here and can reliable just do agent.reset()? Also requested here #329
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.