microsoft/autogen · error · TypeError

Participant {participant} must be a ChatAgent.

Error message

Participant {participant} must be a ChatAgent.

What it means

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.

Source

Thrown at python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_magentic_one/_magentic_one_group_chat.py:126

    def __init__(
        self,
        participants: List[ChatAgent],
        model_client: ChatCompletionClient,
        *,
        name: str | None = None,
        description: str | None = None,
        termination_condition: TerminationCondition | None = None,
        max_turns: int | None = 20,
        runtime: AgentRuntime | None = None,
        max_stalls: int = 3,
        final_answer_prompt: str = ORCHESTRATOR_FINAL_ANSWER_PROMPT,
        custom_message_types: List[type[BaseAgentEvent | BaseChatMessage]] | None = None,
        emit_team_events: bool = False,
    ):
        for participant in participants:
            if not isinstance(participant, ChatAgent):
                raise TypeError(f"Participant {participant} must be a ChatAgent.")
        super().__init__(
            name=name or self.DEFAULT_NAME,
            description=description or self.DEFAULT_DESCRIPTION,
            participants=list(participants),
            group_chat_manager_name="MagenticOneOrchestrator",
            group_chat_manager_class=MagenticOneOrchestrator,
            termination_condition=termination_condition,
            max_turns=max_turns,
            runtime=runtime,
            custom_message_types=custom_message_types,
            emit_team_events=emit_team_events,
        )

        # Validate the participants.
        if len(participants) == 0:
            raise ValueError("At least one participant is required for MagenticOneGroupChat.")
        self._model_client = model_client
        self._max_stalls = max_stalls

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Flatten the team: replace each nested Team with its own ChatAgent participants.
  2. Use a composition primitive that supports teams (e.g. GraphFlow with DiGraphBuilder) instead of nesting inside MagenticOneGroupChat.
  3. Type-check participants before construction: all(isinstance(p, ChatAgent) for p in participants).

Example fix

# before
team = MagenticOneGroupChat(
    participants=[assistant, RoundRobinGroupChat(participants=[coder, reviewer])],  # TypeError
    model_client=client,
)

# after
team = MagenticOneGroupChat(
    participants=[assistant, coder, reviewer],
    model_client=client,
)
Defensive patterns

Strategy: type-guard

Validate before calling

from autogen_agentchat.agents import ChatAgent
assert all(isinstance(p, ChatAgent) for p in participants), "MagenticOne requires ChatAgent participants"

Type guard

from autogen_agentchat.agents import ChatAgent

def is_chat_agents(participants: Sequence[object]) -> bool:
    return all(isinstance(p, ChatAgent) for p in participants)

Try / catch

try:
    team = MagenticOneGroupChat(participants=participants, model_client=client)
except TypeError as e:
    raise TypeError(f"Bad participants for MagenticOne: {e}. Flatten nested teams.") from e

Prevention

When it happens

Trigger: 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=[...]).

Common situations: 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.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/10db48cec8320eb0. Report an issue: GitHub.