feat(gateway): make Telegram command-menu cap configurable - #34147
Closed
fnoor1 wants to merge 1 commit into
Closed
Conversation
The Telegram bot-command menu is capped at MAX_COMMANDS_PER_SCOPE (30) per
scope to stay under Telegram's undocumented ~4KB setMyCommands payload limit.
The menu is built core -> plugin -> skill commands (skills trimmed first), so
when core + skill commands fill the 30 slots, plugin/profile slash commands
(e.g. a profile router exposing /finance, /trend) are trimmed and never appear
in the "/" menu — they work when typed but aren't discoverable.
Make the cap configurable via `telegram.menu_max_commands`:
- gateway/config.py forwards the top-level key into PlatformConfig.extra
(alongside disable_link_previews / guest_mode).
- TelegramAdapter reads it via a new `_coerce_int_extra` helper (mirroring
`_coerce_bool_extra`), clamped to Telegram's 1..100, defaulting to the
existing MAX_COMMANDS_PER_SCOPE (30) so behavior is unchanged unless opted in.
- Both registration sites honor it (startup all-scopes + lazy forum-scope).
How to test: set `telegram: { menu_max_commands: 50 }`, run a plugin that
registers slash commands, restart the gateway, and confirm getMyCommands lists
them. Unit tests in tests/gateway/test_telegram_menu_cap.py cover the adapter
read (default/override/string-int/clamp/invalid) and the config-loader
passthrough into extra.
Platforms tested: Linux.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
fnoor1
force-pushed
the
feat/configurable-telegram-menu-cap
branch
from
May 28, 2026 23:00
c8c08b2 to
f4af3e9
Compare
19 tasks
This was referenced Jun 12, 2026
Contributor
|
Thanks for the focused Telegram menu-cap work. This is an automated hermes-sweeper review; current
Closing as implemented on main. |
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 & why
The Telegram bot-command menu (
set_my_commands) is capped atMAX_COMMANDS_PER_SCOPE = 30per scope to stay under Telegram's undocumented ~4KBsetMyCommandspayload limit. The menu is built in priority order — core commands → plugin slash commands → skill commands (skills trimmed first). When core + skill commands fill the 30 slots, plugin/profile slash commands get trimmed and never reach the "/" menu. They still work when typed, but aren't discoverable.Concretely: a profile-router plugin that registers
/finance,/trend, etc. viactx.register_command(...)has its commands silently omitted from the menu on instances with many core/skill commands —getMyCommandsreturns 30 with none of the plugin commands.Change
Make the cap configurable via
telegram.menu_max_commands(read from the platformextraconfig, clamped to Telegram's documented 1–100), defaulting to the existingMAX_COMMANDS_PER_SCOPE(30) so behavior is unchanged unless opted in. Both registration sites honor it:connect())_ensure_forum_commands())A new
_coerce_int_extrahelper mirrors the existing_coerce_bool_extra(invalid/missing → default, with optional clamping).How to test
Set
telegram: { menu_max_commands: 50 }inconfig.yaml, run a plugin that registers slash commands, restart the gateway, and confirmgetMyCommandslists them. Unit tests added intests/gateway/test_telegram_menu_cap.pycover: default, override, string-encoded int, clamp-high (→100), clamp-low (→1), and invalid (→default).Platforms tested
Linux. Pure config read + clamp — no OS-specific code paths.
🤖 Generated with Claude Code