microsoft/autogen · error · ValueError

Unsupported content type: {mime_type}

Error message

Unsupported content type: {mime_type}

What it means

_extract_text in ChromaDBVectorMemory only handles TEXT, MARKDOWN, and JSON (dict payload) contents. Any other MemoryMimeType value (e.g. IMAGE, BINARY, or a future enum member) falls into the else branch and raises ValueError with the offending mime type. This guards the string-only contract ChromaDB's document store requires.

Source

Thrown at python/packages/autogen-ext/src/autogen_ext/memory/chromadb/_chromadb.py:302

    def _extract_text(self, content_item: str | MemoryContent) -> str:
        """Extract searchable text from content."""
        if isinstance(content_item, str):
            return content_item

        content = content_item.content
        mime_type = content_item.mime_type

        if mime_type in [MemoryMimeType.TEXT, MemoryMimeType.MARKDOWN]:
            return str(content)
        elif mime_type == MemoryMimeType.JSON:
            if isinstance(content, dict):
                # Store original JSON string representation
                return str(content).lower()
            raise ValueError("JSON content must be a dict")
        elif isinstance(content, Image):
            raise ValueError("Image content cannot be converted to text")
        else:
            raise ValueError(f"Unsupported content type: {mime_type}")

    def _calculate_score(self, distance: float) -> float:
        """Convert ChromaDB distance to a similarity score."""
        if self._config.distance_metric == "cosine":
            return 1.0 - (distance / 2.0)
        return 1.0 / (1.0 + distance)

    async def update_context(
        self,
        model_context: ChatCompletionContext,
    ) -> UpdateContextResult:
        messages = await model_context.get_messages()
        if not messages:
            return UpdateContextResult(memories=MemoryQueryResult(results=[]))

        # Extract query from last message
        last_message = messages[-1]
        query_text = last_message.content if isinstance(last_message.content, str) else str(last_message)

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Convert the content to a supported form before add(): text/markdown string, or a dict for JSON mime type.
  2. If content is JSON, pass a dict (not json.dumps output); the backend serializes it itself.
  3. Switch to a memory backend that supports the mime type you need (e.g. RedisMemory for TEXT/JSON/MARKDOWN, or a custom Memory implementation for binary).

Example fix

// before
await memory.add(MemoryContent(content=b'raw-bytes', mime_type=MemoryMimeType.BINARY))

// after
await memory.add(MemoryContent(content=b64encode(b'raw-bytes').decode(), mime_type=MemoryMimeType.TEXT, metadata={'encoding': 'base64'}))
Defensive patterns

Strategy: validation

Validate before calling

from autogen_core.memory import MemoryContent, MemoryMimeType

SUPPORTED = {MemoryMimeType.TEXT, MemoryMimeType.MARKDOWN, MemoryMimeType.JSON}

def validate_for_chroma(item: MemoryContent) -> bool:
    if item.mime_type not in SUPPORTED:
        return False
    if item.mime_type == MemoryMimeType.JSON and not isinstance(item.content, dict):
        return False
    return True

Type guard

def is_chroma_supported(item: MemoryContent) -> bool:
    return item.mime_type in {MemoryMimeType.TEXT, MemoryMimeType.MARKDOWN, MemoryMimeType.JSON} and not isinstance(item.content, Image)

Try / catch

try:
    await memory.add(item)
except ValueError as e:
    if 'Unsupported content type' in str(e):
        raise SkipMemoryItem(item.mime_type) from e
    raise

Prevention

When it happens

Trigger: add() or query() with a MemoryContent whose mime_type is MemoryMimeType.IMAGE or MemoryMimeType.BINARY; a JSON content whose payload is a non-dict (e.g. list or string) also raises the sibling 'JSON content must be a dict' error; passing a custom/extended enum value.

Common situations: Sharing one MemoryContent pipeline across several memory backends with different supported-type matrices; upgrading autogen-ext and encountering a new MemoryMimeType member; storing JSON as a pre-serialized string instead of a dict.

Related errors


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