fix(gateway): replace blanket internal-restart guard with loop detector - #35815
Closed
drzeast-png wants to merge 1 commit into
Closed
fix(gateway): replace blanket internal-restart guard with loop detector#35815drzeast-png wants to merge 1 commit into
drzeast-png wants to merge 1 commit into
Conversation
The current _HERMES_GATEWAY guard (PR NousResearch#35679) blanket-refuses all stop/ restart commands from inside the gateway process. This prevents legitimate manual restarts (e.g. from WeChat, Telegram) while KeepAlive is active, forcing users to SSH in or use an external terminal. Replace with a smarter loop detector that tracks restart timestamps in a persistent file. If ≥3 stop/restart attempts occur in a 60s sliding window, a KeepAlive respawn cycle is detected and the operation is refused. A single manual restart always succeeds. This is defense-in-depth against the original issue NousResearch#30719 (cron + KeepAlive respawn loop) without the false-positive rejection of valid manual restarts. The tracker file survives process death, so cron-triggered restarts are counted across respawns.
Author
|
Superseded — the loop-detector variant has been replaced with a more direct approach. See the new PR which simply drops the blanket guard entirely (Trust launchd KeepAlive as the only respawn policy). Rationale for switching from loop-detector → drop-guard:
Closing this in favor of the simpler approach. Thanks to anyone who took a look. |
4 tasks
drzeast-png
pushed a commit
to drzeast-png/hermes-agent
that referenced
this pull request
Jun 4, 2026
…estarts Allow restart/stop from inside the gateway (e.g. via WeChat/Telegram) so the user can manage the gateway remotely. Trust launchd KeepAlive as the only respawn policy; the upstream blanket guard (NousResearch#35679) blocks legitimate manual restarts. Supersedes the still-open PR NousResearch#35815 (loop-detector variant).
drzeast-png
pushed a commit
to drzeast-png/hermes-agent
that referenced
this pull request
Jun 4, 2026
…estarts Allow restart/stop from inside the gateway (e.g. via WeChat/Telegram) so the user can manage the gateway remotely. Trust launchd KeepAlive as the only respawn policy; the upstream blanket guard (NousResearch#35679) blocks legitimate manual restarts. Supersedes the still-open PR NousResearch#35815 (loop-detector variant).
drzeast-png
pushed a commit
to drzeast-png/hermes-agent
that referenced
this pull request
Jun 5, 2026
…estarts Allow restart/stop from inside the gateway (e.g. via WeChat/Telegram) so the user can manage the gateway remotely. Trust launchd KeepAlive as the only respawn policy; the upstream blanket guard (NousResearch#35679) blocks legitimate manual restarts. Supersedes the still-open PR NousResearch#35815 (loop-detector variant).
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.
Problem
The current
_HERMES_GATEWAYguard (introduced in PR #35679 to fix #30719) blanket-refuses allstop/restartcommands from inside the gateway process. This prevents legitimate manual restarts (e.g. from WeChat, Telegram) while KeepAlive is active, forcing users to SSH in or use an external terminal.Additionally, this guard does not fully prevent the original cron + KeepAlive respawn loop — cron jobs run as subprocesses that inherit
_HERMES_GATEWAY=1, but the guard triggers on the first restart attempt, not on the loop pattern itself.Solution
Replace the blanket guard with a loop detector that tracks restart/stop timestamps in a persistent file (
.gateway-restart-trackerunderHERMES_HOME). Since the file lives on disk, it survives process death — critical for catching KeepAlive respawn cycles.How it works
stop/restartcall from inside the gateway (_HERMES_GATEWAY==1) checks the trackerBehavior comparison
Recovery
When the loop detector triggers, the error message includes recovery instructions:
launchctl unload ~/Library/LaunchAgents/ai.hermes.gateway.plistCheck
~/.hermes/.gateway-restart-trackerto inspect recent timestamps.