feat: support Telegram guest messages - #32802
Closed
vincelwt wants to merge 3 commits into
Closed
Conversation
This was referenced Jun 22, 2026
3 tasks
19 tasks
teknium1
reviewed
Jul 13, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the focused guest-message implementation. The feature premise remains valid on current main, but this needs a current-architecture salvage and one delivery fix.
Problems
gateway/platforms/telegram.py:1924-1942splits a response and then answers the guest query with onlychunks[0]. Any later chunks are silently discarded whileSendResult(success=True)is returned. The guest path needs an explicit, tested one-shot overflow policy.- The adapter target was moved by
5600105478ffde29d7566b45421b100eaa29c4effromgateway/platforms/telegram.pytoplugins/platforms/telegram/adapter.py. Current main still has fourUpdate.ALL_TYPESregistration sites there, includingplugins/platforms/telegram/adapter.py:2009, so all update-registration and reply wiring needs to be ported to that surface.
Suggested changes
- Port the feature to the bundled Telegram plugin and cover polling, reconnect, conflict-recovery, and webhook registrations.
- Add a gateway-level test for complete final delivery and a response exceeding
MAX_MESSAGE_LENGTH.
This is an automated hermes-sweeper review.
| # Official Telegram Guest Bot replies go through | ||
| # answerGuestQuery, not sendMessage, because the bot is not a | ||
| # member of the chat that summoned it. | ||
| return await self._send_guest_query_answer(guest_query_id, chunks[0]) |
Contributor
There was a problem hiding this comment.
chunks was produced by truncate_message() immediately above, so this silently discards every chunk after the first while returning success. Please implement and test an explicit one-shot guest-reply overflow policy rather than dropping the remainder.
1 task
milnerrad
added a commit
to milnerrad/hermes-agent
that referenced
this pull request
Jul 30, 2026
Address blocking review comment. Moving the catch-all TypeHandler(Update) from group=-1 to fallback group=1 ensures it does not compete with normal text/command/media handlers in the default group (0). While PTB's group-dispatch rules evaluate groups independently (so a group=-1 catch-all does not prevent default group-0 handlers from running unless a handler raises ApplicationHandlerStop), this movement matches the placement in sibling PR NousResearch#32802 and keeps registration clean. Extracted adapter.py handler registration into _register_handlers() and added accompanying regression tests in test_telegram_guest_mode.py to assert both group-sorting and dispatch routing.
milnerrad
added a commit
to milnerrad/hermes-agent
that referenced
this pull request
Jul 30, 2026
Address blocking review comment. Moving the catch-all TypeHandler(Update) from group=-1 to fallback group=1 ensures it does not compete with normal text/command/media handlers in the default group (0). While PTB's group-dispatch rules evaluate groups independently (so a group=-1 catch-all does not prevent default group-0 handlers from running unless a handler raises ApplicationHandlerStop), this movement matches the placement in sibling PR NousResearch#32802 and keeps registration clean. Extracted adapter.py handler registration into _register_handlers() and added accompanying regression tests in test_telegram_guest_mode.py to assert both group-sorting and dispatch routing.
milnerrad
added a commit
to milnerrad/hermes-agent
that referenced
this pull request
Aug 2, 2026
Address blocking review comment. Moving the catch-all TypeHandler(Update) from group=-1 to fallback group=1 ensures it does not compete with normal text/command/media handlers in the default group (0). While PTB's group-dispatch rules evaluate groups independently (so a group=-1 catch-all does not prevent default group-0 handlers from running unless a handler raises ApplicationHandlerStop), this movement matches the placement in sibling PR NousResearch#32802 and keeps registration clean. Extracted adapter.py handler registration into _register_handlers() and added accompanying regression tests in test_telegram_guest_mode.py to assert both group-sorting and dispatch routing.
milnerrad
added a commit
to milnerrad/hermes-agent
that referenced
this pull request
Aug 4, 2026
Address blocking review comment. Moving the catch-all TypeHandler(Update) from group=-1 to fallback group=1 ensures it does not compete with normal text/command/media handlers in the default group (0). While PTB's group-dispatch rules evaluate groups independently (so a group=-1 catch-all does not prevent default group-0 handlers from running unless a handler raises ApplicationHandlerStop), this movement matches the placement in sibling PR NousResearch#32802 and keeps registration clean. Extracted adapter.py handler registration into _register_handlers() and added accompanying regression tests in test_telegram_guest_mode.py to assert both group-sorting and dispatch routing. (cherry picked from commit ae489fd)
milnerrad
added a commit
to milnerrad/hermes-agent
that referenced
this pull request
Aug 8, 2026
Address blocking review comment. Moving the catch-all TypeHandler(Update) from group=-1 to fallback group=1 ensures it does not compete with normal text/command/media handlers in the default group (0). While PTB's group-dispatch rules evaluate groups independently (so a group=-1 catch-all does not prevent default group-0 handlers from running unless a handler raises ApplicationHandlerStop), this movement matches the placement in sibling PR NousResearch#32802 and keeps registration clean. Extracted adapter.py handler registration into _register_handlers() and added accompanying regression tests in test_telegram_guest_mode.py to assert both group-sorting and dispatch routing. (cherry picked from commit ae489fd)
milnerrad
added a commit
to milnerrad/hermes-agent
that referenced
this pull request
Aug 10, 2026
Address blocking review comment. Moving the catch-all TypeHandler(Update) from group=-1 to fallback group=1 ensures it does not compete with normal text/command/media handlers in the default group (0). While PTB's group-dispatch rules evaluate groups independently (so a group=-1 catch-all does not prevent default group-0 handlers from running unless a handler raises ApplicationHandlerStop), this movement matches the placement in sibling PR NousResearch#32802 and keeps registration clean. Extracted adapter.py handler registration into _register_handlers() and added accompanying regression tests in test_telegram_guest_mode.py to assert both group-sorting and dispatch routing. (cherry picked from commit ae489fd)
milnerrad
added a commit
to milnerrad/hermes-agent
that referenced
this pull request
Aug 17, 2026
Address blocking review comment. Moving the catch-all TypeHandler(Update) from group=-1 to fallback group=1 ensures it does not compete with normal text/command/media handlers in the default group (0). While PTB's group-dispatch rules evaluate groups independently (so a group=-1 catch-all does not prevent default group-0 handlers from running unless a handler raises ApplicationHandlerStop), this movement matches the placement in sibling PR NousResearch#32802 and keeps registration clean. Extracted adapter.py handler registration into _register_handlers() and added accompanying regression tests in test_telegram_guest_mode.py to assert both group-sorting and dispatch routing. (cherry picked from commit ae489fd)
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
guest_messageupdate type.Update.guest_messageor SDK-laggedUpdate.api_kwargs["guest_message"].answerGuestQuerywithMessage.guest_query_id, instead ofsendMessageinto chats where the bot is not a member.Official Telegram docs used:
Update.guest_message,Message.guest_query_id,SentGuestMessage, andanswerGuestQuery.answerGuestQueryrequiresguest_query_idplus anInlineQueryResultresult payload.Test Plan
python -m pytest tests/gateway/test_telegram*.py -q557 passedpython -m py_compile gateway/platforms/telegram.py gateway/platforms/base.py gateway/session.py tests/gateway/test_telegram_format.pygit diff --check