-
Notifications
You must be signed in to change notification settings - Fork 7.4k
add activation group for workflow with multiple cycles #6711
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
add activation group for workflow with multiple cycles #6711
Conversation
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.
Pull Request Overview
This pull request addresses a flaw in the activation tracking mechanism when handling cycles in the workflow, implementing a two-layer activation map to distinguish between edges inside a cycle and outside the cycle. Key changes include:
- Renaming and updating test functions to verify behavior with self cycles and multiple cycles.
- Adding new properties (activation_group and activation_condition) and validators to DiGraphEdge.
- Updating state tracking and lookup methods in GraphFlowManagerState to use a two-layered remaining map.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
File | Description |
---|---|
python/packages/autogen-agentchat/tests/test_group_chat_graph.py | Renamed and added tests to validate cycle handling with new activation groups. |
python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_graph/_digraph_group_chat.py | Updated edge and state logic to support a two-layer activation map for handling cycles. |
Comments suppressed due to low confidence (3)
python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_graph/_digraph_group_chat.py:440
- [nitpick] Consider adding a comment to explain the rationale for resetting the remaining count from _origin_remaining in _reset_triggered_activation_groups to improve maintainability.
self._remaining[speaker][activation_group] = self._origin_remaining[speaker][activation_group]
python/packages/autogen-agentchat/tests/test_group_chat_graph.py:722
- [nitpick] Ensure the new test name clearly reflects its purpose of testing self-cycle activation behavior, which is key to verifying the updated activation grouping mechanism.
async def test_digraph_group_chat_loop_with_self_cycle(runtime: AgentRuntime | None) -> None:
python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_graph/_digraph_group_chat.py:122
- The removal of the self-loop check in get_parents now includes self-loop edges as parents. Please confirm this change is intentional and aligns with the revised activation grouping logic.
parents[edge.target].append(node.name)
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.
Thanks for the PR.
- Could you add explanation to the new fields "activation_group" and "activation_condition", and in what scenario user need to use them.
- Could you also add the activation group feature to the digraph builder API?
- Add a code example to the API doc of
GraphFlow
to show how to use the builder API to create a graph flow with two different cycles involving a single node. Ensure the code block passes Pyright check and fomratted like the existing ones.
Thanks for the code review! really appreciate it. I already finish the code and the api doc example, Could you review it again |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6711 +/- ##
==========================================
+ Coverage 79.70% 79.75% +0.04%
==========================================
Files 232 232
Lines 17329 17401 +72
==========================================
+ Hits 13812 13878 +66
- Misses 3517 3523 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Please see python/README.md for |
…rent activation groups and fix the related assertion.
All set |
Why are these changes needed?
When the GraphFlowManager encounters cycles, it tracks remaining indegree counts for the node's activation. However, this tracking mechanism has a flaw when dealing with cycles. When a node first enters a cycle, the GraphFlowManager evaluates all remaining incoming edges, including those that loop back to the origin node. If the activation prerequisites are not satisfied at that moment, the workflow will eventually finish because the _remaining counter never reaches zero, preventing the select_speaker() method from selecting any agents for execution.
change activation map to 2 layer for ditinguish remaining inside different cycle and outside the cycle.
add a activation group and policy property for edge, compute the remaining map when GraphFlowManager is init and check the remaining map with activation group to avoid checking the loop back edges
Related issue number
#6710
Checks