Skip to content

fix(telegram): support image files sent as documents#18819

Closed
dashixiong-droid wants to merge 1 commit into
NousResearch:mainfrom
dashixiong-droid:fix/telegram-image-documents
Closed

fix(telegram): support image files sent as documents#18819
dashixiong-droid wants to merge 1 commit into
NousResearch:mainfrom
dashixiong-droid:fix/telegram-image-documents

Conversation

@dashixiong-droid

Copy link
Copy Markdown

Problem

When users send image files (PNG, JPG, WEBP, GIF) as Telegram documents (file attachments) rather than as photos, the gateway rejects them with "Unsupported document type" because the image extensions are not in SUPPORTED_DOCUMENT_TYPES.

Solution

Add image format detection in the elif msg.document: branch of _handle_media_message, routing .png/.jpg/.jpeg/.webp/.gif files through the existing cache_image_from_bytes pipeline — the same path used for native Telegram photos.

Testing

Verified by sending a PNG as a document attachment to the Hermes Telegram bot — the image is now cached and accessible for vision analysis.

Related

  • Telegram Bot API sends images as msg.photo (compressed) or msg.document (full quality). This fix handles the latter case.

When users send image files (PNG/JPG/WEBP/GIF) as Telegram documents
rather than photos, the gateway rejected them with 'Unsupported document
type'. This patch adds image format detection in the document handler,
routing them through the existing image cache for vision tool access.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter tool/vision Vision analysis and image generation labels May 2, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #16710 — same fix routing image documents through cache_image_from_bytes pipeline in Telegram gateway.

1 similar comment
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #16710 — same fix routing image documents through cache_image_from_bytes pipeline in Telegram gateway.

@teknium1

Copy link
Copy Markdown
Contributor

This is already implemented on current main. Thanks for the patch; the maintainer note was right that this overlaps the same Telegram image-document fix discussed in #16710.

Automated hermes-sweeper review evidence:

  • gateway/platforms/telegram.py:5562 detects Telegram documents as images when the filename extension is .png, .jpg, .jpeg, .webp, .gif, or the MIME type is image/*.
  • gateway/platforms/telegram.py:5567 downloads the document bytes and routes them through cache_image_from_bytes, instead of falling through to the unsupported-document branch.
  • gateway/platforms/telegram.py:5577 marks the resulting event as MessageType.PHOTO, and gateway/platforms/telegram.py:5582 sends it through the same photo/media-group enqueue path used by native Telegram photos.
  • gateway/platforms/base.py:1150 defines the supported image-document extensions for .jpg, .jpeg, .png, .webp, and .gif.
  • tests/gateway/test_telegram_documents.py:264 covers a PNG uploaded as a Telegram document and asserts it is enqueued as a photo with image/png media type.
  • The implementing commit is 77c4675a50db7abbfd191d4fba4746b4f3e1559e (fix(telegram): route image documents (.png/.jpg/.webp/.gif) through vision pipeline), which is already an ancestor of main and is included in release tag v2026.5.28.

@teknium1 teknium1 closed this Jun 10, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter sweeper:implemented-on-main Sweeper: behavior already present on current main tool/vision Vision analysis and image generation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants