microsoft/autogen · critical · ValueError

No serializers found for type {t}.

Error message

No serializers found for type {t}.

What it means

RoutedAgent._handles_types() walks every handler's target types and calls try_get_known_serializers_for_type for each; if no serializer can be found for a type, ValueError is raised when the agent's type metadata is built (typically at runtime/agent-type registration, blocking startup). This means the annotated message class is neither a supported serializable model nor one with a registered serializer.

Source

Thrown at python/packages/autogen-core/src/autogen_core/_routed_agent.py:515

            if callable(getattr(cls, attr, None)):
                # Since we are getting it from the class, self is not bound
                handler = getattr(cls, attr)
                if hasattr(handler, "is_message_handler"):
                    handlers.append(cast(MessageHandler[Any, Any, Any], handler))
        return handlers

    @classmethod
    def _handles_types(cls) -> List[Tuple[Type[Any], List[MessageSerializer[Any]]]]:
        # TODO handle deduplication
        handlers = cls._discover_handlers()
        types: List[Tuple[Type[Any], List[MessageSerializer[Any]]]] = []
        types.extend(cls.internal_extra_handles_types)
        for handler in handlers:
            for t in handler.target_types:
                # TODO: support different serializers
                serializers = try_get_known_serializers_for_type(t)
                if len(serializers) == 0:
                    raise ValueError(f"No serializers found for type {t}.")

                types.append((t, try_get_known_serializers_for_type(t)))
        return types

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Define message types as pydantic BaseModel subclasses (pydantic-based serialization is auto-detected)
  2. If the type cannot be a BaseModel, register a serializer for it (e.g. a MessageSerializer implementation added to the type registry / try_get_known_serializers_for_type path) before creating the agent runtime
  3. Remove non-message types (str, int, helper classes) accidentally included in the handler's message annotation union

Example fix

# before
@rpc
async def handle(self, message: AskDict, ctx: MessageContext) -> None: ...  # AskDict is a TypedDict

# after
from pydantic import BaseModel

class Ask(BaseModel):
    query: str

@rpc
async def handle(self, message: Ask, ctx: MessageContext) -> None: ...
Defensive patterns

Strategy: validation

Validate before calling

from pydantic import BaseModel
from autogen_core import try_get_known_serializers_for_type

def all_handler_types_serializable(agent_cls) -> bool:
    for t, _ in agent_cls._handles_types():
        pass
    return True  # _handles_types raises ValueError for unserializable types

def type_is_serializable(t: type) -> bool:
    if issubclass(t, BaseModel):
        return True
    return len(try_get_known_serializers_for_type(t)) > 0

Type guard

from pydantic import BaseModel
from autogen_core import try_get_known_serializers_for_type

def has_serializer(t: type) -> bool:
    return issubclass(t, BaseModel) or len(try_get_known_serializers_for_type(t)) > 0

Try / catch

try:
    await runtime.register_agent_type(agent_type)
except ValueError as e:
    if "No serializers found" in str(e):
        # convert the annotated type to a pydantic BaseModel or register a serializer, then retry
        raise

Prevention

When it happens

Trigger: Annotating a handler with a plain Python class, TypedDict, dataclass, or non-pydantic type with no serializer registered; annotating with types from other frameworks; using a type that is pydantic but fails its known-serializer detection.

Common situations: Using dataclasses or TypedDicts instead of pydantic BaseModel for messages; forgetting to register a custom serializer via a serialization registry before constructing/registering the agent runtime; annotating handler parameters with helper or generic types accidentally exposed in a union.

Related errors


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