Skip to content

fix(gateway): skip home-channel shutdown broadcast when idle - #931

Open
hashbender wants to merge 1 commit into
mainfrom
mirror/pr-57164
Open

fix(gateway): skip home-channel shutdown broadcast when idle#931
hashbender wants to merge 1 commit into
mainfrom
mirror/pr-57164

Conversation

@hashbender

Copy link
Copy Markdown
Owner

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_shutdown notifies 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 /restart already 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

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • gateway/run.py: return early from the home-channel broadcast in _notify_active_sessions_of_shutdown when active is empty, after the in-chat-restart skip and before the drain-marker gate. Logs the skip at INFO.
  • tests/gateway/test_gateway_shutdown.py: add test_idle_external_shutdown_skips_home_channel_notification. It fails on main (the home channel receives the warning) and passes with this change.

How to Test

  1. python -m pytest tests/gateway/test_gateway_shutdown.py tests/gateway/test_restart_notification.py -q → 48 passed.
  2. Revert gateway/run.py only and rerun the new test: it fails with the home-chat send captured.
  3. Live on a systemd deployment: systemctl --user restart hermes-gateway while 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

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass (full suite running now; focused gateway suites are 48/48 — will tick and mark ready when it finishes)
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)

Mirror-of: NousResearch#57164
NousResearch#57164

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Add config option to suppress shutdown notifications when no active sessions exist

1 participant