fix(gateway): break stuck session resume loops on restart - #7747
Closed
konsisumer wants to merge 1 commit into
Closed
fix(gateway): break stuck session resume loops on restart#7747konsisumer wants to merge 1 commit into
konsisumer wants to merge 1 commit into
Conversation
…ch#7536) When a gateway session gets stuck (hung tool, runaway loop) and the user restarts the gateway, the agent would reload the stuck session transcript and re-enter the same stuck state — creating an unrecoverable loop. Three changes break this cycle: 1. Add `suspended` flag to SessionEntry — when set, the session auto-resets (new session_id, clean transcript) on the next incoming message instead of resuming from where it left off. 2. `/stop` now marks the session as suspended — after force-stopping a stuck agent, the next message starts a fresh conversation instead of replaying the stuck context. 3. Gateway startup suspends all active sessions — any session that was in-flight when the gateway last exited is marked suspended, so it cannot be blindly resumed on restart. Closes NousResearch#7536
konsisumer
marked this pull request as ready for review
April 11, 2026 14:04
teknium1
pushed a commit
that referenced
this pull request
Apr 11, 2026
Cherry-picked from PR #7747 with follow-up fixes: - Narrowed suspend_all_active() to suspend_recently_active() — only suspends sessions updated within the last 2 minutes (likely in-flight), not all sessions which would unnecessarily reset idle users - /stop with no running agent no longer suspends the session; only actual force-stops mark the session for reset
teknium1
pushed a commit
that referenced
this pull request
Apr 11, 2026
Cherry-picked from PR #7747 with follow-up fixes: - Narrowed suspend_all_active() to suspend_recently_active() — only suspends sessions updated within the last 2 minutes (likely in-flight), not all sessions which would unnecessarily reset idle users - /stop with no running agent no longer suspends the session; only actual force-stops mark the session for reset
Contributor
|
Merged via PR #7910. Your commit was cherry-picked onto current main with authorship preserved, plus two follow-up fixes: suspend_all_active() narrowed to only recently-active sessions, and /stop with no running agent no longer suspends. Thanks for the stuck-resume-loop fix! |
Tommyeds
pushed a commit
to Tommyeds/hermes-agent
that referenced
this pull request
Apr 12, 2026
…ch#7536) Cherry-picked from PR NousResearch#7747 with follow-up fixes: - Narrowed suspend_all_active() to suspend_recently_active() — only suspends sessions updated within the last 2 minutes (likely in-flight), not all sessions which would unnecessarily reset idle users - /stop with no running agent no longer suspends the session; only actual force-stops mark the session for reset
angelburgosrosado
pushed a commit
to angelburgosrosado/hermes-agent
that referenced
this pull request
Apr 28, 2026
…ch#7536) Cherry-picked from PR NousResearch#7747 with follow-up fixes: - Narrowed suspend_all_active() to suspend_recently_active() — only suspends sessions updated within the last 2 minutes (likely in-flight), not all sessions which would unnecessarily reset idle users - /stop with no running agent no longer suspends the session; only actual force-stops mark the session for reset
aj-nt
pushed a commit
to aj-nt/hermes-agent
that referenced
this pull request
May 1, 2026
…ch#7536) Cherry-picked from PR NousResearch#7747 with follow-up fixes: - Narrowed suspend_all_active() to suspend_recently_active() — only suspends sessions updated within the last 2 minutes (likely in-flight), not all sessions which would unnecessarily reset idle users - /stop with no running agent no longer suspends the session; only actual force-stops mark the session for reset
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
…ch#7536) Cherry-picked from PR NousResearch#7747 with follow-up fixes: - Narrowed suspend_all_active() to suspend_recently_active() — only suspends sessions updated within the last 2 minutes (likely in-flight), not all sessions which would unnecessarily reset idle users - /stop with no running agent no longer suspends the session; only actual force-stops mark the session for reset
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
…ch#7536) Cherry-picked from PR NousResearch#7747 with follow-up fixes: - Narrowed suspend_all_active() to suspend_recently_active() — only suspends sessions updated within the last 2 minutes (likely in-flight), not all sessions which would unnecessarily reset idle users - /stop with no running agent no longer suspends the session; only actual force-stops mark the session for reset
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
…ch#7536) Cherry-picked from PR NousResearch#7747 with follow-up fixes: - Narrowed suspend_all_active() to suspend_recently_active() — only suspends sessions updated within the last 2 minutes (likely in-flight), not all sessions which would unnecessarily reset idle users - /stop with no running agent no longer suspends the session; only actual force-stops mark the session for reset
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.
Summary
Fixes #7536 — when a gateway session gets stuck (hung terminal command, runaway tool loop), restarting the gateway re-enters the stuck state because the agent reloads the session transcript and resumes the stuck task. This creates an unrecoverable loop.
Changes
suspendedflag onSessionEntry— a new persisted boolean that, when set, causesget_or_create_session()to auto-reset the session (new session_id, clean transcript) on the next incoming message./stopmarks session as suspended — both the early intercept (for truly hung agents) and the normal command handler now suspend the session, so the user's next message starts fresh instead of replaying stuck context.How it works
/stop→ session is suspendedget_or_create_session()seessuspended=True→ auto-resets to a new session → fresh conversation/stoppossible) → on restart,suspend_all_active()marks every existing session as suspended → same auto-reset behaviorWhat's NOT in this PR (future work)
hermes gateway --cleanCLI flag (issue suggestion Support passing morph snapshot id #2)drop_pending_updates=Trueon fresh startTest plan
tests/gateway/test_session.pytests passtest_session_reset_notify+test_session_reset_fixtests pass