Skip to content

feat(gateway): make Telegram command-menu cap configurable - #34147

Closed
fnoor1 wants to merge 1 commit into
NousResearch:mainfrom
fnoor1:feat/configurable-telegram-menu-cap
Closed

feat(gateway): make Telegram command-menu cap configurable#34147
fnoor1 wants to merge 1 commit into
NousResearch:mainfrom
fnoor1:feat/configurable-telegram-menu-cap

Conversation

@fnoor1

@fnoor1 fnoor1 commented May 28, 2026

Copy link
Copy Markdown

What & why

The Telegram bot-command menu (set_my_commands) is capped at MAX_COMMANDS_PER_SCOPE = 30 per scope to stay under Telegram's undocumented ~4KB setMyCommands payload 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. via ctx.register_command(...) has its commands silently omitted from the menu on instances with many core/skill commands — getMyCommands returns 30 with none of the plugin commands.

Change

Make the cap configurable via telegram.menu_max_commands (read from the platform extra config, clamped to Telegram's documented 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 registration (connect())
  • lazy per-forum-scope registration (_ensure_forum_commands())
telegram:
  menu_max_commands: 50   # 1..100; default 30

A new _coerce_int_extra helper mirrors the existing _coerce_bool_extra (invalid/missing → default, with optional clamping).

How to test

Set telegram: { menu_max_commands: 50 } in config.yaml, run a plugin that registers slash commands, restart the gateway, and confirm getMyCommands lists them. Unit tests added in tests/gateway/test_telegram_menu_cap.py cover: default, override, string-encoded int, clamp-high (→100), clamp-low (→1), and invalid (→default).

scripts/run_tests.sh tests/gateway/test_telegram_menu_cap.py

Platforms tested

Linux. Pure config read + clamp — no OS-specific code paths.

🤖 Generated with Claude Code

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
fnoor1 force-pushed the feat/configurable-telegram-menu-cap branch from c8c08b2 to f4af3e9 Compare May 28, 2026 23:00
@alt-glitch alt-glitch added type/feature New feature or request comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter P3 Low — cosmetic, nice to have labels May 29, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused Telegram menu-cap work. This is an automated hermes-sweeper review; current main already implements the requested behavior through a broader, documented configuration surface.

  • hermes_cli/commands.py:600-642 reads and safely clamps platforms.telegram.extra.command_menu.max_commands to Telegram's 1..100 range.
  • plugins/platforms/telegram/adapter.py:2936-2945 uses that value for startup registration, and plugins/platforms/telegram/adapter.py:7483-7487 uses it for lazy forum-scope registration.
  • Commit dbe14ce35d9cb087ae9fe3e3f166f6c475297e25 implemented the configurable cap and priority support, explicitly salvaging related PR feat(gateway): configure Telegram command menu priority #42021; d4be583d986f7bcca4f8414fd21ef9e34b18c948 raised the default cap to 60. Current tests at tests/hermes_cli/test_commands.py:1337-1391 cover defaults, overrides, invalid input, and clamp bounds.

Closing as implemented on main.

@teknium1 teknium1 closed this Jul 13, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have platform/telegram Telegram bot adapter sweeper:implemented-on-main Sweeper: behavior already present on current main type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants