-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Fix output task messages 6150 #6678
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?
Fix output task messages 6150 #6678
Conversation
…on guide- Fix version format from 0.4.0-dev-1 to 0.4.0-dev.1 for all packages- Remove reference to non-existent Microsoft.AutoGen.Extensions package- Add correct extension packages: Aspire, MEAI, and SemanticKernel- Fix typo: RuntimeGatewway -> RuntimeGateway- Improve documentation structure with clear section headersFixes microsoft#6244
Fix issue microsoft#6277 where TextMessage was used but not imported in three code cells of the custom agents documentation, causing NameError when users run the examples. Changes: - Add TextMessage to imports in ArithmeticAgent section - Add TextMessage to imports in GeminiAssistantAgent section - Add TextMessage to imports in Declarative GeminiAssistantAgent section The CountDownAgent section already had the correct import. Fixes microsoft#6277
…ic in run_stream. Replaces brittle count-based task message filtering with explicit output_task_messages parameter. Enables proper SocietyOfMindAgent encapsulation while maintaining backward compatibility.
- Set output_task_messages default to False for backward compatibility - Fix duplicate task message logic in base_group_chat.py - Update 20+ streaming tests to handle task message offset - Correct protocol definition in _task.py All test suites now pass (165 tests). Fixes regression from previous commit.
@tejas-dharani ,
There is a chance that future PRs that do not follow the above might be closed without review. |
Hi @victordibia, Separate branches: Created individual branches for each issue Appreciate the guidance on the workflow! |
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 PR replaces brittle count-based logic for filtering task messages in streaming methods with an explicit output_task_messages
parameter, making message inclusion more robust across varying team structures.
- Added
output_task_messages
flag torun_stream
in team, task, and agent implementations - Updated SocietyOfMindAgent and BaseChatAgent to leverage the new flag
- Revised tests and documentation to align with the new parameter behavior
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/custom-agents.ipynb | Imported TextMessage for examples |
python/packages/autogen-agentchat/tests/test_society_of_mind_agent.py | Added tests for output_task_messages parameter and its default behavior |
python/packages/autogen-agentchat/tests/test_group_chat.py | Adjusted result indexing to skip task messages in streams |
python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py | Introduced output_task_messages parameter and message filtering logic |
python/packages/autogen-agentchat/src/autogen_agentchat/base/_task.py | Documented output_task_messages argument in run_stream |
python/packages/autogen-agentchat/src/autogen_agentchat/agents/_society_of_mind_agent.py | Updated inner team calls to use output_task_messages=False |
python/packages/autogen-agentchat/src/autogen_agentchat/agents/_base_chat_agent.py | Added output_task_messages argument and conditional yields |
docs/dotnet/core/installation.md | Updated .NET package versions and added extension package listings |
python/packages/autogen-agentchat/tests/test_society_of_mind_agent.py
Outdated
Show resolved
Hide resolved
python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py
Outdated
Show resolved
Hide resolved
…stallation guide- Fix version format from 0.4.0-dev-1 to 0.4.0-dev.1 for all packages- Remove reference to non-existent Microsoft.AutoGen.Extensions package- Add correct extension packages: Aspire, MEAI, and SemanticKernel- Fix typo: RuntimeGatewway -> RuntimeGateway- Improve documentation structure with clear section headersFixes microsoft#6244" This reverts commit 6d9fb2e.
…tation" This reverts commit d07898b.
Hi @ekzhu Sir, |
@@ -170,19 +177,22 @@ async def run_stream( | |||
text_msg = TextMessage(content=task, source="user") | |||
input_messages.append(text_msg) | |||
output_messages.append(text_msg) | |||
yield text_msg | |||
if output_task_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.
The output_messages should exclude the task messages if the flag is set to False to be consistent.
@@ -319,6 +319,7 @@ async def run_stream( | |||
*, | |||
task: str | BaseChatMessage | Sequence[BaseChatMessage] | None = None, | |||
cancellation_token: CancellationToken | None = None, | |||
output_task_messages: bool = False, |
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.
Default should be True
@@ -39,6 +39,7 @@ def run_stream( | |||
*, | |||
task: str | BaseChatMessage | Sequence[BaseChatMessage] | None = None, | |||
cancellation_token: CancellationToken | None = None, | |||
output_task_messages: bool = False, |
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.
Default is True.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6678 +/- ##
==========================================
+ Coverage 79.73% 83.64% +3.90%
==========================================
Files 232 67 -165
Lines 17403 3613 -13790
==========================================
- Hits 13877 3022 -10855
+ Misses 3526 591 -2935
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:
|
Why are these changes needed?
The existing run_stream methods used fragile count-based logic (count <= len(task)) to skip task messages during streaming. This approach was brittle and broke when team structure changed or task composition varied, particularly affecting SocietyOfMindAgent's ability to properly encapsulate inner team messages.
This PR adds an output_task_messages parameter to run_stream methods to provide explicit control over task message inclusion in streams, replacing the fragile count-based logic with robust message filtering.
Related issue number
Closes #6150
Checks