Skip to content

Invalidate session affinity on auth-wide failures and force fresh upstream sessions#2

Merged
clcc2019 merged 1 commit into
mainfrom
codex/analyze-session-pollution-during-auth-switch
Jun 3, 2026
Merged

Invalidate session affinity on auth-wide failures and force fresh upstream sessions#2
clcc2019 merged 1 commit into
mainfrom
codex/analyze-session-pollution-during-auth-switch

Conversation

@clcc2019

@clcc2019 clcc2019 commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Ensure that when an auth becomes unavailable due to an auth-wide failure the session-affinity cache is invalidated so downstream sessions are not silently rebound to a failing credential.
  • Force creation of a fresh upstream provider session when the same downstream session is rebound to a different auth to avoid reusing server-side sessions tied to the unavailable credential.

Description

  • Add logic in Manager.MarkResult to detect auth-wide unavailability and trigger invalidateSessionAffinityForAuth, which calls InvalidateAuth on active affinity selectors.
  • Extend SessionCache with a forceNew map and ConsumeForceNew method; InvalidateAuth now records recently unbound sessions into forceNew so callers can detect the need for a fresh upstream session.
  • Update SessionAffinitySelector and manager affinity-based pick paths to consult ConsumeForceNew for primary and fallback session keys and call forceNewUpstreamSessionForNextCredential when necessary to start a fresh upstream session.
  • Add TestManager_AuthWideFailureInvalidatesAffinityAndForcesFreshSession to validate that auth-wide failures clear affinity bindings and cause the next execution to force a new upstream session and rebind to a different auth.

Testing

  • Ran the auth package unit tests: go test ./sdk/cliproxy/auth -run TestManager_AuthWideFailureInvalidatesAffinityAndForcesFreshSession and related affinity tests, and they passed.
  • Existing selector and session-affinity tests in conductor_overrides_test.go were executed and continued to succeed after the changes.
  • Verified the new SessionCache cleanup behavior via unit tests and ensured ConsumeForceNew entries expire correctly during cache cleanup.

Codex Task

@clcc2019
clcc2019 merged commit ac51612 into main Jun 3, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant