{"record":{"id":"3c70a13046eb82ef","repo":"microsoft/autogen","slug":"unsupported-subscription-type","errorCode":null,"errorMessage":"Unsupported subscription type.","messagePattern":"Unsupported subscription type\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_utils.py","lineNumber":23,"sourceCode":"from .protos import agent_worker_pb2\n\n\ndef subscription_to_proto(subscription: Subscription) -> agent_worker_pb2.Subscription:\n    match subscription:\n        case TypeSubscription(topic_type=topic_type, agent_type=agent_type, id=id):\n            return agent_worker_pb2.Subscription(\n                id=id,\n                typeSubscription=agent_worker_pb2.TypeSubscription(topic_type=topic_type, agent_type=agent_type),\n            )\n        case TypePrefixSubscription(topic_type_prefix=topic_type_prefix, agent_type=agent_type, id=id):\n            return agent_worker_pb2.Subscription(\n                id=id,\n                typePrefixSubscription=agent_worker_pb2.TypePrefixSubscription(\n                    topic_type_prefix=topic_type_prefix, agent_type=agent_type\n                ),\n            )\n        case _:\n            raise ValueError(\"Unsupported subscription type.\")\n\n\ndef subscription_from_proto(subscription: agent_worker_pb2.Subscription) -> Subscription:\n    oneofcase = subscription.WhichOneof(\"subscription\")\n    match oneofcase:\n        case \"typeSubscription\":\n            type_subscription_msg: agent_worker_pb2.TypeSubscription = subscription.typeSubscription\n            return TypeSubscription(\n                topic_type=type_subscription_msg.topic_type,\n                agent_type=type_subscription_msg.agent_type,\n                id=subscription.id,\n            )\n\n        case \"typePrefixSubscription\":\n            type_prefix_subscription_msg: agent_worker_pb2.TypePrefixSubscription = subscription.typePrefixSubscription\n            return TypePrefixSubscription(\n                topic_type_prefix=type_prefix_subscription_msg.topic_type_prefix,\n                agent_type=type_prefix_subscription_msg.agent_type,","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_utils.py#L5-L41","documentation":"subscription_to_proto converts an AutoGen Subscription to its gRPC protobuf form using a match on the subscription type. Only TypeSubscription and TypePrefixSubscription are handled; any other object falls through to `case _` and raises ValueError('Unsupported subscription type.').","triggerScenarios":"Calling runtime.add_subscription (or any API that serializes subscriptions to the host) with a custom Subscription subclass or any object that is neither TypeSubscription nor TypePrefixSubscription.","commonSituations":"Writing a custom Subscription class (the abstract base allows it) and assuming the gRPC runtime supports it; upgrading from a local runtime where custom subscriptions worked to GrpcWorkerAgentRuntime.","solutions":["Replace the custom subscription with TypeSubscription or TypePrefixSubscription semantics (source/target topic rewriting can usually be expressed as a type or prefix mapping)","If mapping logic is essential, apply it before publishing (publish to a rewritten TopicId) instead of via a custom Subscription","Contribute/extend the converter in _utils.py if you control the fork"],"exampleFix":"# before\nclass MySub(Subscription):\n    def map_topic_to_agents(...): ...\nawait runtime.add_subscription(MySub(...))\n\n# after\nawait runtime.add_subscription(TypePrefixSubscription(topic_type_prefix=\"events\", agent_type=\"worker\"))","handlingStrategy":"type-guard","validationCode":"from autogen_core import TypeSubscription, TypePrefixSubscription, Subscription\n\ndef is_grpc_supported_subscription(sub: Subscription) -> bool:\n    return isinstance(sub, (TypeSubscription, TypePrefixSubscription))\n\nif not is_grpc_supported_subscription(sub):\n    raise ValueError(\"gRPC runtime supports only TypeSubscription/TypePrefixSubscription\")","typeGuard":"def is_grpc_supported_subscription(sub: object) -> TypeGuard[TypeSubscription | TypePrefixSubscription]:\n    return isinstance(sub, (TypeSubscription, TypePrefixSubscription))","tryCatchPattern":"try:\n    await runtime.add_subscription(sub)\nexcept ValueError as e:\n    if \"Unsupported subscription type\" in str(e):\n        # replace with TypeSubscription/TypePrefixSubscription\n        ...","preventionTips":["Restrict subscription declarations to TypeSubscription and TypePrefixSubscription for gRPC runtimes","Run integration tests that exercise registration against GrpcWorkerAgentRuntime","Keep subscription construction centralized so unsupported types cannot sneak in"],"tags":["python","autogen","grpc","subscriptions","validation"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}