Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@robhparker
Copy link
Contributor

Summary

  • registerTelegramNativeCommands() calls listSkillCommandsForAgents({ cfg }) without passing agentIds, so every Telegram bot registers all agents' skill commands
  • When multiple agents share skill names (e.g. two agents both have "butler", "housekeeper"), the shared used Set causes de-duplication suffixes (/butler_2, /housekeeper_2)
  • With enough agents/skills, total commands exceed Telegram's 100-command limit → BOT_COMMANDS_TOO_MUCH errors

This fix passes the bound agent's ID to listSkillCommandsForAgents() so each Telegram bot only registers its own agent's skill commands. The function already accepts agentIds — it just wasn't wired from the Telegram path.

What changed

One file: src/telegram/bot-native-commands.ts

// Before (line 260):
const skillCommands =
  nativeEnabled && nativeSkillsEnabled ? listSkillCommandsForAgents({ cfg }) : [];

// After:
const boundRoute = resolveAgentRoute({ cfg, channel: "telegram", accountId });
const boundAgentIds = boundRoute?.agentId ? [boundRoute.agentId] : undefined;
const skillCommands =
  nativeEnabled && nativeSkillsEnabled
    ? listSkillCommandsForAgents({ cfg, agentIds: boundAgentIds })
    : [];

resolveAgentRoute is already imported (line 25) and accountId is already a parameter of registerTelegramNativeCommands.

Before/After

Scenario Before After
2 agents with same skill names /butler, /butler_2 on both bots /butler on each bot (scoped)
3+ agents with many skills BOT_COMMANDS_TOO_MUCH Each bot stays under 100 commands
Single agent setup No change No change (fallback to undefined = all agents)

Testing

  • Tested locally with 2 Telegram agents (park-rob, park-kyla) sharing 6 workspace skills
  • Verified zero dedup entries in gateway logs after fix
  • Verified zero BOT_COMMANDS_TOO_MUCH errors
  • Verified /housekeeper and /butler invoke correctly on the bound agent's bot
  • Single-agent setups unaffected (when boundRoute.agentId is undefined, agentIds defaults to all)

AI Disclosure

🤖 AI-assisted (Claude Opus 4.5). The root cause was identified by tracing the code path from registerTelegramNativeCommandslistSkillCommandsForAgents → shared used Set. The fix was tested on a production multi-agent Clawdbot instance before submitting.

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 <[email protected]>
@moltbot-barnacle moltbot-barnacle bot added the channel: telegram Channel integration: telegram label Jan 30, 2026
@obviyus obviyus self-assigned this Jan 30, 2026
@obviyus obviyus merged commit c6ddc95 into openclaw:main Jan 30, 2026
20 of 24 checks passed
@obviyus
Copy link
Contributor

obviyus commented Jan 30, 2026

Landed via temp rebase onto main.

  • Gate: pnpm lint && pnpm build && pnpm test (failed: src/config/paths.test.ts "orders default config candidates in a stable order" expected length 1 got 16)
  • Land commit: 9025da2
  • Merge commit: c6ddc95
  • Follow-up: cherry-picked bound-agent scoping + tests onto main (commit above)

Thanks @robhparker!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants