fix(gateway): skip home-channel shutdown broadcast when idle - #931
Open
hashbender wants to merge 1 commit into
Open
fix(gateway): skip home-channel shutdown broadcast when idle#931hashbender wants to merge 1 commit into
hashbender wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Skips the home-channel "⚠️ Gateway shutting down — Your current task will be interrupted." broadcast when the gateway shuts down with no running agents.
_notify_active_sessions_of_shutdownnotifies every configured home channel on every external stop or restart (systemd, cron auto-updates), even when nothing is running. The warning is false in that case: there is no task to interrupt. Deployments that restart the gateway on a schedule get the ping on every cycle. NousResearch#20103 and NousResearch#29846 both report this; my two production gateways logged ten of these pings since June 16, all while idle, doubled because both gateways share one home chat.The config opt-out that closed NousResearch#20103 (
gateway_restart_notification: false) silences the idle pings, but it also silences the interruption warning for chats with active work, the one message that carries real information. Users pick between spam and losing real warnings. This change drops the idle broadcast and keeps everything else.In-chat
/restartalready suppresses the idle warning (test_idle_in_chat_restart_does_not_send_interruption_warning). This applies the same rule to external shutdowns. The drain-marker gate from NousResearch#54824 still covers force-interrupt drains, which reach the home-channel section with active sessions.Prior art: NousResearch#20126 proposed this same idle skip and its author closed it after it went stale unreviewed, inviting a fresh attempt. NousResearch#20943 (open) goes further and stops all home-channel interruption broadcasts; this PR is narrower and keeps the broadcast whenever sessions are interrupted.
Related Issue
Refs NousResearch#20103, NousResearch#29846 (both closed via the config opt-out; this fixes the default behavior). Supersedes stale NousResearch#20126.
Type of Change
Changes Made
gateway/run.py: return early from the home-channel broadcast in_notify_active_sessions_of_shutdownwhenactiveis empty, after the in-chat-restart skip and before the drain-marker gate. Logs the skip at INFO.tests/gateway/test_gateway_shutdown.py: addtest_idle_external_shutdown_skips_home_channel_notification. It fails onmain(the home channel receives the warning) and passes with this change.How to Test
python -m pytest tests/gateway/test_gateway_shutdown.py tests/gateway/test_restart_notification.py -q→ 48 passed.gateway/run.pyonly and rerun the new test: it fails with the home-chat send captured.systemctl --user restart hermes-gatewaywhile idle. The gateway logs "Skipping home-channel shutdown notification: no active sessions to interrupt" and sends nothing. Restart during a running task and the affected chat still gets the warning. Verified on two production gateways.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass (full suite running now; focused gateway suites are 48/48 — will tick and mark ready when it finishes)Mirror-of: NousResearch#57164
NousResearch#57164