fix(agent): reset fallback provider state in reset_session_state#4382
Open
binhnt92 wants to merge 1 commit intoNousResearch:mainfrom
Open
fix(agent): reset fallback provider state in reset_session_state#4382binhnt92 wants to merge 1 commit intoNousResearch:mainfrom
binhnt92 wants to merge 1 commit intoNousResearch:mainfrom
Conversation
reset_session_state() resets all token counters, turn count, and compressor state between gateway conversations — but never resets _fallback_index or _fallback_activated. Once the primary model fails and fallback activates, every subsequent conversation in the same gateway session stays on the fallback model permanently. Users unknowingly talk to a cheaper/weaker model for all future messages with no way to return to the primary short of restarting the gateway. Additionally, once the fallback chain is exhausted, fallback protection is permanently disabled for that session.
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.
reset_session_state()resets all token counters, turn count, and compressor state between gateway conversations — but never resets_fallback_indexor_fallback_activated. Once the primary model fails and fallback activates, every subsequent conversation in the same gateway session stays on the fallback model permanently. Users unknowingly talk to a weaker model for all future messages, with no way to return to the primary short of restarting the gateway. Once the fallback chain is fully exhausted, fallback protection is also permanently disabled for that session.Changes Made
Added
self._fallback_index = 0andself._fallback_activated = Falsetoreset_session_state()inrun_agent.py, alongside the existing token/turn/compressor resets.How to Test
6 tests: fallback index reset to 0, fallback activated reset to False, fallback chain preserved (not cleared), token counters still reset (no regression), source line verification for both fields.
Checklist