{"record":{"id":"10db48cec8320eb0","repo":"microsoft/autogen","slug":"participant-participant-must-be-a-chatagent-10db48","errorCode":null,"errorMessage":"Participant {participant} must be a ChatAgent.","messagePattern":"Participant (.+?) must be a ChatAgent\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_group_chat.py","lineNumber":126,"sourceCode":"\n    def __init__(\n        self,\n        participants: List[ChatAgent],\n        model_client: ChatCompletionClient,\n        *,\n        name: str | None = None,\n        description: str | None = None,\n        termination_condition: TerminationCondition | None = None,\n        max_turns: int | None = 20,\n        runtime: AgentRuntime | None = None,\n        max_stalls: int = 3,\n        final_answer_prompt: str = ORCHESTRATOR_FINAL_ANSWER_PROMPT,\n        custom_message_types: List[type[BaseAgentEvent | BaseChatMessage]] | None = None,\n        emit_team_events: bool = False,\n    ):\n        for participant in participants:\n            if not isinstance(participant, ChatAgent):\n                raise TypeError(f\"Participant {participant} must be a ChatAgent.\")\n        super().__init__(\n            name=name or self.DEFAULT_NAME,\n            description=description or self.DEFAULT_DESCRIPTION,\n            participants=list(participants),\n            group_chat_manager_name=\"MagenticOneOrchestrator\",\n            group_chat_manager_class=MagenticOneOrchestrator,\n            termination_condition=termination_condition,\n            max_turns=max_turns,\n            runtime=runtime,\n            custom_message_types=custom_message_types,\n            emit_team_events=emit_team_events,\n        )\n\n        # Validate the participants.\n        if len(participants) == 0:\n            raise ValueError(\"At least one participant is required for MagenticOneGroupChat.\")\n        self._model_client = model_client\n        self._max_stalls = max_stalls","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_group_chat.py#L108-L144","documentation":"MagenticOneGroupChat.__init__ raises TypeError when any participant is not an instance of ChatAgent. MagenticOne's orchestrator drives individual agents only, so nested teams or arbitrary Team instances are rejected at construction time.","triggerScenarios":"Passing a Team (e.g. RoundRobinGroupChat or another MagenticOneGroupChat), a custom BaseAgent subclass, or any non-ChatAgent object in the participants list to MagenticOneGroupChat(participants=[...]).","commonSituations":"Trying to compose MagenticOne with a sub-team the way GraphFlow or SelectorGroupChat allow; passing autogen_core agents directly instead of autogen_agentchat AssistantAgent instances.","solutions":["Flatten the team: replace each nested Team with its own ChatAgent participants.","Use a composition primitive that supports teams (e.g. GraphFlow with DiGraphBuilder) instead of nesting inside MagenticOneGroupChat.","Type-check participants before construction: all(isinstance(p, ChatAgent) for p in participants)."],"exampleFix":"# before\nteam = MagenticOneGroupChat(\n    participants=[assistant, RoundRobinGroupChat(participants=[coder, reviewer])],  # TypeError\n    model_client=client,\n)\n\n# after\nteam = MagenticOneGroupChat(\n    participants=[assistant, coder, reviewer],\n    model_client=client,\n)","handlingStrategy":"type-guard","validationCode":"from autogen_agentchat.agents import ChatAgent\nassert all(isinstance(p, ChatAgent) for p in participants), \"MagenticOne requires ChatAgent participants\"","typeGuard":"from autogen_agentchat.agents import ChatAgent\n\ndef is_chat_agents(participants: Sequence[object]) -> bool:\n    return all(isinstance(p, ChatAgent) for p in participants)","tryCatchPattern":"try:\n    team = MagenticOneGroupChat(participants=participants, model_client=client)\nexcept TypeError as e:\n    raise TypeError(f\"Bad participants for MagenticOne: {e}. Flatten nested teams.\") from e","preventionTips":["Do not nest Teams inside MagenticOneGroupChat; use GraphFlow for team composition.","Type-hint your builder functions with list[ChatAgent] to catch this statically."],"tags":["autogen","magentic-one","participants","type-error"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}