Skip to content

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

@xuezhaojun

Description

@xuezhaojun

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/gatewayGateway runner, session dispatch, deliverysweeper:implemented-on-mainSweeper: behavior already present on current maintype/featureNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions