fix(gateway): recover resume_pending sessions instead of sending a blank turn - #267
Open
hashbender wants to merge 1 commit into
Open
fix(gateway): recover resume_pending sessions instead of sending a blank turn#267hashbender wants to merge 1 commit into
hashbender wants to merge 1 commit into
Conversation
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
After a gateway restart, an auto-resumed thread now always gets its recovery system note instead of occasionally receiving a genuinely blank user turn (which made the model reply with confused "that message came through blank" noise).
Root cause:
_schedule_resume_pending_sessionsdispatches an empty-text turn expecting the injector to fill it with a recovery note, but the scheduler judges freshness offlast_resume_marked_at(interrupt time) while the injector gates_is_resume_pendingon the transcript clock (_last_transcript_timestamp). For a thread quiet >1h before the crash, those disagree →_is_resume_pendinggoes False → the note is never injected → the model gets a blank user turn.Changes
gateway/run.py: (1) dual freshness signal —_is_resume_pendingnow fires when the transcript clock orlast_resume_marked_atis within the window, so the scheduler's decision and the per-turn injection agree. (2) empty-turn safety net — ifmessageis still blank AND the session isresume_pending, backfill the recovery note; scoped toresume_pendingso a legitimately empty user turn (uncaptioned image) on a normal session is untouched. The safety-net note reuses the canonical reason-aware recovery wording from the_is_resume_pendingbranch (follow-up on the salvage).scripts/release.py: AUTHOR_MAP entry for the salvaged commit.Validation
_is_resume_pending=False→ blank turnresume_pending(branch missed)tests/gateway/test_restart_resume_pending.pyE2E-verified against the real
_is_fresh_gateway_interruption/_last_transcript_timestamphelpers: the exact stale-transcript bug case flips from False (old single-signal) to True (dual signal).Salvaged from NousResearch#46997 by @abchiaravalle (first-time contributor); authorship preserved via rebase-merge.
Infographic
Nous Research
Mirror-of: NousResearch#56262
NousResearch#56262