feat(telegram): let plugins handle callback queries and send markup - #96053
Open
vKongv wants to merge 1 commit into
Open
feat(telegram): let plugins handle callback queries and send markup#96053vKongv wants to merge 1 commit into
vKongv wants to merge 1 commit into
Conversation
cursor
Bot
force-pushed
the
feat/telegram-plugin-callback-handlers
branch
from
August 27, 2026 10:45
1fc3385 to
f41a83f
Compare
vKongv
force-pushed
the
feat/telegram-plugin-callback-handlers
branch
from
August 27, 2026 11:21
f41a83f to
8216b89
Compare
Plugins can register prefix-matched callback_query handlers and attach inline keyboards or per-send preview overrides via send() metadata. Callback auth prefers set_authorization_check so multiplex profile closures do not fail-closed.
vKongv
added a commit
to pebble-tech/hermes-agent
that referenced
this pull request
Aug 27, 2026
…CHES Carry Nous NousResearch#96053 (KAI-157) on the next sync so plugin callback handlers and send() markup land on integration main.
vKongv
force-pushed
the
feat/telegram-plugin-callback-handlers
branch
from
August 27, 2026 14:04
8216b89 to
29743c9
Compare
vKongv
added a commit
to pebble-tech/hermes-agent
that referenced
this pull request
Aug 27, 2026
…CHES Carry Nous NousResearch#96053 (KAI-157) on the next sync so plugin callback handlers and send() markup land on integration main.
Contributor
|
Heads-up: the handler-registration half of this landed in #59217 (34393c3) — ctx.register_platform_handler("telegram", factory) wires plugin CallbackQueryHandlers into the PTB Application before core handlers, so the swallowed-callback_query problem is solved on main. The outbound half (attaching InlineKeyboardMarkup via adapter.send metadata) is NOT covered and still worth reviewing — a rebase onto main that drops the handler plumbing and keeps the send-markup surface would slim this nicely. |
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.
What does this PR do?
Plugins can register Telegram inline-keyboard handlers the same way they register Slack action handlers, and they can attach those keyboards through
adapter.send()metadata.Without this, a plugin that sends
InlineKeyboardMarkuphas itscallback_queryswallowed by the built-in prefix router. The alternatives are forking the adapter or adding a second PTBCallbackQueryHandler, which reconnect rebuilds drop.This PR:
PluginContext.register_telegram_callback_handler(prefix, callback)and queues(prefix, callback, plugin_name)onPluginManager._handle_callback_queryafter built-in prefixes, using longest-prefix match. Built-in prefixes stay reserved and cannot be overridden.query.answer()s on a match, and swallows handler exceptions.set_authorization_check/_is_sender_authorizedbefore the bound-handler__self__lookup, somultiplex_profilesclosures do not fail-closed on empty env allowlists (same class as Telegram group_allowed_chats is skipped by early auth with multiplex handler closures #87132 / [Bug]: Telegram inline callbacks reject profile-authorized users under multiplex routing #86296).TelegramAdapter.send(..., metadata)withreply_markup(structured rows or pass-through markup) and optional per-senddisable_link_preview. Keyboard attaches to the first chunk only when the message is split. If markup is present, the rich-send path is skipped so the keyboard is not dropped.Related open work (searched before opening): #78619, #80458, #85565 take other plugin-callback shapes (
gateway_platform_eventor a lifecycle hook). This one stays on the Slack-style registry plus send metadata. #86308 is the multiplex callback-auth fix for built-in buttons.Related Issue
Related to #87132 / #86296 (callback auth under multiplex). No dedicated issue for the registry API.
Type of Change
Changes Made
hermes_cli/plugins.py: register / get / clear Telegram callback handlers; reject reserved prefixesplugins/platforms/telegram/adapter.py: plugin dispatch, multiplex-safe callback auth, send markup and per-send preview overridetests/gateway/test_telegram_plugin_callback_handlers.py: register, dispatch, auth fail-closed, multiplex closure, built-in precedence, reconnect, send markuptests/hermes_cli/test_plugins.py: force-rediscover clears the new listwebsite/docs/developer-guide/plugins/index.md: public API docsHow to Test
scripts/run_tests.sh tests/gateway/test_telegram_plugin_callback_handlers.py tests/hermes_cli/test_plugins.py -qctx.register_telegram_callback_handler("task:", handler).metadata={"reply_markup": [[{"text": "Go", "callback_data": "task:go"}]], "disable_link_preview": True}.gateway.multiplex_profiles, a tap from an allowlisted user still reaches the plugin (authorization check is consulted even when the primary handler is a closure).Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings)cli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/A