From 4522900487b65766d0f89dd30b10b6021b45e313 Mon Sep 17 00:00:00 2001 From: afourney Date: Mon, 9 Oct 2023 14:30:20 -0700 Subject: [PATCH] Warn if GroupChat is underpopulatd. (#170) --- autogen/agentchat/groupchat.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/autogen/agentchat/groupchat.py b/autogen/agentchat/groupchat.py index fae72f26ac49..d2f53002b410 100644 --- a/autogen/agentchat/groupchat.py +++ b/autogen/agentchat/groupchat.py @@ -3,6 +3,9 @@ from typing import Dict, List, Optional, Union from .agent import Agent from .conversable_agent import ConversableAgent +import logging + +logger = logging.getLogger(__name__) @dataclass @@ -42,6 +45,14 @@ def select_speaker_msg(self): def select_speaker(self, last_speaker: Agent, selector: ConversableAgent): """Select the next speaker.""" selector.update_system_message(self.select_speaker_msg()) + + # Warn if GroupChat is underpopulated, without established changing behavior + n_agents = len(self.agent_names) + if n_agents < 3: + logger.warning( + f"GroupChat is underpopulated with {n_agents} agents. Direct communication would be more efficient." + ) + final, name = selector.generate_oai_reply( self.messages + [