fix(gateway): bypass active-session guard for gateway-handled slash commands

This commit is contained in:
Xowiek
2026-04-17 04:08:20 +03:00
committed by Teknium
parent d465fc5869
commit 511ed4dacc
5 changed files with 114 additions and 15 deletions

View File

@@ -1579,20 +1579,9 @@ class BasePlatformAdapter(ABC):
# session lifecycle and its cleanup races with the running task
# (see PR #4926).
cmd = event.get_command()
if cmd in (
"approve",
"deny",
"status",
"agents",
"tasks",
"stop",
"new",
"reset",
"background",
"restart",
"queue",
"q",
):
from hermes_cli.commands import should_bypass_active_session
if should_bypass_active_session(cmd):
logger.debug(
"[%s] Command '/%s' bypassing active-session guard for %s",
self.name, cmd, session_key,

View File

@@ -2952,7 +2952,10 @@ class GatewayRunner:
return await self._handle_status_command(event)
# Resolve the command once for all early-intercept checks below.
from hermes_cli.commands import resolve_command as _resolve_cmd_inner
from hermes_cli.commands import (
resolve_command as _resolve_cmd_inner,
should_bypass_active_session as _should_bypass_active_inner,
)
_evt_cmd = event.get_command()
_cmd_def_inner = _resolve_cmd_inner(_evt_cmd) if _evt_cmd else None
@@ -3038,6 +3041,20 @@ class GatewayRunner:
if _cmd_def_inner and _cmd_def_inner.name == "background":
return await self._handle_background_command(event)
# Gateway-handled info/control commands must never fall through to
# the interrupt path. If they are queued as pending text, the
# slash-command safety net discards them before the user sees any
# response.
if _cmd_def_inner and _should_bypass_active_inner(_cmd_def_inner.name):
if _cmd_def_inner.name == "help":
return await self._handle_help_command(event)
if _cmd_def_inner.name == "commands":
return await self._handle_commands_command(event)
if _cmd_def_inner.name == "profile":
return await self._handle_profile_command(event)
if _cmd_def_inner.name == "update":
return await self._handle_update_command(event)
if event.message_type == MessageType.PHOTO:
logger.debug("PRIORITY photo follow-up for session %s — queueing without interrupt", _quick_key[:20])
adapter = self.adapters.get(source.platform)