Skip to content

The agent that grows with you

fix(gateway): tell Slack users /hermes discard in the lost-turn pause notice

Tekniumdf8769298f43
diff --git a/gateway/session_ingress.py b/gateway/session_ingress.py
index 0b41a51b91e..992c2a90895 100644
--- a/gateway/session_ingress.py
+++ b/gateway/session_ingress.py
@@ -200,8 +200,11 @@ def pause_notice(authority, ref, reason):
if reason == 'unknown_execution':
# GW-10: the way out is in this chat. /discard acknowledges the lost turn (never replayed)
# through the same fenced resolve_unknown as Desktop/TUI, and the saved messages then run.
+ # Slack registers no native /discard (its slash cap): the umbrella `/hermes discard` reaches it.
+ slack = getattr(getattr(live.source, 'platform', None), 'value', None) == 'slack'
+ discard = '/hermes discard' if slack else '/discard'
return ('⏸️ This conversation is paused: a previous turn did not finish when Hermes restarted, '
- 'and only you know whether to send it again. Your message is saved. Send /discard to drop '
+ f'and only you know whether to send it again. Your message is saved. Send {discard} to drop '
'the lost turn and continue (it is not re-run), or /reset to start a fresh conversation.')
cause = f'a queued message could not be re-authorized ({reason})'
return (f'⏸️ This conversation is paused: {cause}. Your message is saved but will not be answered here. '
diff --git a/tests/gateway/test_messaging_discard_reach.py b/tests/gateway/test_messaging_discard_reach.py
new file mode 100644
index 00000000000..57bc0daa893
--- /dev/null
+++ b/tests/gateway/test_messaging_discard_reach.py
@@ -0,0 +1,20 @@
+"""Messaging ``/discard`` reaches every lost turn it promises to (review #141357, GW-10).
+
+Slack has no native ``/discard`` (its slash cap), so the pause notice must name ``/hermes discard``;
+a conversation brought back by ``/resume`` after a restart is not in the owner's live map, and
+``/discard`` must still find its lost turn. Real runner dispatch and SQLite; transport stubbed."""
+
+
+def test_slack_pause_notice_names_the_registered_umbrella_command():
+ from types import SimpleNamespace
+ from gateway.config import Platform
+ from gateway.session import SessionSource
+ from gateway.session_contract import SessionRef
+ from gateway.session_ingress import pause_notice
+ from hermes_cli.commands_platforms import slack_native_slashes, slack_subcommand_map
+ assert 'discard' not in [row[0].lstrip('/') for row in slack_native_slashes()]
+ assert slack_subcommand_map().get('discard')
+ for platform, expected in ((Platform.SLACK, '/hermes discard'), (Platform.TELEGRAM, 'Send /discard')):
+ live = SimpleNamespace(source=SessionSource(platform=platform, chat_id='D42'), pause_notified=False)
+ notice = pause_notice(SimpleNamespace(sessions={'s': live}), SessionRef('p', 's'), 'unknown_execution')
+ assert expected in notice, notice