fix(gateway): add freshness gate to resume_pending sessions - #46963
Closed
vanthinh6886 wants to merge 1 commit into
Closed
fix(gateway): add freshness gate to resume_pending sessions#46963vanthinh6886 wants to merge 1 commit into
vanthinh6886 wants to merge 1 commit into
Conversation
…ession When a session has resume_pending=True but the freshness window has expired (default 1 hour), the session is a zombie — the auto-recovery turn either never ran or failed. Previously, get_or_create_session() returned the stale session unconditionally, causing context bleed where the agent would respond with old conversation context. Fix: check last_resume_marked_at against HERMES_AUTO_CONTINUE_FRESHNESS window. If expired, fall through to auto-reset with reason "resume_pending_expired" instead of returning the stale entry. Fixes NousResearch#46934
This was referenced Jun 25, 2026
Contributor
|
Merged via #56264 (commit a1f62f4) — your commit was cherry-picked onto current main with your authorship preserved in git log. Thanks! Note: the exact bug your PR targeted (the unconditional |
crayfish-ai
added a commit
to crayfish-ai/hermes-agent
that referenced
this pull request
Jul 26, 2026
When a session's resume_pending marker outlasts the freshness window, the scheduler skips auto-resuming it but leaves the stale flag in sessions.json. Over multiple restarts, these accumulate as zombie entries. On startup, the scheduler now calls clear_resume_pending() for each expired marker so it doesn't persist. This is a defense-in-depth complement to the freshness gate in get_or_create_session() (PR NousResearch#46963), which prevents stale sessions from being served to users at message time. Together they close the resume_pending residual accumulation loop. Fixes NousResearch#46934
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.
Fixes #46934
When the gateway restarts after a crash, sessions interrupted mid-turn are marked
resume_pending=True. If the auto-recovery turn fails,resume_pendingis never cleared. After the freshness window expires, these sessions become zombies — user-initiated messages resume the stale session with old conversation history, bypassing idle reset.Root Cause
In
gateway/session.py,get_or_create_session()returnedresume_pendingsessions unconditionally without checking if they were still fresh.Fix
Add a freshness gate using
last_resume_marked_atagainstHERMES_AUTO_CONTINUE_FRESHNESSwindow (default 3600s). If expired, fall through to auto-reset with reason"resume_pending_expired".Before
After
Respects
HERMES_AUTO_CONTINUE_FRESHNESS=0to disable the gate (opt-out for users who want the old behavior).