fix(telegram): scope skill commands to bound agent per bot

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 <noreply@anthropic.com>
This commit is contained in:
robhparker
2026-01-29 23:15:33 -05:00
committed by Ayaan Zaidi
parent 28f8d00e9f
commit c6ddc95fc0

View File

@@ -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" })
: [];