From a656dcc19969962cb601b3ba3b66b1310665433f Mon Sep 17 00:00:00 2001 From: Claude Code Date: Mon, 9 Feb 2026 06:21:54 +0100 Subject: [PATCH] fix(telegram): truncate commands to 100 to avoid BOT_COMMANDS_TOO_MUCH Telegram Bot API limits setMyCommands to 100 commands per scope. When users have many skills installed (~15+), the combined native + plugin + custom commands can exceed this limit, causing a 400 error on every gateway restart. Truncate the command list to 100 (native commands first, then plugins, then custom) and log a warning instead of failing the registration. Fixes #11567 --- src/telegram/bot-native-commands.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/telegram/bot-native-commands.ts b/src/telegram/bot-native-commands.ts index d004650c2..e4f3538c3 100644 --- a/src/telegram/bot-native-commands.ts +++ b/src/telegram/bot-native-commands.ts @@ -358,7 +358,7 @@ export const registerTelegramNativeCommands = ({ existingCommands.add(normalized); pluginCommands.push({ command: normalized, description }); } - const allCommands: Array<{ command: string; description: string }> = [ + const allCommandsFull: Array<{ command: string; description: string }> = [ ...nativeCommands.map((command) => ({ command: command.name, description: command.description, @@ -366,6 +366,15 @@ export const registerTelegramNativeCommands = ({ ...pluginCommands, ...customCommands, ]; + // Telegram Bot API limits commands to 100 per scope. + // Truncate with a warning rather than failing with BOT_COMMANDS_TOO_MUCH. + const TELEGRAM_MAX_COMMANDS = 100; + if (allCommandsFull.length > TELEGRAM_MAX_COMMANDS) { + runtime.log?.( + `telegram: truncating ${allCommandsFull.length} commands to ${TELEGRAM_MAX_COMMANDS} (Telegram Bot API limit)`, + ); + } + const allCommands = allCommandsFull.slice(0, TELEGRAM_MAX_COMMANDS); // Clear stale commands before registering new ones to prevent // leftover commands from deleted skills persisting across restarts (#5717).