fix(telegram): download reply-to-message photo for agent vision - #22251
Closed
alblez wants to merge 1 commit into
Closed
fix(telegram): download reply-to-message photo for agent vision#22251alblez wants to merge 1 commit into
alblez wants to merge 1 commit into
Conversation
When a user sends a text message replying to a photo message, the agent could not see the referenced image because only reply_to_text/caption was extracted — the photo itself was never downloaded. Add _fetch_reply_to_photo() to the Telegram adapter that: - Detects when reply_to_message contains a photo - Downloads the largest PhotoSize variant via get_file() - Caches locally via cache_image_from_bytes() - Attaches path to event.media_urls/media_types for downstream routing - Sets reply_to_text="[photo]" when no caption exists The fix reuses the existing image-routing pipeline in run.py so the replied-to photo flows through the same native/vision-analyze path as directly-sent photos. Fixes NousResearch#22250
Contributor
|
Thanks for the focused reproduction and regression coverage. This is an automated hermes-sweeper review; current
The current implementation also handles additional replied-to media types, so this photo-only PR is redundant. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a user replies to a photo message with text (e.g., "What do you think about this?" as a reply to a screenshot), the agent could not see the referenced image. Only
reply_to_text/caption was extracted — the photo itself was never downloaded or forwarded.Fixes #22250
Changes
gateway/platforms/telegram.pyNew method
_fetch_reply_to_photo()— async helper that:message.reply_to_messagehas a photoPhotoSizevariant viaget_file()cache_image_from_bytes()event.media_urls/event.media_typesreply_to_text = "[photo]"when no caption exists (so the disambiguation pointer inrun.pystill fires)Called from
_handle_text_message()— right after building the event, before enqueueingtests/gateway/test_telegram_reply_to_photo.py6 regression tests covering:
reply_to_textnot overwritten)How It Works
The fix reuses the existing image-routing pipeline in
run.py— the replied-to photo flows through the same native/vision-analyze path as directly-sent photos. No changes needed torun.pyorbase.py.How to Test
Platforms Tested