-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix GraphFlowManager termination to prevent _StopAgent from polluting conversation context #6752
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Copilot
AI
changed the title
[WIP]
Fix GraphFlowManager termination to prevent _StopAgent from polluting conversation context
Jul 6, 2025
GraphFlowManager should not let _StopAgent speak and apply termination if no more ready agent
Copilot finished work on behalf of
ekzhu
July 6, 2025 07:12
ekzhu
reviewed
Jul 6, 2025
...ages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_graph/_digraph_group_chat.py
Outdated
Show resolved
Hide resolved
… in select_speaker Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Copilot finished work on behalf of
ekzhu
July 6, 2025 07:28
ekzhu
requested changes
Jul 6, 2025
...ages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_graph/_digraph_group_chat.py
Show resolved
Hide resolved
...ages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_graph/_digraph_group_chat.py
Show resolved
Hide resolved
- Prioritize graph completion check before standard termination conditions - Properly reset termination conditions and turn count when graph completes - Fix whitespace in docstring to satisfy linting Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Copilot finished work on behalf of
ekzhu
July 6, 2025 07:37
ekzhu
approved these changes
Jul 6, 2025
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6752 +/- ##
==========================================
- Coverage 80.27% 80.26% -0.02%
==========================================
Files 232 232
Lines 17651 17641 -10
==========================================
- Hits 14170 14160 -10
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:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The
GraphFlowManagerwas allowing_StopAgentto speak and add termination messages to the conversation context, which polluted the message history that other agents could see. This violated the principle of clean agent interactions.Before this fix:
After this fix:
Solution
_StopAgententirely - No longer added to participants listGraphFlowManager.select_speaker()- Directly signals termination whenself._readyis empty instead of selecting stop agentGraphFlowconstructor - RemovedStopMessageTerminationand stop agent logicKey Changes
GraphFlowManager.select_speaker(): Now handles termination directly when no ready agents remainGraphFlow.__init__(): No longer adds_StopAgentto participants or usesStopMessageTermination_StopAgentclass and cleaned up importsBenefits
✅ Clean conversation context - No stop agent messages pollute agent contexts
✅ Same termination behavior - Graph execution still stops correctly when complete
✅ Preserved functionality - All existing features work exactly the same
✅ Better performance - One fewer participant to manage
✅ Cleaner codebase - Removed unnecessary
_StopAgentcomplexityVerification
Created comprehensive tests that verify:
StopMessageinstances appear in conversation historyFixes #6751.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.