a1f62f4777
A crash-interrupted session marked resume_pending is returned by get_or_create_session so its transcript reloads intact. The idle/daily reset policy (#54442) keys on updated_at, which is bumped to now on every message — so a zombie session that keeps receiving messages never trips it and resumes stale context forever (context bleed reported on Telegram and Feishu). Gate the resume_pending branch on last_resume_marked_at (set once at resume-mark, never bumped per-message) against the auto-continue freshness window. If resume has been pending past the window, fall through to auto-reset with reason "resume_pending_expired". A window <= 0 disables the gate (opt-out for the pre-fix always-fresh behaviour). Also hoist auto_continue_freshness_window() into gateway/session.py as the single source of truth; gateway/run._auto_continue_freshness_window() now delegates to it (keeps the existing import/patch surface). Fixes #46934 Co-authored-by: Hermes Agent <noreply@nousresearch.com>