hermes-agent/gateway/platforms
Teknium eb7c408445
fix(gateway): /stop and /new bypass Level 1 active-session guard (#5765)
* fix(gateway): /stop and /new bypass Level 1 active-session guard

The base adapter's Level 1 guard intercepted ALL messages while an
agent was running, including /stop and /new. These commands were queued
as pending messages instead of being dispatched to the gateway runner's
Level 2 handler. When the agent eventually stopped (via the interrupt
mechanism), the command text leaked into the conversation as a user
message — the model would receive '/stop' as input and respond to it.

Fix: Add /stop, /new, and /reset to the bypass set in base.py alongside
/approve, /deny, and /status. Consolidate the three separate bypass
blocks into one. Commands in the bypass set are dispatched inline to the
gateway runner, where Level 2 handles them correctly (hard-kill for
/stop, session reset for /new).

Also add a safety net in _run_agent's pending-message processing: if the
pending text resolves to a known slash command, discard it instead of
passing it to the agent. This catches edge cases where command text
leaks through the interrupt_message fallback.

Refs: #5244

* test: regression tests for command bypass of active-session guard

17 tests covering:
- /stop, /new, /reset bypass the Level 1 guard when agent is running
- /approve, /deny, /status bypass (existing behavior, now tested)
- Regular text and unknown commands still queued (not bypassed)
- File paths like '/path/to/file' not treated as commands
- Telegram @botname suffix handled correctly
- Safety net command resolution (resolve_command detects known commands)
2026-04-07 00:53:45 -07:00
..
__init__.py Enhance CLI with multi-platform messaging integration and configuration management 2026-02-02 19:01:51 -08:00
ADDING_A_PLATFORM.md docs: finish cron terminology cleanup 2026-03-14 19:20:58 -07:00
api_server.py fix(gateway): wrap cron helpers with staticmethod to prevent self-binding 2026-04-05 12:31:10 -07:00
base.py fix(gateway): /stop and /new bypass Level 1 active-session guard (#5765) 2026-04-07 00:53:45 -07:00
dingtalk.py fix(dingtalk): requirements check passes with only one credential set 2026-03-17 03:50:45 -07:00
discord.py fix(discord): remove default selection from model picker provider dropdown 2026-04-06 23:06:33 -07:00
email.py fix(email): close SMTP and IMAP connections on failure (#3804) 2026-03-29 15:38:32 -07:00
feishu.py feat(gateway): add per-group access control for Feishu 2026-04-06 16:54:16 -07:00
homeassistant.py fix(gateway): add request timeouts to HA, Email, Mattermost, SMS adapters (#3258) 2026-03-26 14:36:07 -07:00
matrix.py fix(matrix): hard-fail E2EE when python-olm missing + stable MATRIX_DEVICE_ID 2026-04-06 16:54:16 -07:00
mattermost.py fix: detect correct message type from file mime instead of blanket DOCUMENT 2026-04-06 16:49:45 -07:00
signal.py fix(signal): implement send_image_file, send_voice, and send_video for MEDIA: tag delivery 2026-04-06 11:41:34 -07:00
slack.py feat(gateway): Enable Slack thread replies without explicit @mentions 2026-04-06 21:27:16 -07:00
sms.py fix: store asyncio task references to prevent GC mid-execution (#3267) 2026-03-26 14:36:24 -07:00
telegram.py feat(telegram): paginated model picker with Next/Prev navigation 2026-04-06 23:10:40 -07:00
telegram_network.py fix(security): reject private and loopback IPs in Telegram DoH fallback (#4129) 2026-03-30 18:53:24 -07:00
webhook.py feat(webhook): add {__raw__} template token and thread_id passthrough for forum topics 2026-04-06 16:42:52 -07:00
wecom.py feat(gateway): add WeCom (Enterprise WeChat) platform support (#3847) 2026-03-29 21:29:13 -07:00
whatsapp.py fix(whatsapp): add free_response_chats, mention stripping, and interactive message unwrapping 2026-04-03 01:16:39 -07:00