fix(auth): stop new sessions inheriting auto-selected auth profile overrides#62710
fix(auth): stop new sessions inheriting auto-selected auth profile overrides#62710zeynalnia wants to merge 23 commits into
Conversation
Greptile SummaryThis PR fixes a bug where Confidence Score: 5/5Safe to merge — targeted fix with no regressions; all findings are style-level or lower. All three code paths that propagated auto overrides into new sessions are correctly patched with identical source === "user" guards. The defense-in-depth layer in resolveSessionAuthProfileOverride is updated consistently, including the write-back that now correctly preserves "user" source rather than always overwriting to "auto". Five new unit tests lock in the intended behavior for auto vs user overrides, cooldown skipping, legacy inference, and all-cooldown fallback. No P0 or P1 issues found. No files require special attention.
|
2a4d681 to
30d83ea
Compare
cbdbd15 to
d0ebc5a
Compare
…errides (openclaw#62412) New sessions were inheriting `authProfileOverride` from rate-limited or cooldown backup profiles instead of picking the best available profile. The auto-failover override leaked through three paths: gateway session reset, /new and /reset command handling, and the session override resolver's round-robin logic. Only carry over auth profile overrides when the source is "user" (explicitly set). Auto-selected overrides are now discarded at session boundaries so the new session resolves the best available non-cooldown profile fresh via pickFirstAvailable(). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
d0ebc5a to
d69ba4c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a341f08add
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…legacy entries - User-set overrides now persist across /new without rotation (return early instead of round-robining), eliminating the source corruption where the persist block relabeled user overrides as "auto". - Use !== "auto" instead of === "user" in session.ts and session-reset-service.ts to preserve legacy entries that have an override but no authProfileOverrideSource field. - Revert source preservation in persist block back to always "auto" since user overrides now return before reaching it. - Add tests for legacy entry preservation and consecutive /new survival. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…w-sessions # Conflicts: # CHANGELOG.md
…w-sessions # Conflicts: # CHANGELOG.md
…w-sessions # Conflicts: # CHANGELOG.md
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1a475e5b7a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Legacy session entries from auto-failover have authProfileOverrideCompactionCount set but no authProfileOverrideSource field. The !== "auto" guard missed these, letting stale failover overrides leak through gateway reset and /new as if they were user choices. Now both paths also check for the compactionCount heuristic to correctly identify and drop legacy auto overrides. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…w-sessions # Conflicts: # CHANGELOG.md
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bcc52cfcf1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
The compactionCount heuristic for detecting legacy auto overrides was too aggressive — it also dropped explicit user overrides (source: "user") that happened to have a stale authProfileOverrideCompactionCount. Now the carry-over logic checks source first: explicit "user" always carries over, explicit "auto" always drops, and only undefined-source entries fall through to the compactionCount heuristic. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…w-sessions # Conflicts: # CHANGELOG.md
|
This pull request has been automatically marked as stale due to inactivity. |
|
Thanks for the context here. I did a careful shell check against current Close this older PR: the central reset-boundary fix is already on current main and shipped, with shared reset preservation code and regression coverage. The remaining branch diff is stale against the current reset architecture, includes release-owned changelog edits, and any broader wrong-provider auth loop is tracked separately. So I’m closing this older PR as already covered on Review detailsBest possible solution: Keep the shipped shared reset-preservation implementation, and handle any remaining wrong-provider auth loop through the narrower current thread at #85126. Do we have a high-confidence way to reproduce the issue? Yes for the central reset-boundary bug: current source and regression tests show auto-sourced auth/model overrides are cleared on Is this the best way to solve the issue? No, merging this branch is no longer the best way to solve it. Current main’s shared reset-preservation helper is the cleaner shipped owner boundary, and any remaining resolver-only gap should be a new focused PR against that code. Security review: Security review cleared: The diff touches auth/session routing but does not add permissions, dependency sources, secret handling, network calls, or a concrete new security regression beyond the merge risks already called out. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 37e3e895b020; fix evidence: release v2026.4.9, commit 5d46e4dc4f45. |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
This pull request has been automatically marked as stale due to inactivity. |
|
ClawSweeper applied the proposed close for this PR.
|
Summary
authProfileOverridefrom rate-limited or cooldown backup profiles instead of using the default/best available profile. The auto-failover override persists across gateway restarts,/new,/reset, and manual session clearing.lastGood/cooldownUntilfields are effectively ignored.source === "auto") auth profile overrides are now discarded at session boundaries (gateway reset,/new,/reset). Only user-explicitly-set overrides (source === "user") carry over. Defense-in-depth inresolveSessionAuthProfileOverrideensures new sessions always callpickFirstAvailable()for auto overrides./authcommand) still carry over across session resets as before. The round-robin and cooldown logic is unchanged for continuing (non-new) sessions.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
authProfileOverridefrom old to new sessions regardless of whether the override was auto-selected (failover) or user-set. TheauthProfileOverrideSourcediscriminator existed in the data model but was not consulted at session boundaries."auto"and"user"source when propagating auth profile overrides across session resets.authProfileOverrideSource: "auto"but the session reset and init paths treated all overrides identically.Regression Test Plan (if applicable)
src/agents/auth-profiles/session-override.test.tsauthProfileOverrideSource: "auto"picks first available profile (not round-robin from stale position); new session withauthProfileOverrideSource: "user"round-robins as before; cooldown profiles are skipped.User-visible / Behavior Changes
/new,/reset, gateway restart, or session expiry) now start with the best available auth profile instead of inheriting a stale auto-failover profile that may be in cooldown or rate-limited./author similar) still persist across session resets.Diagram (if applicable)
Security Impact (required)
Repro + Verification
Environment
Steps
/new,/reset, or new message after expiry)Expected
Actual
Evidence
5 new unit tests in
src/agents/auth-profiles/session-override.test.tsall pass, covering auto vs user override propagation, cooldown skipping, legacy inference, and all-cooldown fallback.Human Verification (required)
authProfileOverrideSource, all-profiles-in-cooldown fallback, provider alias normalizationReview Conversations
Compatibility / Migration
Risks and Mitigations
authProfileOverrideSource: "auto"will lose their override on the next session reset, changing profile selection behavior.🤖 Generated with Claude Code
AI Disclosure
session-override.test.tspass, fullauth-profiles/suite passes (109/110, 1 pre-existing unrelated failure)CI Note
The
checkandcheck-additionalCI failures are pre-existing onmain— type errors inextensions/slack/src/approval-handler.runtime.test.tsandextensions/telegram/src/approval-handler.runtime.test.ts(TS18046:'payload' is of type 'unknown'). These are unrelated to this PR's changes.