Repository navigation
fix(agents): stored auth profile order is ignored when resolving CLI runtime aliases - #129165
Conversation
…untime aliases `resolveCliRuntimeFromAuthProfile` built its ordered profile list from `cfg.auth.order` alone, and `RuntimeAuthAliasParams` carried no auth store at all, so the order an operator sets through `models auth order set` never reached CLI runtime alias resolution. The canonical sibling resolver, `resolveAuthProfileOrderWithMetadata`, already reads the stored order first and falls back to config, so the two disagreed about the same question. With no config `auth.order` and two profiles sharing a provider auth key, the ordered list came out empty and the resolver fell through to its "exactly one compatible profile" branch, returning undefined. The gateway then reported model availability and picked the turn's execution backend as if the reorder had not happened, and no restart cleared it because the store was never read on this path. Rather than re-deriving the precedence at the call site, extract it: the stored-first explicit-order resolution moves out of `resolveAuthProfileOrderWithMetadata` into `resolveExplicitAuthOrderSelection`, and alias routing becomes its second consumer. Both now resolve the order through one implementation, across normalized provider keys, so they cannot drift apart again. The store is read from the lifecycle-published runtime snapshot for the requested agent and its declared inherited owner, matching how prepared model catalog and registry resolve the same pair; no new snapshot API and no SQLite reopen on request paths. An authored stored order also owns selection, so it suppresses the unique-compatible-profile fallback the way the canonical resolver does. Tests cover stored-order-only selection, stored-over-config precedence, non-normalized stored keys, inheritance from the main agent, authoritative empty orders with a control for the fallback that must survive, and the unchanged config-only path.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs changes before merge. Reviewed August 26, 2026, 4:26 PM ET / 20:26 UTC. ClawSweeper reviewWhat this changesThe PR makes CLI runtime alias selection use the persisted per-agent auth-profile order before configured order, including credentials present only in the SQLite auth store. Merge readinessKeep this PR open: it fixes a real current-main gap, but its revised stale-order path still disagrees with the canonical credential selector and can route a CLI-selected execution back to direct provider execution. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherAuth-order commands persist per-agent credential preferences and publish a runtime snapshot. Runtime alias selection consumes that state to choose whether an agent executes through a direct provider or a compatible local CLI runtime. flowchart LR
Command[Auth order command] --> Store[Per-agent SQLite auth store]
Store --> Snapshot[Published runtime snapshot]
Config[Configured auth order] --> Selection[Profile-order selection]
Snapshot --> Selection
Selection --> Runtime[CLI runtime alias selection]
Runtime --> Execution[Direct provider or CLI execution]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource -30, Tests +171, Docs +3. Total +144 across 5 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Make runtime alias routing consume the same repaired profile-selection outcome as credential execution, then prove mixed stored direct-API and CLI profiles remain aligned after stale-order repair. Do we have a high-confidence way to reproduce the issue? Yes in source: an all-deleted stored order plus stored direct-API and CLI credentials takes different paths in canonical selection and alias routing. It was not executed here because this is a read-only review. Is this the best way to solve the issue? No: shared precedence alone is insufficient because stale-order repair still has two outcomes; the alias resolver should consume the canonical repaired selection. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a27f7fe56c28. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Share stored-over-config precedence, preserve stale-profile repair, and route explicitly selected stored credentials without config metadata. Remove unreachable OpenAI order-alias merging. Co-authored-by: masatohoshino <[email protected]>
|
@clawsweeper re-review Updated the original contributor branch at 410a8e8. The owner refactor now removes 30 production lines, preserves stale-profile repair, and covers stored-only credentials and explicit pins without config metadata. All 77 focused tests, eight real SQLite/snapshot/plugin-discovery scenarios, and complete-branch structured autoreview pass. The PR body records proof and its limits. Required CI on this candidate remains the landing gate. |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…runtime aliases (openclaw#129165) * fix(agents): honor the stored auth profile order when resolving CLI runtime aliases `resolveCliRuntimeFromAuthProfile` built its ordered profile list from `cfg.auth.order` alone, and `RuntimeAuthAliasParams` carried no auth store at all, so the order an operator sets through `models auth order set` never reached CLI runtime alias resolution. The canonical sibling resolver, `resolveAuthProfileOrderWithMetadata`, already reads the stored order first and falls back to config, so the two disagreed about the same question. With no config `auth.order` and two profiles sharing a provider auth key, the ordered list came out empty and the resolver fell through to its "exactly one compatible profile" branch, returning undefined. The gateway then reported model availability and picked the turn's execution backend as if the reorder had not happened, and no restart cleared it because the store was never read on this path. Rather than re-deriving the precedence at the call site, extract it: the stored-first explicit-order resolution moves out of `resolveAuthProfileOrderWithMetadata` into `resolveExplicitAuthOrderSelection`, and alias routing becomes its second consumer. Both now resolve the order through one implementation, across normalized provider keys, so they cannot drift apart again. The store is read from the lifecycle-published runtime snapshot for the requested agent and its declared inherited owner, matching how prepared model catalog and registry resolve the same pair; no new snapshot API and no SQLite reopen on request paths. An authored stored order also owns selection, so it suppresses the unique-compatible-profile fallback the way the canonical resolver does. Tests cover stored-order-only selection, stored-over-config precedence, non-normalized stored keys, inheritance from the main agent, authoritative empty orders with a control for the fallback that must survive, and the unchanged config-only path. * fix(agents): align runtime routing with stored auth selection Share stored-over-config precedence, preserve stale-profile repair, and route explicitly selected stored credentials without config metadata. Remove unreachable OpenAI order-alias merging. Co-authored-by: masatohoshino <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]>
Related: #119946
What Problem This Solves
Fixes an issue where operators using
openclaw models auth order setwould still get the configured/default execution backend instead of the CLI backend they selected. Stored credentials could also be ignored when login had not created matchingauth.profilesconfig metadata.Why This Change Was Made
Credential selection and CLI runtime routing now share one stored-over-config order lookup. Runtime routing consumes the lifecycle-published auth snapshot, including the requested agent's inherited auth owner, without reopening SQLite on request paths. Selected profile metadata comes from config or the actual stored credential; explicit model-runtime policy and explicit auth pins retain precedence.
The rewrite preserves the existing repair for orders containing only deleted profiles, honors explicit empty configured orders, and keeps the first existing direct-API profile authoritative. It also removes unreachable OpenAI order-alias merging: both provider constants already identify
openai, so the alias path could never win. Credential eligibility, cooldowns, and OpenAI API-key versus OAuth handling remain owned by the existing credential selector.User Impact
Stored auth order now controls the intended runtime, even when it conflicts with config or the selected credential exists only in the auth store. Clearing the stored order returns selection to configured/automatic behavior. Merely discovering a sole CLI credential does not implicitly select it. No new config option, dependency, database schema, or protocol change.
Documentation now describes stored-order precedence and the SQLite auth store. Production delta: +67 / −97 (net −30); tests: +176 / −5; docs: +4 / −1. Thanks @masatohoshino for the original fix and production reproduction; contributor credit is retained.
Evidence
Reviewed candidate:
410a8e8c1be3f9a0bbe7fe3f9bc8b08652e13a56.Before/after regressions: baseline ignored stored-only and conflicting stored order and routed despite an empty configured order. Additional failing-before cases caught stale-profile repair, a first store-only API profile, and stored-only CLI order/pins without config metadata.
77 tests passed across runtime aliases, credential ordering, snapshot lifecycle, external CLI selection, and CLI auth-order commands:
Eight real production-module scenarios passed on macOS / Node v24.19.0 with isolated synthetic state: actual
setAuthProfileOrder→ SQLite reload → runtime snapshot publication → actual Anthropic plugin discovery → runtime resolution. No mocks or provider requests:Local and complete-branch structured autoreview passed with no actionable findings; separate independent owner-boundary review passed.
Direct Codex contract inspection:
codex-rs/protocol/src/auth.rs:5-65,codex-rs/model-provider/src/auth.rs:197-220, andcodex-rs/model-provider/src/provider.rs:389-429at upstreamd47e5cc0e2bb. These preserve the separate API-key/OAuth shapes; this change does not alter Codex auth.Proof boundary: the production harness verifies persisted selection and resolver output, not an authenticated turn or Gateway snapshot-refresh lifecycle. The latter remains covered by the unchanged snapshot/auth-order tests and the preceding merged #119946. Callers that do not publish a runtime snapshot retain config-only behavior.
ClawSweeper rank-up: focused resolver tests are complete; required CI must be green on the pushed candidate before landing. The earlier CLI-help probe timed out during a cold build and was not a runtime-routing failure. The prior +59 production-line concern is eliminated by the net-negative owner refactor.