From c6ddc95fc0d514758087ca1020c04c49caeee63f Mon Sep 17 00:00:00 2001 From: robhparker Date: Thu, 29 Jan 2026 23:15:33 -0500 Subject: [PATCH] fix(telegram): scope skill commands to bound agent per bot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit registerTelegramNativeCommands() calls listSkillCommandsForAgents() without passing agentIds, causing ALL agents' skill commands to be registered on EVERY Telegram bot. When multiple agents share skill names (e.g. two agents both have a "butler" skill), the shared `used` Set in listSkillCommandsForAgents causes de-duplication suffixes (_2, _3) and all commands appear on every bot regardless of agent binding. This fix uses the existing resolveAgentRoute() (already imported) to find the bound agent for the current Telegram accountId, then passes that agentId to listSkillCommandsForAgents(). The function already accepts an optional agentIds parameter — it just wasn't wired from the Telegram registration path. Before: All agents' skill commands registered on every Telegram bot, causing /butler_2, /housekeeper_2 dedup suffixes and potential BOT_COMMANDS_TOO_MUCH errors when total exceeds 100. After: Each Telegram bot only registers skill commands for its own bound agent. No cross-agent dedup, no command limit overflow. Co-Authored-By: Claude Opus 4.5 --- src/telegram/bot-native-commands.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/telegram/bot-native-commands.ts b/src/telegram/bot-native-commands.ts index 5f37b81dc..c4b78a09a 100644 --- a/src/telegram/bot-native-commands.ts +++ b/src/telegram/bot-native-commands.ts @@ -257,8 +257,12 @@ export const registerTelegramNativeCommands = ({ shouldSkipUpdate, opts, }: RegisterTelegramNativeCommandsParams) => { + const boundRoute = resolveAgentRoute({ cfg, channel: "telegram", accountId }); + const boundAgentIds = boundRoute?.agentId ? [boundRoute.agentId] : undefined; const skillCommands = - nativeEnabled && nativeSkillsEnabled ? listSkillCommandsForAgents({ cfg }) : []; + nativeEnabled && nativeSkillsEnabled + ? listSkillCommandsForAgents({ cfg, agentIds: boundAgentIds }) + : []; const nativeCommands = nativeEnabled ? listNativeCommandSpecsForConfig(cfg, { skillCommands, provider: "telegram" }) : [];