microsoft/autogen · error · ValueError
Unknown destination type: {type(destination)}
Error message
Unknown destination type: {type(destination)} What it means
The tracing config turns a messaging destination into a span attribute string; _get_destination_str accepts only AgentId, TopicId, plain str, or None. Any other object raises ValueError naming its type. This is an internal instrumentation helper, so the error almost always means a custom messaging path passed a non-standard destination object into tracing.
Source
Thrown at python/packages/autogen-core/src/autogen_core/_telemetry/_tracing_config.py:189
if operation in ["create", "send", "publish"]:
return SpanKind.PRODUCER
elif operation in ["receive", "intercept", "process", "ack"]:
return SpanKind.CONSUMER
else:
return SpanKind.CLIENT
# TODO: Use stringified convention
def _get_destination_str(self, destination: MessagingDestination) -> str:
if isinstance(destination, AgentId):
return f"{destination.type}.({destination.key})-A"
elif isinstance(destination, TopicId):
return f"{destination.type}.({destination.source})-T"
elif isinstance(destination, str):
return destination
elif destination is None:
return ""
else:
raise ValueError(f"Unknown destination type: {type(destination)}")
def _get_operation_type(self, operation: MessagingOperation) -> str:
if operation in ["send", "publish"]:
return "publish"
if operation in ["create"]:
return "create"
elif operation in ["receive", "intercept", "ack"]:
return "receive"
elif operation in ["process"]:
return "process"
else:
return "Unknown"
View on GitHub (pinned to 027ecf0a37)
Solutions
- Always pass AgentId, TopicId, str, or None as the destination to messaging operations.
- If you have a custom destination object, stringify it (`str(dest)`) or map it to AgentId/TopicId before it reaches tracing.
- Disable/replace the instrumentation config for the custom path if it cannot produce standard destinations.
Example fix
# before
tracer_config._get_destination_str(("worker", "default")) # ValueError
# after
tracer_config._get_destination_str(AgentId("worker", "default")) # "worker.(default)-A" Defensive patterns
Strategy: validation
Validate before calling
def is_supported_destination(d: object) -> bool:
return d is None or isinstance(d, (AgentId, TopicId, str)) Type guard
from typing import Union, Optional
from autogen_core import AgentId, TopicId
MessagingDestinationLike = Optional[Union[AgentId, TopicId, str]]
def coerce_destination(d: MessagingDestinationLike) -> str:
return d if isinstance(d, str) else ("" if d is None else str(d)) Prevention
- Type destination parameters as Union[AgentId, TopicId, str, None] at every custom transport boundary.
- Stringify custom routing keys before passing messages into instrumented paths.
When it happens
Trigger: Calling message-instrumentation code with a destination that is e.g. a tuple, int, or a custom wrapper type instead of AgentId/TopicId/str; a custom runtime subclass that forwards its own destination abstraction into the tracing config.
Common situations: Extending autogen-core with custom routing abstractions; test fakes that use string tuples for destinations; version upgrades where a destination field changed from str to a structured type in user adapters.
Related errors
- Unknown metadata type: {type(metadata)}
- Invalid topic type: {self.type}. Must match the pattern: ^[\
- Invalid topic id: {topic_id}
- The string must contain exactly one function
- buffer_size must be greater than 0.
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/2cbd2a2ec1051395.
Report an issue: GitHub.