diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py index 78ec5159e369..e035a9874361 100644 --- a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py +++ b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py @@ -33,7 +33,6 @@ def __init__( self, participants: List[ChatAgent], group_chat_manager_class: type[BaseGroupChatManager], - termination_condition: TerminationCondition | None = None, ): if len(participants) == 0: raise ValueError("At least one participant is required.") @@ -42,7 +41,6 @@ def __init__( self._participants = participants self._team_id = str(uuid.uuid4()) self._base_group_chat_manager_class = group_chat_manager_class - self._termination_condition = termination_condition @abstractmethod def _create_group_chat_manager_factory( @@ -133,7 +131,7 @@ async def run_stream( group_topic_type=group_topic_type, participant_topic_types=participant_topic_types, participant_descriptions=participant_descriptions, - termination_condition=termination_condition or self._termination_condition, + termination_condition=termination_condition, ), ) # Add subscriptions for the group chat manager. diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_round_robin_group_chat.py b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_round_robin_group_chat.py index cec47f6e1b1b..b2dcdb640297 100644 --- a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_round_robin_group_chat.py +++ b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_round_robin_group_chat.py @@ -103,10 +103,9 @@ async def get_weather(location: str) -> str: """ - def __init__(self, participants: List[ChatAgent], termination_condition: TerminationCondition | None = None): + def __init__(self, participants: List[ChatAgent]): super().__init__( participants, - termination_condition=termination_condition, group_chat_manager_class=RoundRobinGroupChatManager, ) diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_selector_group_chat.py b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_selector_group_chat.py index ed7694d38584..d91d89e26a5a 100644 --- a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_selector_group_chat.py +++ b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_selector_group_chat.py @@ -230,9 +230,7 @@ def __init__( """, allow_repeated_speaker: bool = False, ): - super().__init__( - participants, termination_condition=termination_condition, group_chat_manager_class=SelectorGroupChatManager - ) + super().__init__(participants, group_chat_manager_class=SelectorGroupChatManager) # Validate the participants. if len(participants) < 2: raise ValueError("At least two participants are required for SelectorGroupChat.") diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_swarm_group_chat.py b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_swarm_group_chat.py index 0f4ec0e63a48..0afc41afe98b 100644 --- a/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_swarm_group_chat.py +++ b/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_swarm_group_chat.py @@ -85,10 +85,8 @@ class Swarm(BaseGroupChat): print(message) """ - def __init__(self, participants: List[ChatAgent], termination_condition: TerminationCondition | None = None): - super().__init__( - participants, termination_condition=termination_condition, group_chat_manager_class=SwarmGroupChatManager - ) + def __init__(self, participants: List[ChatAgent]): + super().__init__(participants, group_chat_manager_class=SwarmGroupChatManager) # The first participant must be able to produce handoff messages. first_participant = self._participants[0] if HandoffMessage not in first_participant.produced_message_types: diff --git a/python/packages/autogen-agentchat/tests/test_group_chat.py b/python/packages/autogen-agentchat/tests/test_group_chat.py index 4e1485ce3094..72fdc6bcd68a 100644 --- a/python/packages/autogen-agentchat/tests/test_group_chat.py +++ b/python/packages/autogen-agentchat/tests/test_group_chat.py @@ -516,8 +516,8 @@ async def test_swarm_handoff() -> None: second_agent = _HandOffAgent("second_agent", description="second agent", next_agent="third_agent") third_agent = _HandOffAgent("third_agent", description="third agent", next_agent="first_agent") - team = Swarm([second_agent, first_agent, third_agent], termination_condition=MaxMessageTermination(6)) - result = await team.run("task") + team = Swarm([second_agent, first_agent, third_agent]) + result = await team.run("task", termination_condition=MaxMessageTermination(6)) assert len(result.messages) == 6 assert result.messages[0].content == "task" assert result.messages[1].content == "Transferred to third_agent." diff --git a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/quickstart.ipynb b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/quickstart.ipynb index 52f4b1baa914..3c37aee209ef 100644 --- a/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/quickstart.ipynb +++ b/python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/quickstart.ipynb @@ -81,10 +81,11 @@ ")\n", "\n", "# add the agent to a team\n", - "agent_team = RoundRobinGroupChat([weather_agent], termination_condition=MaxMessageTermination(max_messages=2))\n", + "agent_team = RoundRobinGroupChat([weather_agent])\n", "# Note: if running in a Python file directly you'll need to use asyncio.run(agent_team.run(...)) instead of await agent_team.run(...)\n", "result = await agent_team.run(\n", " task=\"What is the weather in New York?\",\n", + " termination_condition=MaxMessageTermination(max_messages=2),\n", ")\n", "print(\"\\n\", result)" ]