Skip to content

fix(gateway): credential pool on /model overrides, stale model cache clears, routed-profile display config (3-PR salvage) - #58503

Merged
teknium1 merged 3 commits into
mainfrom
salvage/gateway-session-state
Jul 4, 2026
Merged

fix(gateway): credential pool on /model overrides, stale model cache clears, routed-profile display config (3-PR salvage)#58503
teknium1 merged 3 commits into
mainfrom
salvage/gateway-session-state

Conversation

@teknium1

@teknium1 teknium1 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Three gateway session-state fixes: agents rebuilt from a persisted /model override 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 read display settings 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_model popped on /new and compression-exhausted auto-reset
  • gateway/run.py: _gateway_config_home() prefers the live profile-home override so multiplexed profiles get their own display config
  • Regression tests for each

Validation

Before After
402/429 after /model pool rotation no-ops recover_with_credential_pool works
config change + /new + transient empty config read stale model served cache cleared, fresh resolve
routed profile display settings root profile's config used routed profile's config used

Targeted 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

gateway-session-state

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery area/auth Authentication, OAuth, credential pools sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data P2 Medium — degraded but workaround exists labels Jul 4, 2026
tuancookiez-hub and others added 3 commits July 4, 2026 16:28
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
teknium1 force-pushed the salvage/gateway-session-state branch from bbd44c7 to 9f2727d Compare July 4, 2026 23:29
@teknium1
teknium1 enabled auto-merge (rebase) July 4, 2026 23:29
@teknium1
teknium1 merged commit 7e8f50a into main Jul 4, 2026
29 checks passed
@teknium1
teknium1 deleted the salvage/gateway-session-state branch July 4, 2026 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants