microsoft/autogen · error · ValueError

Message type {message.__class__} is not registered.

Error message

Message type {message.__class__} is not registered.

What it means

Raised by ChatAgentContainer._buffer_message when an incoming chat message's class is not registered with the team's MessageFactory. The factory only knows the built-in message types plus any types you declared via custom_message_types when creating the team; any other message type arriving in a participant's buffer (e.g., from the initial task, another agent's output, or a checkpoint replay) is rejected before buffering.

Source

Thrown at python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_chat_agent_container.py:163

                    await self.publish_message(
                        GroupChatAgentResponse(response=response, name=self._agent.name),
                        topic_id=DefaultTopicId(type=self._parent_topic_type),
                        cancellation_token=ctx.cancellation_token,
                    )
                except Exception as e:
                    # Publish the error to the group chat.
                    error_message = SerializableException.from_exception(e)
                    await self.publish_message(
                        GroupChatError(error=error_message),
                        topic_id=DefaultTopicId(type=self._parent_topic_type),
                        cancellation_token=ctx.cancellation_token,
                    )
                    # Raise the error to the runtime.
                    raise

    def _buffer_message(self, message: BaseChatMessage) -> None:
        if not self._message_factory.is_registered(message.__class__):
            raise ValueError(f"Message type {message.__class__} is not registered.")
        # Buffer the message.
        self._message_buffer.append(message)

    async def _log_message(self, message: BaseAgentEvent | BaseChatMessage) -> None:
        if not self._message_factory.is_registered(message.__class__):
            raise ValueError(f"Message type {message.__class__} is not registered.")
        # Log the message.
        await self.publish_message(
            GroupChatMessage(message=message),
            topic_id=DefaultTopicId(type=self._output_topic_type),
        )

    @rpc
    async def handle_pause(self, message: GroupChatPause, ctx: MessageContext) -> None:
        """Handle a pause event by pausing the agent."""
        if isinstance(self._agent, Team):
            # If the agent is a team, pause the team.
            await self._agent.pause()

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Pass your message class in custom_message_types=[MyMessageType] when constructing the team (RoundRobin, Selector, Swarm, MagenticOne, GraphFlow all accept it).
  2. Ensure the custom type subclasses BaseChatMessage (or BaseAgentEvent for events) and implements serialization properly.
  3. On version upgrades, migrate old message_factory-based configuration to custom_message_types.

Example fix

// before
team = SelectorGroupChat(participants, model_client=client)  # MyApproval type unknown
await team.run(task=MyApproval(approved=True))

// after
team = SelectorGroupChat(participants, model_client=client,
    custom_message_types=[MyApproval])
await team.run(task=MyApproval(approved=True))
Defensive patterns

Strategy: type-guard

Validate before calling

from autogen_agentchat.messages import MessageFactory
factory = MessageFactory()
for t in CUSTOM_TYPES:
    factory.register_message_type(t)
assert factory.is_registered(MyApproval), "register MyApproval via custom_message_types"

Type guard

def all_input_types_registered(task_msgs, team_custom_types: set[type]) -> bool:
    return all(type(m) in team_custom_types or type(m).__name__ in BUILTIN_MESSAGE_TYPES for m in task_msgs)

Try / catch

try:
    await team.run(task=my_msg)
except ValueError as e:
    if "is not registered" in str(e):
        # add type(my_msg) to the team's custom_message_types and recreate the team
        ...

Prevention

When it happens

Trigger: Passing a custom BaseChatMessage subclass as the task input to team.run() without listing it in the team's custom_message_types; an agent producing a custom message type the team doesn't know; restoring state containing messages of an unregistered type.

Common situations: Defining domain-specific message classes for structured agent output; switching from passing strings/TextMessage to a custom type; teams created before the custom_message_types parameter existed (older autogen versions used message_factory instead).

Related errors


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