-
Notifications
You must be signed in to change notification settings - Fork 799
[BREAKING] Python: Standardize orchestration outputs as list of ChatMessage. Allow agent as group chat manager. #2291
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?
Conversation
…tions to group chat prompt manager
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 standardizes orchestration outputs in the Python agent framework to consistently return list[ChatMessage] instead of a single ChatMessage. Previously, group chat and magentic orchestrations returned a single message while other orchestrations (sequential, concurrent, handoff) returned lists, creating inconsistency. The PR also adds the ability to configure ChatOptions for the group chat prompt-based manager, allowing fine-tuned control over LLM parameters like temperature and seed for reproducible manager decisions.
Key changes:
- Group chat and magentic orchestrations now yield the full conversation history as
list[ChatMessage]instead of just the final message - Added
chat_optionsparameter toGroupChatBuilder.set_prompt_based_manager()and_PromptBasedGroupChatManager - Updated all tests and samples to handle the new list output format
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| python/uv.lock | Version bump for ag-ui package |
| python/samples/semantic-kernel-migration/orchestrations/group_chat.py | Updated to handle both list and single message outputs for migration compatibility |
| python/samples/getting_started/workflows/orchestration/group_chat_with_chat_options.py | New sample demonstrating ChatOptions configuration for prompt-based manager |
| python/samples/getting_started/workflows/orchestration/group_chat_simple_selector.py | Updated to iterate over full conversation list instead of single message |
| python/samples/getting_started/workflows/orchestration/group_chat_prompt_based_manager.py | Updated to display full conversation history instead of single response |
| python/samples/getting_started/workflows/README.md | Added entry for new ChatOptions sample |
| python/packages/core/tests/workflow/test_magentic.py | Updated assertions to expect list output and verify conversation structure |
| python/packages/core/tests/workflow/test_group_chat.py | Updated test expectations for list outputs and added test for chat_options passthrough |
| python/packages/core/agent_framework/_workflows/_magentic.py | Changed output type from ChatMessage to list[ChatMessage], yields full conversation with final answer |
| python/packages/core/agent_framework/_workflows/_group_chat.py | Added chat_options support to prompt manager, changed yield_output to return full conversation list |
python/samples/getting_started/workflows/orchestration/group_chat_with_chat_options.py
Outdated
Show resolved
Hide resolved
python/samples/semantic-kernel-migration/orchestrations/group_chat.py
Outdated
Show resolved
Hide resolved
python/samples/getting_started/workflows/orchestration/group_chat_philosophical_debate.py
Outdated
Show resolved
Hide resolved
eavanvalkenburg
left a comment
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.
Approved with one small comment on the add_manager method
python/samples/getting_started/workflows/orchestration/group_chat_agent_manager.py
Show resolved
Hide resolved
| ) | ||
| return ChatMessage(role=Role.SYSTEM, text=context_text) | ||
|
|
||
| def _parse_manager_selection(self, response: AgentExecutorResponse) -> ManagerSelectionResponse: |
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.
Is this making an implicit assumption that the agent is configured to output ManagerSelectionResponse? If so, is it possible to make a requirement on the manger that it must output a structured output and the type must be ManagerSelectionResponse?
| manager: Manager callable for orchestration decisions (used by select_speakers) | ||
| manager_participant: Manager agent/executor instance (used by set_manager) |
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.
nit: more comments on the differences between the two and when to use which.
question: what happens if both are specified?
| GroupChat coordinates multi-agent conversations using a manager that selects which participant | ||
| speaks next. The manager can be a simple Python function (select_speakers) or an LLM-based | ||
| selector (set_prompt_based_manager). These two approaches are mutually exclusive. | ||
| speaks next. The manager can be a simple Python function (:py:meth:`GroupChatBuilder.select_speakers`) |
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.
nit: maybe set_select_speakers_func instead of select_speakers on the builder?
| self._manager: _GroupChatManagerFn | None = None | ||
| self._manager_participant: AgentProtocol | Executor | None = None |
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.
nit: is it possible to have
manager: _GroupChatManagerFn | AgentProtocol | Executor?
Motivation and Context
Currently there is a divergence in the types returned from some orchestrations - for example, group chat/magentic return a ChatMessage versus others (sequential, concurrent, handoff) return a list[ChatMessage]. To standardize, also to what an agent can return, we're adjusting the output for group chat/magentic to be a list[ChatMessage].
Additionally, for a group chat, when configuring a manager, allow for the use of an Agent or an Executor. The underlying group chat architecture was refactored to allow for the agent / executor manager to actually be a node in the group chat graph in place of the previous PromptManager class.
Caution
This is a breaking change. Will hold this PR until after Ignite.
Description
Closes: #2272, #2228, #2350
Contribution Checklist