fix(gateway): credential pool on /model overrides, stale model cache clears, routed-profile display config (3-PR salvage) - #58503
Merged
Conversation
Per-session /model overrides supplied api_key and provider but omitted credential_pool, so billing rotation never ran on HTTP 402. Wire the pool on fast override, rehydrate, and apply paths; backfill from provider for legacy persisted overrides. Regression tests in tests/gateway/.
… auto-reset After a config change (e.g. switching model provider), the /new command must clear the per-session _last_resolved_model cache so the next turn resolves the model from the updated config instead of falling back to the stale cached value. Without this fix, if a transient config-cache miss occurs on the first post-/new turn, the #35314 recovery path serves the old model from the cache — the user sees the old model being used even though they changed config.yaml and explicitly ran /new. Fix applies to both call sites that reset session model state: - GatewaySlashCommandsMixin._handle_reset_command (slash_commands.py) - GatewayRunner compression-exhausted auto-reset (run.py) Fixes #58403
teknium1
force-pushed
the
salvage/gateway-session-state
branch
from
July 4, 2026 23:29
bbd44c7 to
9f2727d
Compare
teknium1
enabled auto-merge (rebase)
July 4, 2026 23:29
4 tasks
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
Three gateway session-state fixes: agents rebuilt from a persisted
/modeloverride regain credential-pool rotation, the last-resolved-model cache is cleared at session boundaries (/new, compression auto-reset) so a config change can't serve a stale model, and profile-routed sessions readdisplaysettings from the routed profile instead of the root one.Salvages #58439 (@tuancookiez-hub), #58431 (@liuhao1024), #58413 (@msh01) onto current main, authorship preserved.
Changes
gateway/run.py+gateway/slash_commands.py:_credential_pool_for_provider()helper attached at all three override-consumption paths (fast path, rehydrate, apply) with legacy-override backfill;_last_resolved_modelpopped on/newand compression-exhausted auto-resetgateway/run.py:_gateway_config_home()prefers the live profile-home override so multiplexed profiles get their own display configValidation
/model/new+ transient empty config readTargeted suites: session model override pool, /new cache clear, multiplex phase0 — all pass. These caches are model-name/session state, not prompt caches — no prompt-caching impact; both clear points are session boundaries.
Closes #58439. Closes #58431. Closes #58413.
Infographic