Skip to content

fix(gateway): preserve Ctrl+C for Windows foreground runs - #22752

Merged
teknium1 merged 1 commit into
NousResearch:mainfrom
helix4u:fix/windows-gateway-ctrl-c
May 9, 2026
Merged

fix(gateway): preserve Ctrl+C for Windows foreground runs#22752
teknium1 merged 1 commit into
NousResearch:mainfrom
helix4u:fix/windows-gateway-ctrl-c

Conversation

@helix4u

@helix4u helix4u commented May 9, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes foreground Windows gateway runs so Ctrl+C / Ctrl+Break stop hermes gateway run again, while keeping detached Windows gateway launches protected from stray console-control broadcasts.

Root cause: run_gateway() unconditionally ignored SIGINT/SIGBREAK on Windows and installed SetConsoleCtrlHandler(NULL, TRUE), which also disabled user Ctrl+C/Ctrl+Break in PowerShell/CMD foreground runs.

The fix scopes that control-event absorption to detached/background gateway launches. Windows service-style launchers now set HERMES_GATEWAY_DETACHED=1; manual foreground runs keep normal interrupt handling.

Related Issue

No GitHub issue yet. Reported from Discord support: Windows PowerShell hermes gateway run could not be killed with Ctrl+C or Ctrl+Break.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • hermes_cli/gateway.py: add Windows foreground-vs-detached detection and only install SIGINT/SIGBREAK/console-control ignore handlers for detached gateway runs.
  • hermes_cli/gateway_windows.py: mark Windows Scheduled Task / Startup / direct detached launches with HERMES_GATEWAY_DETACHED=1.
  • tests/hermes_cli/test_gateway.py: cover both foreground Windows runs preserving Ctrl+C and detached Windows runs absorbing console-control events.

How to Test

  1. On Windows PowerShell, run hermes gateway run.
  2. Wait for the gateway to start.
  3. Press Ctrl+C or Ctrl+Break. The foreground gateway should exit instead of ignoring the keypress.
  4. For the installed/background gateway path, run hermes gateway start or the Scheduled Task path and confirm the gateway stays detached/background-managed.
  5. Run python -m pytest tests/hermes_cli/test_gateway.py -q.

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
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: Windows manual verification pending on second machine; local targeted tests passed on Linux checkout.

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

N/A.

Screenshots / Logs

Targeted test:

python -m pytest tests/hermes_cli/test_gateway.py -q

Result: 27 passed in 6.11s.

Full suite:

scripts/run_tests.sh

Result: 24 failed, 21359 passed, 59 skipped, 238 warnings in 477.78s.

Observed failures were outside the changed Windows gateway signal files/tests, including gateway approval/topic/config, DingTalk card lifecycle, Discord bot filter, auxiliary client, API server defaults, TTS media routing, update flow, Tencent TokenHub context length, interrupt propagation, code execution timeout/interrupt handling, process registry, Tirith marker cleanup, and TTS command timeout tests.

HERMES_HOME was empty before and after the full-suite run.

@helix4u
helix4u marked this pull request as ready for review May 9, 2026 18:36
@teknium1
teknium1 merged commit 9c26297 into NousResearch:main May 9, 2026
10 of 13 checks passed
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery comp/cli CLI entry point, hermes_cli/, setup wizard labels May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants