microsoft/autogen · error · ValueError

Unsupported subscription type.

Error message

Unsupported subscription type.

What it means

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.').

Source

Thrown at python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_utils.py:23

from .protos import agent_worker_pb2


def subscription_to_proto(subscription: Subscription) -> agent_worker_pb2.Subscription:
    match subscription:
        case TypeSubscription(topic_type=topic_type, agent_type=agent_type, id=id):
            return agent_worker_pb2.Subscription(
                id=id,
                typeSubscription=agent_worker_pb2.TypeSubscription(topic_type=topic_type, agent_type=agent_type),
            )
        case TypePrefixSubscription(topic_type_prefix=topic_type_prefix, agent_type=agent_type, id=id):
            return agent_worker_pb2.Subscription(
                id=id,
                typePrefixSubscription=agent_worker_pb2.TypePrefixSubscription(
                    topic_type_prefix=topic_type_prefix, agent_type=agent_type
                ),
            )
        case _:
            raise ValueError("Unsupported subscription type.")


def subscription_from_proto(subscription: agent_worker_pb2.Subscription) -> Subscription:
    oneofcase = subscription.WhichOneof("subscription")
    match oneofcase:
        case "typeSubscription":
            type_subscription_msg: agent_worker_pb2.TypeSubscription = subscription.typeSubscription
            return TypeSubscription(
                topic_type=type_subscription_msg.topic_type,
                agent_type=type_subscription_msg.agent_type,
                id=subscription.id,
            )

        case "typePrefixSubscription":
            type_prefix_subscription_msg: agent_worker_pb2.TypePrefixSubscription = subscription.typePrefixSubscription
            return TypePrefixSubscription(
                topic_type_prefix=type_prefix_subscription_msg.topic_type_prefix,
                agent_type=type_prefix_subscription_msg.agent_type,

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Replace the custom subscription with TypeSubscription or TypePrefixSubscription semantics (source/target topic rewriting can usually be expressed as a type or prefix mapping)
  2. If mapping logic is essential, apply it before publishing (publish to a rewritten TopicId) instead of via a custom Subscription
  3. Contribute/extend the converter in _utils.py if you control the fork

Example fix

# before
class MySub(Subscription):
    def map_topic_to_agents(...): ...
await runtime.add_subscription(MySub(...))

# after
await runtime.add_subscription(TypePrefixSubscription(topic_type_prefix="events", agent_type="worker"))
Defensive patterns

Strategy: type-guard

Validate before calling

from autogen_core import TypeSubscription, TypePrefixSubscription, Subscription

def is_grpc_supported_subscription(sub: Subscription) -> bool:
    return isinstance(sub, (TypeSubscription, TypePrefixSubscription))

if not is_grpc_supported_subscription(sub):
    raise ValueError("gRPC runtime supports only TypeSubscription/TypePrefixSubscription")

Type guard

def is_grpc_supported_subscription(sub: object) -> TypeGuard[TypeSubscription | TypePrefixSubscription]:
    return isinstance(sub, (TypeSubscription, TypePrefixSubscription))

Try / catch

try:
    await runtime.add_subscription(sub)
except ValueError as e:
    if "Unsupported subscription type" in str(e):
        # replace with TypeSubscription/TypePrefixSubscription
        ...

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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