microsoft/autogen · error · ValueError
Image content cannot be converted to text
Error message
Image content cannot be converted to text
What it means
Teachability's text extraction cannot convert binary/image memory items to text. When a MemoryContent contains an Image object, the converter raises because advice extraction and retrieval operate on text only.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/experimental/task_centric_memory/utils/teachability.py:51
return self._name
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}")
async def update_context(
self,
model_context: ChatCompletionContext,
) -> UpdateContextResult:
"""
Extracts any advice from the last user turn to be stored in memory,
and adds any relevant memories to the model context.
"""
self._logger.enter_function()
# Extract text from the user's last message
messages = await model_context.get_messages()
if not messages:
self._logger.leave_function()
return UpdateContextResult(memories=MemoryQueryResult(results=[]))View on GitHub (pinned to 027ecf0a37)
Solutions
- Filter out image contents before adding them to the teachability memory (check isinstance(content, Image)).
- Store a textual description/caption of the image instead of the Image object.
- Use a memory implementation that supports multimodal content for images.
Example fix
# before await memory.add(MemoryContent(content=Image.from_uri(img_uri), mime_type=MemoryMimeType.IMAGE)) # after await memory.add(MemoryContent(content=describe_image(img_uri), mime_type=MemoryMimeType.TEXT))
Defensive patterns
Strategy: validation
Validate before calling
from autogen_core.models import Image
if isinstance(content, Image):
raise SkipContent("image not supported by teachability") # or convert to a caption
c = MemoryContent(content=content, mime_type=MemoryMimeType.TEXT) Type guard
from autogen_core.models import Image
def is_text_safe_memory_content(content) -> bool:
return not isinstance(content, Image) Prevention
- Filter Image instances out before adding to teachability memory.
- Store image captions/descriptions instead of Image objects.
- Keep a separate multimodal memory for binary artifacts.
When it happens
Trigger: Passing MemoryContent(content=Image.from_uri(...)) (or any Image instance) into the teachability memory's update_context / query path, which routes through the text converter.
Common situations: Multimodal agents sharing a memory store with image artifacts; accidentally storing screenshot/image content in a text-only teachable memory.
Related errors
- Invalid aggregate message {reason}
- Unsupported content type {item.GetType()}
- Only TextContent and ImageContent are allowed in MultiModalM
- JSON content must be a dict
- Unsupported content type: {mime_type}
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/da79489ae50fd06a.
Report an issue: GitHub.