Repository navigation
fix(setup): preserve the current model when activating saved auth - #180832
xiaopan-xydt wants to merge 5 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesSaved-auth discovery and activation preserve the target agent’s current same-provider model, including aliases and primary-versus-utility roles. Example: Activate openai:saved-proof, saved with openai/starter-model, while the agent uses openai/gpt-5.4-mini.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes remaining saved-sign-in model drift on current main; the previous role-isolation finding is resolved, with no new actionable findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherModel Setup and CLI saved-auth activation consume agent configuration and saved credentials, resolve a candidate model, verify inference, and persist the selected model and credential binding. flowchart LR
A[Model Setup or CLI] --> B[Saved auth discovery and staging]
C[Agent configuration] --> D[Existing route resolver]
D --> B
E[Saved credential] --> B
B --> F[Inference verification]
F --> G[Existing activation and persistence owner]
Technical reviewBest possible solution: Use the shared role-aware route resolver for saved-auth discovery and staging while retaining explicit overrides, provider boundaries, and existing activation safeguards. Do we have a high-confidence way to reproduce the issue? Current-main discovery and staging visibly select the saved starter model; the contributor’s published-package CLI comparison also records that drift. Is this the best way to solve the issue? The patch places the shared selection decision beside the existing route owner and updates both consumers, with distinct alias and role-isolation regressions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f31072518010. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +73, Tests +120. Total +193 across 8 files. Added test files: 2. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (7 earlier review cycles)
Reviewed October 24, 2026, 7:16 PM ET / 23:16 UTC (Revision 8). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review The head now also scopes saved-auth model lookup and its discovery cache by |
|
🦞👀 Re-review progress:
|
|
Closing this PR: the setup-inference module has since been restructured on main and the core file this change builds on (setup-inference-saved-model.ts) no longer exists, so the change no longer applies to the current architecture. Issue #167381 remains open and accurately describes the remaining behavior. |
Related to #167381
What Problem This Solves
Activating a previously saved auth profile failed with
The candidate route does not match the selected modelwhen the saved credential's starter model differed from the current agent model. The activation path staged the stored starter model instead of the model the agent was already using, so route verification rejected the candidate. If the models happened to match, activation could also overwrite the user's current model with the starter model. Discovery had the same mismatch: Model Setup forwards the discovered candidate model explicitly, so fixing activation alone was bypassed by the normal UI flow. Provider-qualified aliases such asopenai/Fastmust also be resolved to their canonical model identity or the same route check rejects a valid current model.Why This Change Was Made
Saved-auth discovery and
stageSavedAuthCandidatenow share the same model-selection decision:modelRef.Both paths call
resolveCurrentModelRefForSavedAuth, which uses the existing setup route resolver. Configured aliases therefore resolve to the same concrete model identity used by the model-selection updater, and discovery advertises that canonical current model to Model Setup. The trailing auth-profile suffix is removed before comparing providers. API-key header configuration is applied to the provider of the resolved model rather than always using the saved starter model's provider. Credential and auth-profile binding behavior is unchanged.The saved-auth route lookup is also scoped to the setup target. Previously it always resolved the primary route and cached by provider alone, so a credential chosen for the utility target could advertise the primary model and ordinary activation could promote a utility-only model to primary. Discovery and
stageSavedAuthCandidatenow passmodelTarget(primaryorutility) into the shared resolver, and the discovery cache is keyed by provider plus target. A utility-only configuration therefore keeps its utility model while saved-auth activation still persists the selected starter model as primary.User Impact
Users can switch back to a saved sign-in without a spurious route mismatch, and activation no longer resets their current model to the provider's starter model. Cross-provider saved credentials retain the previous fallback behavior.
Evidence
43 passedacrosssetup-inference-activate.test.tsandsetup-inference-saved-model.test.ts, including bothopenai/gpt-5.4-miniand the configuredopenai/Fastalias;19 passedinsetup-inference-detect.test.ts.setup.detect(), assert the saved-auth candidate advertises the canonical current model, activate that candidate as Model Setup does, and verify the persisted model and inference call.openai/starter-modeland fail before activation.agents.defaults.utilityModelconfigured, detection advertises the saved starter model and activation persists that model as primary while leavingutilityModelunchanged.parseInferenceRefnever receives an optional model reference. The final-head model regressions pass (2 passed | 40 skipped).oxfmt --checkandoxlintpassed for all changed files;git diff --checkpassed.180832-final.log(43 + 19 passed) undercontributions/pr-evidence-20261025/180832/in the contributor workspace. Earlier logs remain undercontributions/pr-evidence-20261023/, and the upgrade readback files are under180832-live-proof/upgrade-20261023e/.Real CLI behavior proof
On 2026-10-23 I exercised the shipped
openclawCLI in an isolated state directory against a local loopback OpenAI Responses provider. The state had an activeopenai:baselinecredential and a saved replacementopenai:saved-proofcredential whose recorded model wasopenai/starter-model; the current agent model wasopenai/gpt-5.4-mini.openclaw agent --localturn authenticated with the baseline credential and returnedLIVE_PROOF_REPLY_1ongpt-5.4-mini.openclaw models auth activate openai:saved-proof --agent mainprintedInference verified: openai/gpt-5.4-miniandSign-in verified and saved.It authenticated the probe with the saved credential, not the baseline credential.openclaw agent --localturn returnedLIVE_PROOF_REPLY_3fromgpt-5.4-miniand used the saved credential.agents.defaults.model.primaryremainedopenai/gpt-5.4-mini, whileagents.entries.main.modelbecameopenai/gpt-5.4-mini@openai:saved-proof.Provider-side request sequence, with keys redacted:
The discriminating latest-stable run used the published
[email protected]package with the same fixture. It activated the saved credential asopenai/starter-modeland persistedagents.entries.main.model = openai/starter-model@openai:saved-proof, reproducing the reported drift. The head above instead persistedopenai/gpt-5.4-mini@openai:saved-proof.Existing-state compatibility
The fixture initially used the legacy
auth-profiles.jsonlayout. The reviewed head'sdoctor --fixmigrated it to the current state SQLite database, retained both profile IDs and credentials, and the CLI listed and activated both afterwards. This PR adds no persisted-format change.Latest-stable upgrade readback
The readback was verified on
a8b7787e, rebased onto currentmain(reports2026.10.6). The branch was then rebased once more toe3d624desolely to pick up upstream82c46546, a test-fixture typecheck fix; the source diff is unchanged. I seeded an isolated state with the published[email protected](fe06181) package: itsdoctor --fixmigrated the legacy store and stampedmeta.lastTouchedVersion=2026.10.6with schema v20, and one baseline turn ran against that state (LIVE_PROOF_REPLY_1, baseline credential,gpt-5.4-mini).The candidate head then opened the same state. Its
doctor --fixadvanced schema v20 -> v31 and retained pre-migration SQLite backups.models auth activate openai:saved-proof --agent mainprintedInference verified: openai/gpt-5.4-miniandSign-in verified and saved.with no downgrade-guard warning. The follow-up turn returnedLIVE_PROOF_REPLY_3ongpt-5.4-miniusing the saved credential. After the upgrade,agents.defaults.model.primaryremainedopenai/gpt-5.4-mini, and onlyagents.entries.main.modelbecameopenai/gpt-5.4-mini@openai:saved-proof.Machine-checkable result:
upgrade-20261023e/upgrade-verification.json(13/13 checks), with logs inupgrade-20261023e/undercontributions/pr-evidence-20261023/.Command:
tsgocould not be run on this host because the available glibc is older than the installed TypeScript native binary requires, so this PR does not claim a local typecheck result.CI note
check-test-types-core-1failed only insrc/hooks/loader.cache-invalidation.test.ts(managedHooksDir), which this PR does not touch; it is a pre-existing failure onmainalready fixed by upstream82c46546. The final rebase includes that fix.AI Assistance
AI-assisted implementation and test preparation. The contributor reviewed the diff, ran both the focused regression and base-red checks, and verified the final patch.