feat(telegram): support Bot API 10 guest messages - #59879
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Telegram Bot API 10.0 “guest message” support to the plugin-based Telegram adapter, routing replies via answerGuestQuery/inline edits and propagating per-message guest metadata through the gateway/session pipeline so guest turns can be isolated and delivered correctly.
Changes:
- Bump
python-telegram-bot[webhooks]to 22.8 (Bot API 10 guest APIs) and wire Telegram adapter handling forguest_messageupdates + guest reply delivery/editing. - Propagate ephemeral platform metadata through
SessionSource/ thread-metadata helpers and incorporate a suffix intobuild_session_key()for guest session isolation. - Add focused gateway/Telegram guest-mode regression tests and adjust Telegram formatting tests to avoid cross-test config bleed.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
uv.lock |
Updates the locked python-telegram-bot version to 22.8. |
pyproject.toml |
Pins the messaging/termux extras to python-telegram-bot[webhooks]==22.8. |
plugins/platforms/telegram/adapter.py |
Implements guest update extraction/authorization + reply via answerGuestQuery and inline edits; subscribes to guest_message updates. |
gateway/platforms/base.py |
Preserves platform_metadata when building thread metadata for adapter sends. |
gateway/session.py |
Adds platform_metadata to SessionSource and appends a session_key_suffix when building session keys. |
gateway/run.py |
Merges platform metadata into send/progress metadata and adds logic to suppress duplicate final sends after streaming. |
gateway/config.py |
Bridges the new Telegram guest_thinking_text config field into platform extra. |
hermes_cli/config.py |
Adds default Telegram guest_thinking_text in the CLI config defaults. |
cli-config.yaml.example |
Documents the guest_thinking_text Telegram config field in the example config. |
tests/gateway/test_telegram_guest_botapi10.py |
Adds tests covering guest update handling, metadata propagation, guest send/edit behavior, and session key suffix behavior. |
tests/gateway/test_telegram_format.py |
Ensures Telegram formatting tests set platform and isolate topics config to avoid cross-test pollution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d8ca57c to
5e08ae1
Compare
Duplicate of #43049 — same Telegram Bot API 10 guest-message feature ( |
5e08ae1 to
b472978
Compare
a66e7e3 to
a042248
Compare
a042248 to
37b4cfc
Compare
What does this PR do?
Adds Telegram Bot API 10.0 guest-message support to the current plugin-based Telegram adapter.
Telegram guest messages let a bot receive explicit @mentions from groups where it is not a member. Those updates cannot be answered through normal
sendMessagechat delivery; they must useanswerGuestQuery. This PR wires that path through the Telegram adapter, preserves guest metadata through gateway session/progress handling, and prevents duplicate normal final sends after the guest reply is delivered.This is related to the existing guest-mode work already open upstream:
I found these while following the contributing guide's duplicate-search step. If maintainers prefer, this can be treated as a tested current-main patch/reference for one of those PRs instead of a competing PR.
Related Issue
Related to #46196 and the open Telegram guest-mode PR stack listed above.
Type of Change
Changes Made
plugins/platforms/telegram/adapter.pyguest_messageupdates;answer_guest_query;gateway/platforms/base.pygateway/session.pygateway/run.pygateway/config.py,hermes_cli/config.py,cli-config.yaml.examplepyproject.toml,uv.lockpython-telegram-bot[webhooks]from 22.6 to 22.8 for Bot API 10.0 guest-message API support.tests/gateway/test_telegram_guest_botapi10.pytests/gateway/test_telegram_format.pyHow to Test
Verify PTB exposes Bot API 10.0 guest support:
Run focused Telegram/gateway regression tests:
Run lint for touched Python files:
Optional runtime check:
Checklist
Code
feat(telegram): support Bot API 10 guest messages)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
N/A.
Screenshots / Logs
Local verification:
Note: I did not run the full
pytest tests/ -qsuite in this environment; only the focused Telegram/gateway regression set above.