langchain-ai/deepagents · error · ChannelMediaError
unsupported media mime type: {mime}
Error message
unsupported media mime type: {mime} What it means
`_media_type` only accepts files whose guessed MIME type starts with `image/` or `video/`. Any other recognized MIME type (audio, documents, archives, etc.) is rejected with `ChannelMediaError` so channels never forward non-image/non-video attachments to the agent.
Source
Thrown at libs/talon/deepagents_talon/channels/base.py:492
window = text[:limit]
for delimiter in ("\n\n", "\n", " "):
index = window.rfind(delimiter)
if index > 0:
return index + len(delimiter)
return limit
def _media_type(path: Path) -> str:
mime, _ = mimetypes.guess_type(path)
if mime is None:
msg = f"unsupported media file type: {path}"
raise ChannelMediaError(msg)
if mime.startswith("image/"):
return "image"
if mime.startswith("video/"):
return "video"
msg = f"unsupported media mime type: {mime}"
raise ChannelMediaError(msg)
_RETRYABLE_ERROR_FRAGMENTS = frozenset(
{
"connectionerror",
"connectionreset",
"connectionrefused",
"connecttimeout",
"timeout",
"broken pipe",
"remotedisconnected",
"eoferror",
"network",
"transient",
}
)
View on GitHub (pinned to a1af029e6e)
Solutions
- Send only image or video files; convert other content to an image/video if needed.
- Filter attachments by MIME type before calling `validate_media` and skip or flag unsupported types.
- If document support is required, request/extend the channel's media handling rather than bypassing validation.
Example fix
# before
validate_media(Path('voice_note.ogg')) # audio/ogg -> ChannelMediaError
# after
if (mime := mimetypes.guess_type('voice_note.ogg')[0]) and mime.startswith(('image/', 'video/')):
validate_media(Path('voice_note.ogg')) Defensive patterns
Strategy: validation
Validate before calling
import mimetypes
from pathlib import Path
def is_image_or_video(path: Path) -> bool:
mime, _ = mimetypes.guess_type(path)
return bool(mime) and (mime.startswith("image/") or mime.startswith("video/"))
if not is_image_or_video(attachment):
skip(attachment) Type guard
def is_supported_mime(mime: str | None) -> bool:
return mime is not None and mime.startswith(("image/", "video/")) Try / catch
try:
validate_media(path)
except ChannelMediaError as exc:
notify_sender(f"Attachment not supported (images/videos only): {exc}") Prevention
- Filter non-image/non-video MIME types at the ingestion boundary
- Convert common formats (e.g. audio) or explicitly reject them with a user message
- Document supported media types for channel users
- Centralize the accepted-MIME list in one place to keep it consistent
When it happens
Trigger: Calling `validate_media` on a file with a known but unsupported MIME type, e.g. `.mp3` (audio/mpeg), `.pdf` (application/pdf), `.zip`, or `.txt`.
Common situations: Users send voice notes, documents, or compressed archives over Telegram and the pipeline tries to attach them; automation forwards arbitrary files into the channel media directory.
Related errors
- unsupported media file type: {path}
- media file type {detected!r} does not match requested type {
- media file is too large: {size} bytes exceeds {max_bytes}
- {media.media_type} media is too large: {size} bytes exceeds
- unsupported outbound media file type: {path}
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/def3a32f36b5a6d0.
Report an issue: GitHub.