{"record":{"id":"36b9de67d4021e93","repo":"microsoft/autogen","slug":"the-participant-names-must-be-unique","errorCode":null,"errorMessage":"The participant names must be unique.","messagePattern":"The participant names must be unique\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py","lineNumber":84,"sourceCode":"    def __init__(\n        self,\n        name: str,\n        description: str,\n        participants: List[ChatAgent | Team],\n        group_chat_manager_name: str,\n        group_chat_manager_class: type[SequentialRoutedAgent],\n        termination_condition: TerminationCondition | None = None,\n        max_turns: int | None = None,\n        runtime: AgentRuntime | None = None,\n        custom_message_types: List[type[BaseAgentEvent | BaseChatMessage]] | None = None,\n        emit_team_events: bool = False,\n    ):\n        self._name = name\n        self._description = description\n        if len(participants) == 0:\n            raise ValueError(\"At least one participant is required.\")\n        if len(participants) != len(set(participant.name for participant in participants)):\n            raise ValueError(\"The participant names must be unique.\")\n        self._participants = participants\n        self._base_group_chat_manager_class = group_chat_manager_class\n        self._termination_condition = termination_condition\n        self._max_turns = max_turns\n        self._message_factory = MessageFactory()\n        if custom_message_types is not None:\n            for message_type in custom_message_types:\n                self._message_factory.register(message_type)\n\n        for agent in participants:\n            if isinstance(agent, ChatAgent):\n                for message_type in agent.produced_message_types:\n                    try:\n                        is_registered = self._message_factory.is_registered(message_type)  # type: ignore[reportUnknownArgumentType]\n                        if issubclass(message_type, StructuredMessage) and not is_registered:\n                            self._message_factory.register(message_type)  # type: ignore[reportUnknownArgumentType]\n                    except TypeError:\n                        # Not a class or not a valid subclassable type (skip)","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py#L66-L102","documentation":"Participant names must be unique inside a group chat team because names are used as topic types and message-routing keys. A duplicate name would make message delivery ambiguous, so the constructor rejects it immediately.","triggerScenarios":"Passing two agents constructed with the same name: AssistantAgent(\"assistant\", ...) twice, or an agent named identically to a nested Team participant. The constructor compares len(participants) against the set of participant.name values.","commonSituations":"Agents created in loops with template names (agent_0 style) where the index was lost; copying example code twice; a nested team whose internal name collides with a top-level agent.","solutions":["Give each agent/team a distinct name: AssistantAgent(\"coder\"), AssistantAgent(\"reviewer\").","If generating in a loop, suffix with the index: AssistantAgent(f\"worker_{i}\").","Add a pre-construction check: names = [p.name for p in participants]; assert len(names) == len(set(names))."],"exampleFix":"# before\nteam = SelectorGroupChat([AssistantAgent(\"agent\"), AssistantAgent(\"agent\")])\n\n# after\nteam = SelectorGroupChat([AssistantAgent(\"researcher\"), AssistantAgent(\"coder\")])","handlingStrategy":"validation","validationCode":"names = [p.name for p in participants]\nif len(names) != len(set(names)):\n    dupes = {n for n in names if names.count(n) > 1}\n    raise ValueError(f\"duplicate participant names: {dupes}\")\nteam = RoundRobinGroupChat(participants)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate agent names with an index or role suffix in loops: f\"worker_{i}\".","Add a pre-construction uniqueness assertion in code that builds teams from config.","Remember nested Teams participate in the same namespace."],"tags":["python","autogen","group-chat","naming","validation"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}