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 60f222912387..5bc86ff5eebe 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 @@ -78,8 +78,17 @@ def __init__( ): self._name = name self._description = description + if participants is None: + raise TypeError("participants must be a non-empty sequence of ChatAgent or Team instances.") + if not isinstance(participants, (list, tuple)): + raise TypeError("participants must be a list or tuple of ChatAgent or Team instances.") if len(participants) == 0: raise ValueError("At least one participant is required.") + for i, participant in enumerate(participants): + if not isinstance(participant, (ChatAgent, Team)): + raise TypeError( + f"participants[{i}] must be a ChatAgent or Team instance, got {type(participant).__name__}." + ) if len(participants) != len(set(participant.name for participant in participants)): raise ValueError("The participant names must be unique.") self._participants = participants