-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix GraphFlow to support multiple task execution without explicit reset #6747
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
Conversation
Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
|
@copilot we should not clear the message thread upon termination to retain the mesasge history. Also, can you refactor GraphFlowManager so the execution state reset code is separated into a private method and reused. |
…et logic Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Done! I've made both changes:
The message thread history is now preserved while only the graph execution state (ready queue, remaining counters, etc.) gets reset between tasks. Commit: 39aa458 |
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.
Add a unit test to verify if GraphFlow can be resumed with the same graph execution state it left off when a termination condition is reached. I.e.,
- create a graph flow, add a termination condition e.g., MaxMessageTermination
- run the graph flow and observe the termination condition reached
- resume the graph flow with no task to observe the execution state was kept and continue where it was left off.
...ages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_graph/_digraph_group_chat.py
Outdated
Show resolved
Hide resolved
Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Added the unit test
Commit: 08e297b |
...ages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_graph/_digraph_group_chat.py
Outdated
Show resolved
Hide resolved
...ages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_graph/_digraph_group_chat.py
Outdated
Show resolved
Hide resolved
… select_speaker Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6747 +/- ##
=======================================
Coverage 80.27% 80.27%
=======================================
Files 232 232
Lines 17648 17651 +3
=======================================
+ Hits 14167 14170 +3
Misses 3481 3481
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:
|
Problem
When using GraphFlow with a termination condition, the second task execution would immediately terminate without running any agents. The first task would run successfully, but subsequent tasks would skip all agents and go directly to the stop agent.
This was demonstrated by the following issue:
Root Cause
The
GraphFlowManagerwas not resetting its execution state when termination occurred. After the first task completed:_readyqueue was empty (all nodes had been processed)_remainingand_enqueued_anytracking structures remained in "completed" state_message_threadretained history from the previous taskThis left the graph in a "completed" state, causing subsequent tasks to immediately trigger the stop agent instead of executing the workflow.
Solution
Added an override of the
_apply_termination_conditionmethod inGraphFlowManagerto automatically reset the graph execution state when termination occurs:This ensures that when a task completes (termination condition is met), the graph is automatically reset to its initial state ready for the next task.
Testing
Added a comprehensive test case
test_digraph_group_chat_multiple_task_executionthat validates:Result
GraphFlow now works like SelectorGroupChat where multiple tasks can be run sequentially without explicit resets between them:
Fixes #6746.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com/usr/lib/apt/methods/https(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.