{"record":{"id":"2b50bc03fe0906de","repo":"microsoft/autogen","slug":"unknown-content-type-message-content","errorCode":null,"errorMessage":"Unknown content type: {message.content}","messagePattern":"Unknown content type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py","lineNumber":130,"sourceCode":"def _system_message_to_azure(message: SystemMessage) -> AzureSystemMessage:\n    return AzureSystemMessage(content=message.content)\n\n\ndef _user_message_to_azure(message: UserMessage) -> AzureUserMessage:\n    assert_valid_name(message.source)\n    if isinstance(message.content, str):\n        return AzureUserMessage(content=message.content)\n    else:\n        parts: List[ContentItem] = []\n        for part in message.content:\n            if isinstance(part, str):\n                parts.append(TextContentItem(text=part))\n            elif isinstance(part, Image):\n                # TODO: support url based images\n                # TODO: support specifying details\n                parts.append(ImageContentItem(image_url=ImageUrl(url=part.data_uri, detail=ImageDetailLevel.AUTO)))\n            else:\n                raise ValueError(f\"Unknown content type: {message.content}\")\n        return AzureUserMessage(content=parts)\n\n\ndef _assistant_message_to_azure(message: AssistantMessage) -> AzureAssistantMessage:\n    assert_valid_name(message.source)\n    if isinstance(message.content, list):\n        return AzureAssistantMessage(\n            tool_calls=[_func_call_to_azure(x) for x in message.content],\n        )\n    else:\n        return AzureAssistantMessage(content=message.content)\n\n\ndef _tool_message_to_azure(message: FunctionExecutionResultMessage) -> Sequence[AzureToolMessage]:\n    return [AzureToolMessage(content=x.content, tool_call_id=x.call_id) for x in message.content]\n\n\ndef to_azure_message(message: LLMMessage) -> Sequence[AzureMessage]:","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py#L112-L148","documentation":"Raised by _user_message_to_azure in the Azure AI (Foundry / GitHub Models) chat client while converting autogen LLMMessage content to Azure SDK ContentItem objects. When message.content is a list, every element must be a str or an autogen_core.models.Image (sent as ImageContentItem with its data_uri); anything else raises ValueError('Unknown content type: ...'). The message in the f-string prints the whole content object, not the offending part.","triggerScenarios":"Calling AzureAIChatCompletionClient.create()/create_stream() with a UserMessage whose content list contains a non-str/non-Image item, e.g. a FunctionCall, a dict, a ToolCallPart, or a multimodal part from another vendor client pasted into the conversation.","commonSituations":"Reusing a multimodal message history produced by a different model client (e.g. OpenAIChatCompletionClient chunks) with the Azure AI client; mixing tool-call parts into UserMessage content; passing Image from a stale autogen-core version so the isinstance check fails.","solutions":["Sanitize the message history before sending: keep only str parts and autogen_core.models.Image parts in UserMessage.content lists","Move tool-call results into FunctionExecutionResultMessage instead of UserMessage content","Verify autogen-core and autogen-ext versions match so the Image class identity used in the isinstance check is the one your code imports"],"exampleFix":"# before\nmsg = UserMessage(content=[\"describe\", some_dict, Image.from_file(\"a.png\")], source=\"user\")\n\n# after\nfrom autogen_core.models import UserMessage, Image\nmsg = UserMessage(\n    content=[p for p in [\"describe\", some_dict, Image.from_file(\"a.png\")] if isinstance(p, (str, Image))],\n    source=\"user\",\n)","handlingStrategy":"type-guard","validationCode":"from autogen_core.models import UserMessage, Image\n\ndef content_is_azure_safe(content) -> bool:\n    if isinstance(content, str):\n        return True\n    return all(isinstance(p, (str, Image)) for p in content)","typeGuard":"from autogen_core.models import Image\nfrom typing import Union, List\n\nAzureSafePart = Union[str, Image]\n\ndef is_azure_safe_part(part) -> bool:\n    return isinstance(part, (str, Image))","tryCatchPattern":"try:\n    result = await client.create(msgs)\nexcept ValueError as e:\n    if str(e).startswith(\"Unknown content type\"):\n        msgs = [strip_unsupported_parts(m) for m in msgs]  # keep only str/Image\n        result = await client.create(msgs)\n    else:\n        raise","preventionTips":["Keep UserMessage content limited to str and autogen_core.models.Image","Never place FunctionCall/ToolCallPart in UserMessage content","Pin matching autogen-core/autogen-ext versions so isinstance checks on Image hold"],"tags":["azure","content-validation","multimodal","message-conversion"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}