fix(gateway): clear last-resolved-model cache on 3 more conversation-boundary resets - #58906
Merged
teknium1 merged 1 commit intoJul 5, 2026
Conversation
…boundary resets 11b4a21 cleared the per-session _last_resolved_model cache on /new and the compression-exhausted auto-reset, so a resumed/reset conversation resolves the model from current config instead of a stale cached value (NousResearch#58403). Three other sites documented as the same "full conversation boundary" treatment — pop _session_model_overrides, clear the reasoning override, pop _pending_model_notes — still missed _last_resolved_model: - _session_expiry_watcher's permanent finalization block (gateway/run.py): a session that goes idle and is finalized, then resumed, could serve a model cached before it went idle on a transient config-cache miss. - The daily/idle/suspended auto-reset cleanup (_was_auto_reset handling, gateway/run.py): same failure mode, different trigger. - /resume (gateway/slash_commands.py), whose own comment already says "conversation boundary just like /new" for the sibling dicts it clears. Fix: pop the session's _last_resolved_model entry in all three, mirroring the exact pattern 11b4a21 established.
Collaborator
Related: #58829 (open) clears |
This was referenced Jul 5, 2026
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.
What does this PR do?
11b4a21a5cleared the per-session_last_resolved_modelcache on/newand the compression-exhausted auto-reset, so a reset conversation resolves the model from current config instead of a stale cached value (#58403 — a transient config-cache miss otherwise serves the old model back even after an explicit reset/config change).Auditing every other site documented as the same "full conversation boundary — drop every session-scoped transient state" treatment (they all pop
_session_model_overrides, clear the reasoning override, and pop_pending_model_notes) turned up three more that still missed_last_resolved_model:_session_expiry_watcher's permanent finalization block (gateway/run.py) — a session that goes idle and gets finalized, then later resumed, could serve a model cached from before it went idle on a transient config-cache miss._was_auto_resethandling,gateway/run.py) — same failure mode, different trigger; its own comment says "drop every session-scoped transient state."/resume(gateway/slash_commands.py) — its own comment already says "conversation boundary just like/new" for the sibling dicts it clears, but_last_resolved_modelwasn't among them.(I also checked the
/moa <prompt>one-shot-override revert and the/reasoningcommand's reasoning-only reset — both are legitimately out of scope: neither is a full conversation-boundary reset, so clearing the model-resolution cache there would be wrong.)Related Issue
Same underlying issue as
11b4a21a5: #58403 (three additional sites of the same class, not yet covered by that fix).Type of Change
11b4a21a5)Changes Made
gateway/run.py: pop_last_resolved_model[key]in the session-expiry finalization block and the_was_auto_resetcleanup block (+14 lines)gateway/slash_commands.py: pop_last_resolved_model[session_key]in/resume's conversation-boundary cleanup (+7 lines)tests/gateway/test_session_boundary_hooks.py: new behavioral regression test driving_session_expiry_watcherend-to-endtests/gateway/test_10710_auto_reset_evicts_cached_agent.py: new AST-invariant test, mirroring this file's existing pattern for pinning the auto-reset cleanup block's contentstests/gateway/test_resume_command.py: new test extending the existingtest_resume_clears_session_model_overridespatternHow to Test
Mutation-verified: all 3 new tests fail against the pre-fix code.
Checklist
_last_resolved_model session_expiry auto_reset resume,resume clears last resolved model,was_auto_reset last_resolved_model)