fix(telegram): raise default command-menu cap to 60 so skills stay visible

The 30-slot default could not fit Hermes's ~50 built-in commands, so
every skill command (and 20 built-ins) were silently dropped from the
Telegram \`/\` menu by default — they only worked when typed manually.
Raising the default to 60 keeps all built-ins plus common skill commands
visible out of the box while staying under Telegram's ~4KB payload limit.
Users can still tune it via platforms.telegram.extra.command_menu.
This commit is contained in:
teknium1 2026-06-23 23:26:07 -07:00 committed by Teknium
parent dbe14ce35d
commit d4be583d98
5 changed files with 19 additions and 14 deletions

View file

@ -742,10 +742,10 @@ platform_toolsets:
# disable_link_previews: false # Set true to suppress Telegram URL previews in bot messages
# rich_messages: false # Bot API 10.1 rich messages (tables/task lists/details/math); default false for copyable legacy MarkdownV2, set true to opt in
# command_menu:
# # Telegram allows up to 100 BotCommands; Hermes defaults to 30 to
# # stay under Telegram's payload-size limits while keeping common
# # commands visible. Values are clamped to 1..100.
# max_commands: 30
# # Telegram allows up to 100 BotCommands; Hermes defaults to 60 so
# # all built-in commands plus common skill commands stay visible
# # while remaining under Telegram's payload-size limit. Clamped 1..100.
# max_commands: 60
# # prepend = user priority first, then Hermes defaults
# # append = Hermes defaults first, then user priority
# # replace = only the list below defines priority

View file

@ -534,7 +534,11 @@ def telegram_bot_commands() -> list[tuple[str, str]]:
return result
_DEFAULT_TELEGRAM_MENU_MAX_COMMANDS = 30
# Telegram allows up to 100 BotCommands. Hermes ships ~50 built-in commands;
# a 60-slot default keeps every built-in plus common skill commands visible in
# the `/` menu while staying comfortably under Telegram's ~4KB payload limit.
# Users can tune this via platforms.telegram.extra.command_menu.max_commands.
_DEFAULT_TELEGRAM_MENU_MAX_COMMANDS = 60
_TELEGRAM_BOT_API_MAX_COMMANDS = 100
_TELEGRAM_PRIORITY_MODES = {"prepend", "append", "replace"}

View file

@ -2427,9 +2427,10 @@ class TelegramAdapter(BasePlatformAdapter):
)
from hermes_cli.commands import telegram_menu_commands, telegram_menu_max_commands
# Telegram allows up to 100 commands but has an undocumented
# payload size limit (~4KB total). Hermes defaults to 30 to
# stay well under the threshold while covering all categories;
# users can tune the cap via platforms.telegram.extra.command_menu.
# payload size limit (~4KB total). Hermes defaults to 60 to
# keep built-ins plus common skill commands visible while
# staying under the threshold; users can tune the cap via
# platforms.telegram.extra.command_menu.
max_commands = telegram_menu_max_commands()
menu_commands, hidden_count = telegram_menu_commands(max_commands=max_commands)
bot_commands = [BotCommand(name, desc) for name, desc in menu_commands]

View file

@ -1245,7 +1245,7 @@ class TestTelegramMenuCommands:
def test_telegram_menu_max_commands_uses_config_with_safe_bounds(self, tmp_path, monkeypatch):
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
assert telegram_menu_max_commands() == 30
assert telegram_menu_max_commands() == 60
(tmp_path / "config.yaml").write_text(
"platforms:\n"
@ -1281,7 +1281,7 @@ class TestTelegramMenuCommands:
" command_menu:\n"
" max_commands: nope\n"
)
assert telegram_menu_max_commands() == 30
assert telegram_menu_max_commands() == 60
def test_telegram_menu_ignores_undocumented_command_menu_paths(self, tmp_path, monkeypatch):
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
@ -1296,7 +1296,7 @@ class TestTelegramMenuCommands:
" max_commands: 9\n"
)
assert telegram_menu_max_commands() == 30
assert telegram_menu_max_commands() == 60
def test_includes_plugin_commands_via_lazy_discovery(self, tmp_path, monkeypatch):
"""Telegram menu generation should discover plugin slash commands on first access."""

View file

@ -81,7 +81,7 @@ Notes:
### Command menu priority and cap (Optional)
Hermes registers its command menu automatically when the Telegram gateway starts. The menu is built from the central slash-command registry plus eligible plugin/skill commands, then capped to a safe default of 30 commands so Telegram accepts the payload reliably.
Hermes registers its command menu automatically when the Telegram gateway starts. The menu is built from the central slash-command registry plus eligible plugin/skill commands, then capped so Telegram accepts the payload reliably. The default cap is 60 commands — enough to keep all built-in commands plus common skill commands visible.
If you have local or plugin commands that should stay visible in Telegram's `/` picker, prioritize them in `~/.hermes/config.yaml`:
@ -90,7 +90,7 @@ platforms:
telegram:
extra:
command_menu:
max_commands: 30
max_commands: 60
priority_mode: prepend # prepend | append | replace
priority:
- my_plugin_command
@ -102,7 +102,7 @@ platforms:
- `append`: keep Hermes defaults first, then your commands
- `replace`: use only your list for priority ordering
Telegram allows up to 100 BotCommands, but large command payloads can fail. Hermes defaults to 30 for reliability and clamps configured values to `1..100`; use `/commands` for the full command list.
Telegram allows up to 100 BotCommands, but large command payloads can fail. Hermes defaults to 60 for reliability and clamps configured values to `1..100`; use `/commands` for the full command list.
## Step 3: Privacy Mode (Critical for Groups)