microsoft/autogen · error · ValueError

Unsupported content type: {content.type}

Error message

Unsupported content type: {content.type}

What it means

The MCP sampling content converter handles only 'text' and 'image' content types. A block with any other type (per MCP spec, 'audio' exists; servers may also send future types on newer protocol versions) raises ValueError(f'Unsupported content type: {content.type}'). This is a capability gap between the sampling host and the content the server sent.

Source

Thrown at python/packages/autogen-ext/src/autogen_ext/tools/mcp/_host/_sampling.py:55

        Converted content as string or Image object

    Raises:
        RuntimeError: If image content is provided but model doesn't support vision
        ValueError: If content type is unsupported
    """
    if content.type == "text":
        return content.text
    elif content.type == "image":
        if model_info and not model_info.get("vision", False):
            model_family = model_info.get("family", "unknown")
            raise RuntimeError(f"model {model_family} does not support vision.")

        # Decode base64 image data and create PIL Image
        image_data = base64.b64decode(content.data)
        pil_image = PILImage.open(io.BytesIO(image_data))
        return Image.from_pil(pil_image)
    else:
        raise ValueError(f"Unsupported content type: {content.type}")


def parse_sampling_message(message: mcp_types.SamplingMessage, model_info: ModelInfo | None = None) -> LLMMessage:
    """Convert MCP sampling messages to AutoGen LLM messages.

    Args:
        message: MCP sampling message with role and content
        model_info: Optional model information for content parsing

    Returns:
        Converted AutoGen LLM message (UserMessage or AssistantMessage)

    Raises:
        ValueError: If message role is not recognized
        AssertionError: If assistant message content is not text
    """
    content = parse_sampling_content(message.content, model_info=model_info)
    if message.role == "user":

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Filter the sampling request server-side so only text (and, for vision models, image) content is sent to the host.
  2. Upgrade autogen-ext to a release whose _sampling converter supports the content type you need (e.g. audio).
  3. If you control the server, downgrade content to text (e.g. transcribe audio server-side).
  4. Catch ValueError around sampling handling and fail that single request with a descriptive message instead of crashing the host.

Example fix

# server side — before
content = [types.ContentBlock(type="audio", data=b64, mimeType="audio/wav")]

# server side — after
transcript = transcribe(b64)
content = [types.ContentBlock(type="text", text=transcript)]
Defensive patterns

Strategy: type-guard

Validate before calling

SUPPORTED = {"text", "image"}
bad = [c for c in message_content if getattr(c, "type", None) not in SUPPORTED]
if bad:
    raise ValueError(f"sampling content contains unsupported types: {[c.type for c in bad]}")

Type guard

from typing import Any, TypeGuard

def is_supported_content(content: Any) -> TypeGuard[Any]:
    return getattr(content, "type", None) in {"text", "image"}

Try / catch

try:
    value = parse_content(content, model_info)
except ValueError as e:
    if "Unsupported content type" in str(e):
        return error_result(f"content type rejected: {e}")
    raise

Prevention

When it happens

Trigger: An MCP server includes content with type='audio' (or a newer spec type) in a sampling message; parse_content hits the final else and raises. Requires a server that actively uses non-text/image blocks.

Common situations: Voice/multimodal MCP servers sending audio blocks; protocol version negotiated higher than what this autogen-ext release supports; a custom server sending experimental content types.

Related errors


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