{"record":{"id":"9b1aff7de2590624","repo":"microsoft/autogen","slug":"participant-participant-must-be-a-chatagent","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/_graph/_digraph_group_chat.py","lineNumber":800,"sourceCode":"\n    def __init__(\n        self,\n        participants: List[ChatAgent],\n        graph: DiGraph,\n        *,\n        name: str | None = None,\n        description: str | None = None,\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    ) -> None:\n        self._input_participants = participants\n        self._input_termination_condition = termination_condition\n\n        for participant in participants:\n            if not isinstance(participant, ChatAgent):\n                raise TypeError(f\"Participant {participant} must be a ChatAgent.\")\n\n        # No longer add _StopAgent or StopMessageTermination\n        # Termination is now handled directly in GraphFlowManager._apply_termination_condition\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=\"GraphManager\",\n            group_chat_manager_class=GraphFlowManager,\n            termination_condition=termination_condition,\n            max_turns=max_turns,\n            runtime=runtime,\n            custom_message_types=custom_message_types,\n        )\n        self._graph = graph\n\n    def _create_group_chat_manager_factory(\n        self,","sourceCodeStart":782,"sourceCodeEnd":818,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_graph/_digraph_group_chat.py#L782-L818","documentation":"Raised by GraphFlow.__init__ (TypeError) when a participant is not a ChatAgent instance. Graph flow nodes must be individual chat agents — a nested Team, a runtime agent, or any other object is rejected, unlike Selector/Swarm teams which can nest teams inside a container.","triggerScenarios":"Passing a RoundRobinGroupChat/SelectorGroupChat/other Team in the participants list of GraphFlow; passing an autogen_core agent (not agentchat ChatAgent); passing None or a plain object from a misbuilt config.","commonSituations":"Trying to compose hierarchical multi-team workflows with GraphFlow; migrating from another team type where nesting was allowed; dynamically loading 'agents' from config where one entry resolves to a Team.","solutions":["Flatten the nested team: register its member agents directly as graph participants and express the inner team's sequencing as graph edges.","Or use SelectorGroupChat/Swarm if nesting teams inside participants is a hard requirement.","Type-check participants before construction (see validation code) for config-driven setups."],"exampleFix":"// before\ninner = RoundRobinGroupChat([a, b])\nflow = GraphFlow([inner, c])  # TypeError\n\n// after\nflow = GraphFlow([a, b, c])  # model the inner team's order as edges\nbuilder.add_edge(a, b); builder.add_edge(b, c)","handlingStrategy":"type-guard","validationCode":"from autogen_agentchat.base import ChatAgent\nbad = [p for p in participants if not isinstance(p, ChatAgent)]\nif bad:\n    raise TypeError(f\"GraphFlow participants must be ChatAgent, got: {[type(b).__name__ for b in bad]}\")","typeGuard":"from autogen_agentchat.base import ChatAgent, Team\ndef is_flat_chat_agents(participants: Sequence[object]) -> bool:\n    return all(isinstance(p, ChatAgent) and not isinstance(p, Team) for p in participants)","tryCatchPattern":"try:\n    flow = GraphFlow(participants, graph_builder=builder)\nexcept TypeError as e:\n    if \"must be a ChatAgent\" in str(e):\n        # flatten nested teams into their member agents and re-model as graph edges\n        ...","preventionTips":["Use only ChatAgent instances as GraphFlow participants; flatten nested teams into edges.","Use SelectorGroupChat/Swarm when team-in-team nesting is required.","Type-check config-driven participant lists before construction."],"tags":["graph","type-error","participants","api-misuse"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}