From 60ecde8ac7d4b6b82bb80b411629947d0993d88b Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Mon, 30 Mar 2026 11:21:13 -0700 Subject: [PATCH] fix: fit all 100 commands in Telegram menu with 40-char descriptions (#4010) * fix: truncate skill descriptions to 100 chars in Telegram menu * fix: 40-char desc cap + 100 command limit for Telegram menu setMyCommands has an undocumented total payload size limit. 50 commands with 256-char descriptions failed, 50 with 100-char worked, and 100 with 40-char descriptions also works (~5300 total chars). Truncate skill descriptions to 40 chars in the menu picker and set cap back to 100. Full descriptions available via /commands. --- gateway/platforms/telegram.py | 7 ++++--- hermes_cli/commands.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gateway/platforms/telegram.py b/gateway/platforms/telegram.py index ac3efd92..db1b1943 100644 --- a/gateway/platforms/telegram.py +++ b/gateway/platforms/telegram.py @@ -623,9 +623,10 @@ class TelegramAdapter(BasePlatformAdapter): try: from telegram import BotCommand from hermes_cli.commands import telegram_menu_commands - # Telegram docs say 100, but setMyCommands returns - # BOT_COMMANDS_TOO_MUCH above ~60 due to metadata overhead. - menu_commands, hidden_count = telegram_menu_commands(max_commands=50) + # Telegram allows up to 100 commands but has an undocumented + # payload size limit. Skill descriptions are truncated to 40 + # chars in telegram_menu_commands() to fit 100 commands safely. + menu_commands, hidden_count = telegram_menu_commands(max_commands=100) await self._bot.set_my_commands([ BotCommand(name, desc) for name, desc in menu_commands ]) diff --git a/hermes_cli/commands.py b/hermes_cli/commands.py index f043ec73..a1443262 100644 --- a/hermes_cli/commands.py +++ b/hermes_cli/commands.py @@ -399,9 +399,10 @@ def telegram_menu_commands(max_commands: int = 100) -> tuple[list[tuple[str, str continue # hub-installed, not built-in name = cmd_key.lstrip("/").replace("-", "_") desc = info.get("description", "") - # Telegram descriptions max 256 chars - if len(desc) > 256: - desc = desc[:253] + "..." + # Keep descriptions short — setMyCommands has an undocumented + # total payload limit. 40 chars fits 100 commands safely. + if len(desc) > 40: + desc = desc[:37] + "..." all_commands.append((name, desc)) except Exception: pass