microsoft/autogen · error · ValueError

Unsupported content type: {type(c)} in {message}

Error message

Unsupported content type: {type(c)} in {message}

What it means

handle_incoming_message converts an incoming BaseChatMessage to an Assistants-API content payload. It supports exactly two content shapes: plain strings and lists whose elements are str or autogen Image (converted to an image_url data-URI part). Any other element type (e.g. a MultiModalVideo or unknown block) raises ValueError naming the type and message.

Source

Thrown at python/packages/autogen-ext/src/autogen_ext/agents/openai/_openai_assistant_agent.py:535

        # Return the assistant's response as a Response with inner messages
        chat_message = TextMessage(source=self.name, content=text_content[0].text.value)
        yield Response(chat_message=chat_message, inner_messages=inner_messages)

    async def handle_incoming_message(self, message: BaseChatMessage, cancellation_token: CancellationToken) -> None:
        """Handle regular text messages by adding them to the thread."""
        content: str | List[MessageContentPartParam] | None = None
        llm_message = message.to_model_message()
        if isinstance(llm_message.content, str):
            content = llm_message.content
        else:
            content = []
            for c in llm_message.content:
                if isinstance(c, str):
                    content.append(TextContentBlockParam(text=c, type="text"))
                elif isinstance(c, Image):
                    content.append(ImageURLContentBlockParam(image_url=ImageURLParam(url=c.data_uri), type="image_url"))
                else:
                    raise ValueError(f"Unsupported content type: {type(c)} in {message}")
        await cancellation_token.link_future(
            asyncio.ensure_future(
                self._client.beta.threads.messages.create(  # type: ignore[reportDeprecated]
                    thread_id=self._thread_id,
                    content=content,
                    role="user",
                )
            )
        )

    async def on_reset(self, cancellation_token: CancellationToken) -> None:
        """Handle reset command by deleting new messages and runs since initialization."""
        await self._ensure_initialized()

        # Retrieve all message IDs in the thread
        new_message_ids: List[str] = []
        after: str | NotGiven = NOT_GIVEN
        while True:

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Send only text and images to OpenAIAssistantAgent: content strings or lists of str/Image.
  2. Strip unsupported parts before forwarding: filter message content to str and Image instances.
  3. Use OpenAIChatCompletionAgent or another agent type if you need broader multimodal input support.

Example fix

# before
await agent.handle_incoming_message(
    MultiModalMessage(source="user", content=["look", video_block]), ct)

# after
from autogen_core.models import Image
safe = [p for p in msg.content if isinstance(p, (str, Image))]
await agent.handle_incoming_message(
    MultiModalMessage(source="user", content=safe), ct)
Defensive patterns

Strategy: type-guard

Validate before calling

from autogen_core.models import Image

def assistant_safe_content(content):
    if isinstance(content, str):
        return content
    return [p for p in content if isinstance(p, (str, Image))]

Type guard

from autogen_core.models import Image

def is_supported_part(p: object) -> bool:
    return isinstance(p, (str, Image))

Prevention

When it happens

Trigger: Sending a MultiModalMessage whose content list contains anything besides str or Image — for example video blocks or custom content types from other autogen-ext packages.

Common situations: Piping rich multimodal messages (audio/video parts) from other agents or UIs into an OpenAIAssistantAgent; custom BaseChatMessage subclasses with novel content types.

Related errors


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