-
Notifications
You must be signed in to change notification settings - Fork 7k
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 |
|
||
# Should have exactly one task message (from the outer level) | ||
assert len(task_messages_in_soma) == 1 | ||
assert len(inner_task_messages_in_soma) == 1 |
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 test description indicates that inner task messages should not be forwarded, but this assertion expects one inner task message. Adjust the expected count to 0 or update the assertion to match the intended behavior.
assert len(inner_task_messages_in_soma) == 1 | |
assert len(inner_task_messages_in_soma) == 0 |
Copilot uses AI. Check for mistakes.
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 have solved the issue.
# Skip adding task messages to output_messages again if they were already added initially | ||
if output_task_messages and received_messages_count < task_messages_count: | ||
received_messages_count += 1 | ||
yield message |
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.
This block yields the same task messages a second time when output_task_messages
is true, causing duplicates. Remove the redundant yield message
to prevent duplicate streaming of task messages.
yield message |
Copilot uses AI. Check for mistakes.
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 have solved the issue.
@@ -263,21 +263,22 @@ async def test_round_robin_group_chat(runtime: AgentRuntime | None) -> None: | |||
|
|||
# Test streaming. | |||
model_client.reset() | |||
index = 0 | |||
stream_index = 0 |
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.
[nitpick] The variable stream_index
is introduced but never used. Consider removing it to reduce noise and improve readability.
stream_index = 0 |
Copilot uses AI. Check for mistakes.
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 have solved the issue.
…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.
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