fix(auth-profiles): repair stale auto runtime auth selection#87893
fix(auth-profiles): repair stale auto runtime auth selection#87893osolmaz wants to merge 13 commits into
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 3, 2026, 12:48 PM ET / 16:48 UTC. Summary PR surface: Source +355, Tests +1128. Total +1483 across 15 files. Reproducibility: yes. Current main source shows persisted runtime model fields win in resolveSessionModelRef and are inherited by sessions.create; the PR’s fixtures encode the stale auto-fallback shapes that cause the wrong selected/active model behavior. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land only after a maintainer explicitly accepts the stale predicate, cleared-field list, and narrow resolver split, while leaving the broader raw session model/auth refactor to #87957. Do we have a high-confidence way to reproduce the issue? Yes. Current main source shows persisted runtime model fields win in resolveSessionModelRef and are inherited by sessions.create; the PR’s fixtures encode the stale auto-fallback shapes that cause the wrong selected/active model behavior. Is this the best way to solve the issue? Yes, as an immediate repair. The PR keeps the fix in core session/model selection, adds a shared stale predicate across run selection, display, inheritance, and preflight, and avoids new config/API surface; the broader cleanup can stay in the linked follow-up. AGENTS.md: found and applied where relevant. Codex review notes: reasoning high; reviewed against 158c4d75402d. Label changesLabel justifications:
Evidence reviewedPR surface: Source +355, Tests +1128. Total +1483 across 15 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aa76c28708
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Implementation report for current head Summary:
Review/comment handling:
Validation:
CI state checked:
Behavior addressed: stale auto-owned runtime auth fallback state no longer pins a session or child session to the fallback provider when the configured/effective selected model is different. |
|
@clawsweeper re-review The display/read-path finding has been addressed in The row/display resolver now ignores stale auto runtime auth state through the shared stale predicate, and |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Follow-up cleanup pushed in 2402271 after maintainer review of code smells. Changed only source shape, not behavior:
Proof run after the cleanup:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Please rerun on current head The previous targeted re-review failed at the ClawSweeper/Codex workflow layer and did not report a patch finding. The cleanup commit only refactored the session expected-model helper shape; focused proof passed in the prior comment. |
|
🦞👀 Command router queued. I will update this comment with the next step. Re-review progress:
|
Related variant: stale
|
|
@clawsweeper re-review Addressed the latest review feedback in Changes:
Proof run after the patch:
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Fresh current-release signal from a real Discord-backed install (not after-fix proof for this PR branch): I am still seeing the same stale auto runtime auth-selection failure class on OpenClaw 2026.6.1 ( Setup shape, sanitized:
Fresh observation:
Why this seems relevant to #87893:
Caveat: I have not run this PR branch in a clean stage yet, so this comment is current-release failing evidence, not a verified after-fix result for |
Summary
Control UI sessions could inherit a temporary fallback auth/model choice as if it were a real user choice.
That made a fresh WebChat/TUI session show or start from the fallback provider instead of the agent primary.
This change treats runtime-only auto auth fallback state as temporary, repairs it back to the configured primary, and keeps the auth resolver provider-scoped.
AI-assisted: yes.
Fixes #85126.
What Changed
The fix stays inside core session/model selection.
It does not add config, plugin SDK, plugin runtime, manifest, or provider contract surface.
createModelSelectionStateswitch that shape back to the configured primary and clear stale runtime/auth fields together.sessions.createfrom copying runtime-only auto fallback auth/model state from a parent into a fresh dashboard session.Testing
I tested the focused state repair path locally, then ran the changed type/lint/guard gate remotely.
The remote broad proof used AWS Crabbox because Blacksmith Testbox was unavailable in this environment (
blacksmithCLI was missing)../node_modules/.bin/oxfmt --write --threads=1 src/sessions/model-overrides.ts src/auto-reply/reply/model-selection.ts src/gateway/session-utils.ts src/gateway/server-methods/sessions.ts src/auto-reply/reply/model-selection.test.ts src/gateway/session-utils.test.ts src/gateway/server.sessions.create.test.tsgit diff --checknode scripts/run-vitest.mjs src/auto-reply/reply/model-selection.test.ts src/gateway/session-utils.test.ts src/gateway/server.sessions.create.test.ts src/sessions/model-overrides.test.ts src/agents/auth-profiles/session-override.test.ts src/agents/agent-scope.test.tsnode scripts/run-vitest.mjs src/auto-reply/reply/agent-runner-execution.test.ts -t "auto fallback"node scripts/crabbox-wrapper.mjs run --provider aws --idle-timeout 90m --ttl 240m --timing-json --shell -- "pnpm check:changed"Behavior addressed: runtime-only auto fallback auth/model state no longer pins a session to the fallback provider when the configured primary should be selected.
Real environment tested: local macOS worktree with synthetic session-store regressions; AWS Crabbox Linux changed gate.
Exact steps or command run after this patch: the commands listed above.
Evidence after fix: focused Vitest regressions passed;
pnpm check:changedpassed on AWS Crabbox provideraws, leasecbx_0417338a2dcb, runrun_9b21f45d5a7d, exit code 0.Observed result after fix: a session with primary
minimax/MiniMax-M2.7, runtimedeepseek/deepseek-v4-flash, and autodeepseek:defaultauth resolves back to MiniMax and clears stale runtime/auth fields before the next dispatch.What was not tested: live MiniMax/DeepSeek provider credentials and a forced real provider fallback were not used; the proof is synthetic plus type/lint/guard coverage.
Risks
The behavior change is narrow and source-gated.
It only applies when the auth profile source is
auto, an auth profile is present, and there is no persisted model override.providerOverride/modelOverride.