A programming framework for agentic AI
Fix Reset of Magentic-One Orchestrator (#4394)
Hussein Mozannar6184e15c5eca
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_group_chat.py b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_group_chat.pyindex d199cbfd7..cd67ced11 100644--- a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_group_chat.py+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_group_chat.py@@ -47,6 +47,7 @@ class MagenticOneGroupChat(BaseGroupChat):return lambda: MagenticOneOrchestrator(group_topic_type,output_topic_type,+ self._team_id,participant_topic_types,participant_descriptions,max_turns,diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_orchestrator.py b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_orchestrator.pyindex ae1567a7d..f69630162 100644--- a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_orchestrator.py+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_orchestrator.py@@ -1,7 +1,7 @@import jsonfrom typing import Any, List-from autogen_core.base import MessageContext+from autogen_core.base import MessageContext, AgentIdfrom autogen_core.components import DefaultTopicId, Image, event, rpcfrom autogen_core.components.models import (AssistantMessage,@@ -42,6 +42,7 @@ class MagenticOneOrchestrator(SequentialRoutedAgent):self,group_topic_type: str,output_topic_type: str,+ team_id: str,participant_topic_types: List[str],participant_descriptions: List[str],max_turns: int | None,@@ -51,6 +52,7 @@ class MagenticOneOrchestrator(SequentialRoutedAgent):super().__init__(description="Group chat manager")self._group_topic_type = group_topic_typeself._output_topic_type = output_topic_type+ self._team_id = team_idif len(participant_topic_types) != len(participant_descriptions):raise ValueError("The number of participant topic types, agent types, and descriptions must be the same.")if len(set(participant_topic_types)) != len(participant_topic_types):@@ -164,10 +166,13 @@ class MagenticOneOrchestrator(SequentialRoutedAgent):async def _reenter_inner_loop(self) -> None:# Reset the agents- await self.publish_message(- GroupChatReset(),- topic_id=DefaultTopicId(type=self._group_topic_type),- )+ for participant_topic_type in self._participant_topic_types:+ await self._runtime.send_message(+ GroupChatReset(),+ recipient=AgentId(type=participant_topic_type, key=self._team_id),+ )+ # Reset the group chat manager+ await self.reset()self._message_thread.clear()# Prepare the ledgerdiff --git a/python/uv.lock b/python/uv.lockindex 9613d7590..2301cfcbd 100644--- a/python/uv.lock+++ b/python/uv.lock@@ -2584,6 +2584,11 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/ba/07/37d67048786ae84e6612575e173d713c9a05d0ae495dde1e68d972207d98/mypy-1.13.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:164f28cb9d6367439031f4c81e84d3ccaa1e19232d9d05d37cb0bd880d3f93c2", size = 12589275 },{ url = "https://files.pythonhosted.org/packages/1f/17/b1018c6bb3e9f1ce3956722b3bf91bff86c1cefccca71cec05eae49d6d41/mypy-1.13.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:a4c1bfcdbce96ff5d96fc9b08e3831acb30dc44ab02671eca5953eadad07d6d0", size = 13037783 },{ url = "https://files.pythonhosted.org/packages/cb/32/cd540755579e54a88099aee0287086d996f5a24281a673f78a0e14dba150/mypy-1.13.0-cp312-cp312-win_amd64.whl", hash = "sha256:a0affb3a79a256b4183ba09811e3577c5163ed06685e4d4b46429a271ba174d2", size = 9726197 },+ { url = "https://files.pythonhosted.org/packages/11/bb/ab4cfdc562cad80418f077d8be9b4491ee4fb257440da951b85cbb0a639e/mypy-1.13.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:a7b44178c9760ce1a43f544e595d35ed61ac2c3de306599fa59b38a6048e1aa7", size = 11069721 },+ { url = "https://files.pythonhosted.org/packages/59/3b/a393b1607cb749ea2c621def5ba8c58308ff05e30d9dbdc7c15028bca111/mypy-1.13.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:5d5092efb8516d08440e36626f0153b5006d4088c1d663d88bf79625af3d1d62", size = 10063996 },+ { url = "https://files.pythonhosted.org/packages/d1/1f/6b76be289a5a521bb1caedc1f08e76ff17ab59061007f201a8a18cc514d1/mypy-1.13.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:de2904956dac40ced10931ac967ae63c5089bd498542194b436eb097a9f77bc8", size = 12584043 },+ { url = "https://files.pythonhosted.org/packages/a6/83/5a85c9a5976c6f96e3a5a7591aa28b4a6ca3a07e9e5ba0cec090c8b596d6/mypy-1.13.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:7bfd8836970d33c2105562650656b6846149374dc8ed77d98424b40b09340ba7", size = 13036996 },+ { url = "https://files.pythonhosted.org/packages/b4/59/c39a6f752f1f893fccbcf1bdd2aca67c79c842402b5283563d006a67cf76/mypy-1.13.0-cp313-cp313-win_amd64.whl", hash = "sha256:9f73dba9ec77acb86457a8fc04b5239822df0c14a082564737833d2963677dbc", size = 9737709 },{ url = "https://files.pythonhosted.org/packages/3b/86/72ce7f57431d87a7ff17d442f521146a6585019eb8f4f31b7c02801f78ad/mypy-1.13.0-py3-none-any.whl", hash = "sha256:9c250883f9fd81d212e0952c92dbfcc96fc237f4b7c92f56ac81fd48460b3e5a", size = 2647043 },]