← Back to PRs

#14991: fix(telegram): deduplicate skill commands by skillName to prevent BOT_COMMANDS_TOO_MUCH

by smartchainark open 2026-02-12 21:02 View on GitHub →
channel: telegram stale size: S
## Summary - Deduplicate skill commands by `skillName` in `registerTelegramNativeCommands` before building the Telegram menu — when multiple agents load the same skill, `listSkillCommandsForAgents()` appends `_2`/`_3`/`_4` suffixes that inflate command count beyond Telegram's 100-command limit - Only the first occurrence of each skill is registered; duplicate entries from other agents are dropped - `listSkillCommandsForAgents()` itself is untouched — other channels (Slack, Discord) and internal routing are unaffected Fixes #5787, #10875, #14737. ## Test plan - [x] New test: verifies `bird_2`, `bird_3`, `notion_2` are filtered out, only `bird` and `notion` registered - [x] New test: 120 entries (30 skills × 4 duplicates) dedup to 30 — no truncation warning triggered - [x] Existing 3 tests continue to pass (binding scoping, unscoped, truncation) - [x] `pnpm check` passes (formatting, type check, lint) - [ ] Manual: restart gateway, confirm `getMyCommands` returns unique commands without suffixes 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR updates Telegram native command registration to deduplicate skill-based commands by `skillName` before building the `/` command menu. This avoids the `listSkillCommandsForAgents()` suffixing behavior (`_2`, `_3`, …) inflating the command count and triggering Telegram’s 100-command limit error (`BOT_COMMANDS_TOO_MUCH`). The change is localized to `registerTelegramNativeCommands` in `src/telegram/bot-native-commands.ts` and adds tests in `src/telegram/bot-native-commands.test.ts` to ensure duplicate skill entries are filtered and that deduplication prevents unnecessary truncation warnings. Other channels and the underlying skill command listing logic are unchanged. <h3>Confidence Score: 4/5</h3> - This PR is safe to merge with low risk. - The change is small and localized (Telegram menu building only), and the dedup key (`skillName`) is a required string type. Added tests directly cover the new behavior and the max-command-limit interaction. I couldn’t execute the test suite in this environment due to missing pnpm, so confidence is slightly reduced. - src/telegram/bot-native-commands.ts (dedup behavior in production); src/telegram/bot-native-commands.test.ts (ensure tests pass in CI) <sub>Last reviewed commit: 50a99c9</sub> <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs