Skip to content

fix(gateway): resolve Telegram's underscored /commands to skill/plugin keys#5205

Closed
el-analista wants to merge 3 commits into
NousResearch:mainfrom
el-analista:fix/gateway-slash-command-underscore-hyphen
Closed

fix(gateway): resolve Telegram's underscored /commands to skill/plugin keys#5205
el-analista wants to merge 3 commits into
NousResearch:mainfrom
el-analista:fix/gateway-slash-command-underscore-hyphen

Conversation

@el-analista

Copy link
Copy Markdown
Contributor

Summary

  • Telegram's Bot API disallows hyphens in command names, so _build_telegram_menu registers /claude-code as /claude_code. When users tap it from autocomplete, the gateway's direct lookup against skill_cmds (keyed on the hyphenated form) misses and silently falls through to the LLM as plain text — the model typically reacts by calling delegate_task, spawning a Hermes subagent instead of invoking the intended skill.
  • Normalize underscores to hyphens on skill and plugin command dispatch, matching the existing pattern in _check_unavailable_skill (gateway/run.py:350).
  • Add resolve_skill_command_key() helper in agent/skill_commands.py with regression tests covering both the hyphen and underscore forms.

Repro

  1. Install the claude-code skill (shipped in skills/autonomous-ai-agents/claude-code/).
  2. Connect Hermes to Telegram.
  3. Tap /claude_code <anything> from Telegram autocomplete.

Before: falls through to the LLM, which usually calls delegate_task.
After: resolves to the claude-code skill and loads it normally.

Test plan

  • python -m pytest tests/agent/test_skill_commands.py -q — 23 passed (includes 6 new tests in TestResolveSkillCommandKey)
  • Verified the hyphenated form (/claude-code) still resolves directly
  • Verified unknown commands still return None and fall through to _check_unavailable_skill

analista added 3 commits April 5, 2026 09:35
…n keys

Telegram's Bot API disallows hyphens in command names, so
_build_telegram_menu registers /claude-code as /claude_code. When the
user taps it from autocomplete, the gateway dispatch did a direct
lookup against skill_cmds (keyed on the hyphenated form) and missed,
silently falling through to the LLM as plain text. The model would
then typically call delegate_task, spawning a Hermes subagent instead
of invoking the intended skill.

Normalize underscores to hyphens in skill and plugin command lookup,
matching the existing pattern in _check_unavailable_skill.
…e LLM

Previously, typing a /command that isn't a built-in, plugin, or skill
would silently fall through to the LLM as plain text. The model often
interprets it as a loose instruction and invents unrelated tool calls —
e.g. a stray /claude_code slipped through and the model fabricated a
delegate_task invocation that got stuck in an OAuth loop.

Now we check GATEWAY_KNOWN_COMMANDS after the skill / plugin /
unavailable-skill lookups and return an actionable message pointing the
user at /commands. The user gets feedback, and the agent doesn't waste
a round-trip guessing what /foo-bar was supposed to mean.
The warning said 'forwarding as plain text' but the code returns a
user-facing error reply instead of forwarding. Describe what actually
happens.
@teknium1

teknium1 commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Merged via PR #5288 (consolidated bugfix salvage). Your commit(s) were cherry-picked onto current main with your authorship preserved in git log. Thanks @el-analista for the fix!

@teknium1 teknium1 closed this Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants