{"record":{"id":"648958858588a2f6","repo":"microsoft/autogen","slug":"unsupported-content-type-mime-type","errorCode":null,"errorMessage":"Unsupported content type: {mime_type}","messagePattern":"Unsupported content type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/experimental/task_centric_memory/utils/teachability.py","lineNumber":53,"sourceCode":"    def _extract_text(self, content_item: str | MemoryContent) -> str:\n        \"\"\"Extract searchable text from content.\"\"\"\n        if isinstance(content_item, str):\n            return content_item\n\n        content = content_item.content\n        mime_type = content_item.mime_type\n\n        if mime_type in [MemoryMimeType.TEXT, MemoryMimeType.MARKDOWN]:\n            return str(content)\n        elif mime_type == MemoryMimeType.JSON:\n            if isinstance(content, dict):\n                # Store original JSON string representation\n                return str(content).lower()\n            raise ValueError(\"JSON content must be a dict\")\n        elif isinstance(content, Image):\n            raise ValueError(\"Image content cannot be converted to text\")\n        else:\n            raise ValueError(f\"Unsupported content type: {mime_type}\")\n\n    async def update_context(\n        self,\n        model_context: ChatCompletionContext,\n    ) -> UpdateContextResult:\n        \"\"\"\n        Extracts any advice from the last user turn to be stored in memory,\n        and adds any relevant memories to the model context.\n        \"\"\"\n        self._logger.enter_function()\n\n        # Extract text from the user's last message\n        messages = await model_context.get_messages()\n        if not messages:\n            self._logger.leave_function()\n            return UpdateContextResult(memories=MemoryQueryResult(results=[]))\n        last_message = messages[-1]\n        last_user_text = last_message.content if isinstance(last_message.content, str) else str(last_message)","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/experimental/task_centric_memory/utils/teachability.py#L35-L71","documentation":"The teachability text converter handles TEXT, MARKDOWN, JSON (dict), and Image; any other mime_type falls into the terminal else branch and raises with the unsupported value embedded in the message.","triggerScenarios":"Creating MemoryContent with a mime_type outside the supported set (e.g. MemoryMimeType.IMAGE binary, AUDIO, VIDEO, or a custom enum value) and routing it through teachability's update_context/query.","commonSituations":"New MemoryMimeType enum members added in newer autogen versions not yet handled here; mixing generic memory contents into the teachable memory; custom mime types.","solutions":["Check the mime_type printed in the message and convert to TEXT/MARKDOWN before storage.","Add a branch for that mime type (if contributing upstream) or bypass teachability for that content type.","Gate memory additions: only add contents whose mime_type is in {TEXT, MARKDOWN, JSON-with-dict}."],"exampleFix":"# before\nawait memory.add(MemoryContent(content=b\"...\", mime_type=MemoryMimeType.BINARY))\n# after\nawait memory.add(MemoryContent(content=\"summary of binary blob\", mime_type=MemoryMimeType.TEXT))","handlingStrategy":"type-guard","validationCode":"from autogen_core.memory import MemoryMimeType\nSUPPORTED = {MemoryMimeType.TEXT, MemoryMimeType.MARKDOWN, MemoryMimeType.JSON}\nassert c.mime_type in SUPPORTED, f\"teachability cannot process {c.mime_type}\"","typeGuard":"def is_supported_teachability_mime(mime_type) -> bool:\n    return mime_type in {MemoryMimeType.TEXT, MemoryMimeType.MARKDOWN, MemoryMimeType.JSON}","tryCatchPattern":null,"preventionTips":["Whitelist mime types before adding content to teachability memory.","After upgrading autogen, re-check the supported set — new enum members may not be handled."],"tags":["autogen","memory","validation","mime-type"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}