fix(gateway): resolve Telegram's underscored /commands to skill/plugin 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.
This commit is contained in:
@@ -2112,7 +2112,10 @@ class GatewayRunner:
|
||||
if command:
|
||||
try:
|
||||
from hermes_cli.plugins import get_plugin_command_handler
|
||||
plugin_handler = get_plugin_command_handler(command)
|
||||
# Normalize underscores to hyphens so Telegram's underscored
|
||||
# autocomplete form matches plugin commands registered with
|
||||
# hyphens. See hermes_cli/commands.py:_build_telegram_menu.
|
||||
plugin_handler = get_plugin_command_handler(command.replace("_", "-"))
|
||||
if plugin_handler:
|
||||
user_args = event.get_command_args().strip()
|
||||
import asyncio as _aio
|
||||
@@ -2123,13 +2126,20 @@ class GatewayRunner:
|
||||
except Exception as e:
|
||||
logger.debug("Plugin command dispatch failed (non-fatal): %s", e)
|
||||
|
||||
# Skill slash commands: /skill-name loads the skill and sends to agent
|
||||
# Skill slash commands: /skill-name loads the skill and sends to agent.
|
||||
# resolve_skill_command_key() handles the Telegram underscore/hyphen
|
||||
# round-trip so /claude_code from Telegram autocomplete still resolves
|
||||
# to the claude-code skill.
|
||||
if command:
|
||||
try:
|
||||
from agent.skill_commands import get_skill_commands, build_skill_invocation_message
|
||||
from agent.skill_commands import (
|
||||
get_skill_commands,
|
||||
build_skill_invocation_message,
|
||||
resolve_skill_command_key,
|
||||
)
|
||||
skill_cmds = get_skill_commands()
|
||||
cmd_key = f"/{command}"
|
||||
if cmd_key in skill_cmds:
|
||||
cmd_key = resolve_skill_command_key(command)
|
||||
if cmd_key is not None:
|
||||
# Check per-platform disabled status before executing.
|
||||
# get_skill_commands() only applies the *global* disabled
|
||||
# list at scan time; per-platform overrides need checking
|
||||
|
||||
Reference in New Issue
Block a user