Skip to content

fix(gateway): freshness-gate resume_pending against per-message zombies - #269

Merged
hashbender merged 1 commit into
mainfrom
mirror/pr-56264
Jul 1, 2026
Merged

fix(gateway): freshness-gate resume_pending against per-message zombies#269
hashbender merged 1 commit into
mainfrom
mirror/pr-56264

Conversation

@hashbender

Copy link
Copy Markdown
Owner

Summary

A crash-interrupted session marked resume_pending now falls through to a fresh session once resume has been pending past the freshness window — closing the zombie-session context bleed reported on Telegram and Feishu.

Root cause: #54442 added _should_reset() to the resume_pending branch, but that policy keys on updated_at, which is bumped to now on every message. A zombie session that keeps receiving messages therefore never goes idle and resumes its stale transcript forever.

Changes

  • gateway/session.py: gate the resume_pending branch on last_resume_marked_at (set once at resume-mark, never bumped per-message) vs the auto-continue freshness window. Past the window → auto-reset with reason "resume_pending_expired". Window <= 0 disables the gate (opt-out).
  • gateway/session.py: hoist auto_continue_freshness_window() here as the single source of truth.
  • gateway/run.py: _auto_continue_freshness_window() now delegates to the session-module helper (import/patch surface preserved).
  • tests/gateway/test_clean_shutdown_marker.py: 3 tests — fresh returns same session, per-message zombie (fresh updated_at, stale mark) resets, window=0 opt-out.

Validation

Scenario Before After
Fresh resume_pending returns session returns session
Zombie (fresh updated_at, resume pending > window) resumes stale context new session
HERMES_AUTO_CONTINUE_FRESHNESS=0 resumes resumes (opt-out)

Targeted tests: 86/86 green (incl. test_restart_resume_pending, _auto_continue_freshness_window helper tests). E2E verified against real imports with a temp HERMES_HOME.

Salvaged from NousResearch#46963 by @annguyenNous (authorship preserved). Supersedes NousResearch#43392.

Fixes NousResearch#46934

Infographic

freshness gate


Mirror-of: NousResearch#56264
NousResearch#56264

@hashbender
hashbender merged commit 0b7e9ef into main Jul 1, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: stale resume_pending sessions bypass idle reset, causing context bleed after gateway restart

1 participant