{"record":{"id":"fbee4c870c93ac0b","repo":"microsoft/semantic-kernel","slug":"no-serializers-found-for-type-t","errorCode":null,"errorMessage":"No serializers found for type {t}.","messagePattern":"No serializers found for type (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/runtime/core/routed_agent.py","lineNumber":524,"sourceCode":"            if callable(getattr(cls, attr, None)):\n                # Since we are getting it from the class, self is not bound\n                handler = getattr(cls, attr)\n                if hasattr(handler, \"is_message_handler\"):\n                    handlers.append(cast(MessageHandler[Any, Any, Any], handler))\n        return handlers\n\n    @classmethod\n    def _handles_types(cls) -> list[tuple[type[Any], list[MessageSerializer[Any]]]]:\n        # TODO(evmattso): handle deduplication\n        handlers = cls._discover_handlers()\n        types: list[tuple[type[Any], list[MessageSerializer[Any]]]] = []\n        types.extend(cls.internal_extra_handles_types)\n        for handler in handlers:\n            for t in handler.target_types:\n                # TODO(evmattso): support different serializers\n                serializers = try_get_known_serializers_for_type(t)\n                if len(serializers) == 0:\n                    raise ValueError(f\"No serializers found for type {t}.\")\n\n                types.append((t, try_get_known_serializers_for_type(t)))\n        return types\n\n\n# endregion\n","sourceCodeStart":506,"sourceCodeEnd":531,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/runtime/core/routed_agent.py#L506-L531","documentation":"Raised when a RoutedAgent is registered. _handles_types() discovers each handler's target_types and calls try_get_known_serializers_for_type(t), which only knows three families: Pydantic BaseModel, dataclass, and protobuf Message subclasses. If a handler declares a target type outside those families, no serializer is found and ValueError is raised, blocking registration.","triggerScenarios":"An @rpc/@event/@message_handler whose 'message' annotation is a plain class, TypedDict, namedtuple, Enum, primitive (int/str), or any non-{BaseModel, dataclass, protobuf} type, and the agent is then registered with the runtime (which triggers _handles_types).","commonSituations":"Using a TypedDict or a vanilla class as a message; using an Enum or a primitive; forgetting to make the message a dataclass/pydantic model; using a third-party non-serializable type.","solutions":["Make the message type a Pydantic BaseModel, a dataclass, or a protobuf Message subclass.","Or register a custom MessageSerializer and add it to the registry / the agent's internal_extra_handles_types.","If using inheritance, ensure the concrete declared type is itself one of the three supported families."],"exampleFix":"// before\nclass MyMessage:  # plain class -> no serializer\n    ...\n\n@rpc\nasync def handle(self, message: MyMessage, ctx: MessageContext) -> None: ...\n\n// after\nfrom pydantic import BaseModel\n\nclass MyMessage(BaseModel):\n    ...\n\n@rpc\nasync def handle(self, message: MyMessage, ctx: MessageContext) -> None: ...","handlingStrategy":"validation","validationCode":"import dataclasses\nfrom pydantic import BaseModel\nfrom google.protobuf.message import Message\nfrom semantic_kernel.agents.runtime.core.serialization import try_get_known_serializers_for_type\n\ndef has_serializer(t: type) -> bool:\n    return len(try_get_known_serializers_for_type(t)) > 0","typeGuard":"def is_serializable_message(t: type) -> bool:\n    return isinstance(t, type) and (\n        issubclass(t, BaseModel) or dataclasses.is_dataclass(t) or issubclass(t, Message)\n    )","tryCatchPattern":null,"preventionTips":["Make every message type a Pydantic model, dataclass, or protobuf Message.","Register custom serializers for any type outside the three supported families.","Call try_get_known_serializers_for_type in tests before registering an agent."],"tags":["serialization","message-type","registration","agent"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}