hermes - ✅(Solved) Fix Feature Request: Add config option to suppress shutdown notifications when no active sessions exist [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#20103Fetched 2026-05-06 06:38:46
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×3cross-referenced ×1

Error Message

For users who schedule routine restarts (e.g. daily 4 AM reboot via cron/systemd timer), this results in a spurious notification every single day that serves no purpose — there's no active task to warn about.

when idle — no running task means nothing to warn about.

Fix Action

Fixed

PR fix notes

PR #20126: fix(gateway): skip home-channel shutdown ping when idle (#20103)

Description (problem / solution / changelog)

Summary

  • Skip the home-channel shutdown broadcast when no session was active and the shutdown is not a user-initiated /restart.
  • Preserves the existing /restart behaviour: home channels are still notified even when idle (existing test enshrines this for ops-watcher heartbeat reasons).
  • Mirrors the symmetric startup gate at _send_home_channel_startup_notifications (gateway/run.py:3332), which only fires when /restart was pending.

The bug

_notify_active_sessions_of_shutdown broadcasts \"⚠️ Gateway shutting down — Your current task will be interrupted.\" to every configured home channel unconditionally. For deployments with a daily systemd-timed reboot of an idle gateway, this produced a spurious daily ping in every home channel — there was no task to interrupt, so the warning carried no signal.

The reporter (#20103) hits this on a Weixin home-channel deployment with a 4 AM systemd reboot.

The fix

In gateway/run.py:_notify_active_sessions_of_shutdown, after the active-session loop and before the home-channel loop, skip the home-channel broadcast when:

  • active == {} (no running agents) and
  • self._restart_requested is False (plain shutdown, not /restart)
if not active and not self._restart_requested:
    logger.info(
        \"No active sessions at shutdown — skipping home-channel notification\"
    )
    return

The /restart path is intentionally preserved because:

  • An existing test (tests/gateway/test_restart_resume_pending.py::test_restart_notifies_home_channel_even_without_active_sessions) explicitly asserts the home channel is notified even with no active sessions on /restart.
  • /restart is user-initiated; ops watchers depend on the heartbeat to know the gateway will be back.

This matches the issue reporter's recommended Option A: a one-shot guarded early-return, no new config knobs.

Test plan

  • Two new tests in tests/gateway/test_restart_notification.py:
    • test_plain_shutdown_skips_home_channel_when_idle — asserts adapter.send is not called when _restart_requested=False and _running_agents={}.
    • test_shutdown_still_pings_home_channel_when_active — asserts the home channel is still notified when at least one session is active in a different chat (regression guard for the home-channel loop entry).
  • Existing test test_restart_notifies_home_channel_even_without_active_sessions still passes — the /restart path is unchanged.
  • Adjacent suites pass: tests/gateway/test_restart_notification.py (23), tests/gateway/test_gateway_shutdown.py, tests/gateway/test_shutdown_cache_cleanup.py, tests/gateway/test_restart_drain.py, tests/gateway/test_restart_resume_pending.py — 114 passed.
  • Regression guard verified: stashing the production fix causes only test_plain_shutdown_skips_home_channel_when_idle to fail with the exact bug behaviour (`adapter.send` called once with the home-channel ping); restoring the fix passes both tests.

Related

Sibling code paths that may need the same fix: none. The startup-side already gates home-channel notifications on restart_notification_pending or delivered_restart_target is not None (gateway/run.py:3332); this PR brings the shutdown side into the same shape. Happy to widen if any other gateway broadcast sites need the same idle-skip treatment.

Changed files

  • gateway/run.py (modified, +15/-0)
  • tests/gateway/test_restart_notification.py (modified, +65/-0)

Code Example

# After notifying active sessions, skip home-channel notification
# when idle — no running task means nothing to warn about.
if not active:
    logger.info("No active sessions — skipping home-channel shutdown notification")
    return
RAW_BUFFERClick to expand / collapse

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

Problem

When the gateway shuts down (e.g. daily scheduled machine reboot via systemd), it unconditionally sends a "⚠️ Gateway shutting down — Your current task will be interrupted." message to all home channels, even when there are no active sessions running.

For users who schedule routine restarts (e.g. daily 4 AM reboot via cron/systemd timer), this results in a spurious notification every single day that serves no purpose — there's no active task to warn about.

Current Behavior

In gateway/run.py, _notify_active_sessions_of_shutdown() does two things:

  1. Notifies sessions with active agents (useful ✅)
  2. Unconditionally notifies all home channels regardless of whether any session is active (noisy ❌)

This means even an idle gateway restart triggers a notification to every configured home channel.

Desired Behavior

Either:

Option A (recommended): Skip home-channel notifications entirely when there are no active sessions. The notification is only meaningful when a task is actually being interrupted.

Option B: Add a config option like agent.shutdown_notify: false (or agent.shutdown_notify_home: false) to allow users to opt out of shutdown notifications to home channels.

Suggested Fix (Option A)

In _notify_active_sessions_of_shutdown(), after the loop that notifies active sessions, add an early return before the home-channel loop:

# After notifying active sessions, skip home-channel notification
# when idle — no running task means nothing to warn about.
if not active:
    logger.info("No active sessions — skipping home-channel shutdown notification")
    return

This keeps the notification useful (it still fires when a task is actually interrupted) but eliminates the noise for scheduled/idle restarts.

Environment

  • Hermes Agent v0.12.0
  • Platform: Weixin (WeChat) home channel
  • Gateway runs as systemd service, machine reboots daily at 4 AM

extent analysis

TL;DR

Modify the _notify_active_sessions_of_shutdown() function to conditionally skip home-channel notifications when there are no active sessions.

Guidance

  • Review the current implementation of _notify_active_sessions_of_shutdown() in gateway/run.py to understand the notification logic.
  • Consider adding a conditional check to skip home-channel notifications when no active sessions exist, as suggested in the issue.
  • Evaluate the trade-offs between the two proposed options: skipping notifications entirely when idle (Option A) or adding a config option to opt out of shutdown notifications (Option B).
  • Test the modified function to ensure it behaves as expected under different scenarios (e.g., with and without active sessions).

Example

if not active:
    logger.info("No active sessions — skipping home-channel shutdown notification")
    return

This code snippet illustrates the suggested fix for Option A, where the function returns early when no active sessions are found.

Notes

The proposed fix assumes that the active variable accurately reflects the presence of active sessions. Additionally, the solution may need to be adapted based on the specific requirements and constraints of the Hermes Agent and Weixin (WeChat) home channel.

Recommendation

Apply workaround by modifying the _notify_active_sessions_of_shutdown() function to conditionally skip home-channel notifications when there are no active sessions, as this approach directly addresses the reported issue and minimizes unnecessary notifications.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix Feature Request: Add config option to suppress shutdown notifications when no active sessions exist [1 pull requests, 1 participants]