Skip to content

The agent that grows with you

fix(gateway): a restart drain tells the platform user to wait, not to /reset

teknium10077ea733ffe
diff --git a/gateway/session_ingress.py b/gateway/session_ingress.py
index 47cf7adef73..c664c46143f 100644
--- a/gateway/session_ingress.py
+++ b/gateway/session_ingress.py
@@ -33,6 +33,9 @@ def pause_notice(authority, ref, reason):
if live.pause_notified:
return None
live.pause_notified = True
+ if reason == 'runtime_draining':
+ # Transient: the row runs when the restarted owner drains it, so /reset would be wrong advice.
+ return '⏳ Hermes is restarting — your message is saved and will be answered when it is back.'
if reason == 'unknown_execution':
cause = 'a previous turn did not finish when Hermes restarted, so nothing queued after it will run'
else:
diff --git a/tests/gateway/test_native_pause_notice.py b/tests/gateway/test_native_pause_notice.py
index 2ba4abc145f..7e760f926b5 100644
--- a/tests/gateway/test_native_pause_notice.py
+++ b/tests/gateway/test_native_pause_notice.py
@@ -49,6 +49,13 @@ async def test_paused_fifo_releases_the_messaging_waiter_with_one_notice_per_epi
replies = await asyncio.wait_for(asyncio.gather(first, second), 5)
assert sum(r is not None and PAUSE_MARKER in r for r in replies) == 1, replies
assert executed == []
+ # A restart drain is transient: the saved row runs on the next owner, so the notice must
+ # not tell the user to /reset (that would discard the very message that is about to run).
+ from gateway.session_ingress import pause_notice
+ authority.sessions['s'].pause_notified = False
+ draining = pause_notice(authority, ref, 'runtime_draining')
+ assert 'restarting' in draining and '/reset' not in draining, draining
+ authority.sessions['s'].pause_notified = False
# The operator resumes the FIFO; the saved followers run, no new notice was owed.
viewer = AuthorityConnection(authority, Peer(), {'user_id': 'human'})
await viewer.dispatch({'id': 1, 'method': 'prompt.resolve_unknown', 'params': {