{"record":{"id":"ba037603a490e872","repo":"microsoft/semantic-kernel","slug":"agent-type-recipient-type-does-not-exist","errorCode":null,"errorMessage":"Agent type '{recipient.type}' does not exist.","messagePattern":"Agent type '(.+?)' does not exist\\.","errorType":"exception","errorClass":"LookupError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/runtime/in_process/in_process_runtime.py","lineNumber":349,"sourceCode":"        provided in the dictionary. The keys of the dictionary are the agent IDs, and the values are the state\n        dictionaries returned by the :meth:`~agent_runtime.BaseAgent.save_state` method.\n\n        .. note::\n\n            This method does not currently load the subscription state. We will add this in the future.\n\n        \"\"\"\n        for agent_id_str in state:\n            agent_id = CoreAgentId.from_str(agent_id_str)\n            if agent_id.type in self._known_agent_names:\n                await (await self._get_agent(agent_id)).load_state(state[str(agent_id)])\n\n    async def _process_send(self, message_envelope: SendMessageEnvelope) -> None:\n        with self._tracer_helper.trace_block(\"send\", message_envelope.recipient, parent=message_envelope.metadata):\n            recipient = message_envelope.recipient\n\n            if recipient.type not in self._known_agent_names:\n                raise LookupError(f\"Agent type '{recipient.type}' does not exist.\")\n\n            try:\n                sender_id = str(message_envelope.sender) if message_envelope.sender is not None else \"Unknown\"\n                logger.info(\n                    f\"Calling message handler for {recipient} with message type \"\n                    f\"{type(message_envelope.message).__name__} sent by {sender_id}\"\n                )\n                event_logger.info(\n                    MessageEvent(\n                        payload=self._try_serialize(message_envelope.message),\n                        sender=message_envelope.sender,\n                        receiver=recipient,\n                        kind=MessageKind.DIRECT,\n                        delivery_stage=DeliveryStage.DELIVER,\n                    )\n                )\n                recipient_agent = await self._get_agent(recipient)\n","sourceCodeStart":331,"sourceCodeEnd":367,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/runtime/in_process/in_process_runtime.py#L331-L367","documentation":"When the runtime processes a SendMessageEnvelope, it checks whether the recipient's agent type is in _known_agent_names. If the type was never registered (or was registered under a different name string), a LookupError is raised. This is the send-side guard before attempting to invoke the message handler.","triggerScenarios":"Calling runtime.send_message(message, AgentId('UnknownType', 'key')) where 'UnknownType' was never registered via register_factory. Also triggered by a subscription routing a message to an agent type that has no registered factory.","commonSituations":"Typo or case mismatch between the registered type name and the recipient type. Registering a factory under one name but sending to a slightly different name. Using an agent type from a different runtime instance or after the runtime was reset.","solutions":["Verify the recipient type string matches exactly what was passed to register_factory.","Ensure register_factory was called (and completed) before sending messages.","Check for case sensitivity and whitespace in the agent type string.","If using subscriptions, confirm the subscription's agent_type resolves to a registered factory."],"exampleFix":"# before\nawait runtime.register_factory('my_agent', factory)\nawait runtime.send_message(msg, AgentId('MyAgent', 'default'))  # case mismatch\n\n# after\nawait runtime.register_factory('my_agent', factory)\nawait runtime.send_message(msg, AgentId('my_agent', 'default'))","handlingStrategy":"validation","validationCode":"# Before sending, verify the agent type is registered\n# (No public API to check; track registration in your own code)\nregistered_types: set[str] = set()\nasync def safe_register(runtime, type_name, factory):\n    await runtime.register_factory(type_name, factory)\n    registered_types.add(type_name)\n\n# Guard sends:\nif recipient.type not in registered_types:\n    raise ValueError(f'Agent type {recipient.type} not registered')","typeGuard":"null","tryCatchPattern":"try:\n    await runtime.send_message(msg, recipient)\nexcept LookupError:\n    # recipient type not registered\n    await runtime.register_factory(recipient.type, factory)\n    await runtime.send_message(msg, recipient)","preventionTips":["Register all agent factories before starting message flow.","Verify type strings match exactly (case-sensitive) between registration and AgentId construction.","Maintain a registry/set of known types in your application code for pre-send validation."],"tags":["agent-runtime","send-message","agent-type","registration","lookup","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}