{"record":{"id":"e2ad1ebd793ef5a1","repo":"microsoft/autogen","slug":"if-agent-type-is-not-specified-defaultsubscription","errorCode":null,"errorMessage":"If agent_type is not specified DefaultSubscription must be created within the subscription callback in AgentRuntime.register","messagePattern":"If agent_type is not specified DefaultSubscription must be created within the subscription callback in AgentRuntime\\.register","errorType":"exception","errorClass":"CantHandleException","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-core/src/autogen_core/_default_subscription.py","lineNumber":25,"sourceCode":"from .exceptions import CantHandleException\n\n\nclass DefaultSubscription(TypeSubscription):\n    \"\"\"The default subscription is designed to be a sensible default for applications that only need global scope for agents.\n\n    This topic by default uses the \"default\" topic type and attempts to detect the agent type to use based on the instantiation context.\n\n    Args:\n        topic_type (str, optional): The topic type to subscribe to. Defaults to \"default\".\n        agent_type (str, optional): The agent type to use for the subscription. Defaults to None, in which case it will attempt to detect the agent type based on the instantiation context.\n    \"\"\"\n\n    def __init__(self, topic_type: str = \"default\", agent_type: str | AgentType | None = None):\n        if agent_type is None:\n            try:\n                agent_type = SubscriptionInstantiationContext.agent_type().type\n            except RuntimeError as e:\n                raise CantHandleException(\n                    \"If agent_type is not specified DefaultSubscription must be created within the subscription callback in AgentRuntime.register\"\n                ) from e\n\n        super().__init__(topic_type, agent_type)\n\n\nBaseAgentType = TypeVar(\"BaseAgentType\", bound=\"BaseAgent\")\n\n\n@overload\ndef default_subscription() -> Callable[[Type[BaseAgentType]], Type[BaseAgentType]]: ...\n\n\n@overload\ndef default_subscription(cls: Type[BaseAgentType]) -> Type[BaseAgentType]: ...\n\n\ndef default_subscription(","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-core/src/autogen_core/_default_subscription.py#L7-L43","documentation":"Error \"If agent_type is not specified DefaultSubscription must be created within the subscription callback in AgentRuntime.register\" thrown in microsoft/autogen.","triggerScenarios":"Thrown at python/packages/autogen-core/src/autogen_core/_default_subscription.py:25 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Create it inside AgentRuntime.register's callback or pass agent_type explicitly"],"exampleFix":"DefaultSubscription(agent_type=\"my_agent\") or use within register(callback)","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}