Skip to content

fix: keep OpenAI model discovery on configured auth profile - #137120

Merged
shakkernerd merged 22 commits into
mainfrom
workloop/fix-openai-catalog-auth-profile-c22cf759
Sep 6, 2026
Merged

shakkernerd merged 22 commits into
mainfrom
workloop/fix-openai-catalog-auth-profile-c22cf759

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes #137033

What Problem This Solves

With multiple OpenAI accounts, model discovery could choose persisted account A even when usable account B was configured first. A rejected or different inventory could hide B's models from listings and pickers.

Why This Change Was Made

Discovery now reuses canonical profile ordering, eligibility and account-wide cooldown rules. Preparation can advance past an unusable expiring OAuth candidate before discovery; each catalog request then stays bound to its selected profile, without another-account retry after rejection.

The selected credential's mode and current material travel together. Configured OpenAI OAuth/token credentials use subscription discovery, refreshed Chutes material reaches its consumer, and MiniMax derives the auth header from the same selection. Existing source precedence, optional profile provenance and provider-owned multiple credential probes remain supported.

A locked credential materialization returns that profile or its failure. The existing outer auth controller still performs permitted rotation and retains a user's stored pin. This is not a new no-failover policy.

User Impact

The preferred usable account supplies discovered models. Unresolved secret markers remain network-free, and asynchronous preparation cannot begin a catalog request after its deadline. Existing inventory retention and generation-owned native/configured rows remain intact. There are no new settings, schema changes or dependencies.

Evidence

  • The original configured B,A / persisted A,B failure is reproduced on the baseline. Controls also expose prior subscription-route, refreshed-token, timeout and MiniMax header defects.
  • 281 affected tests, core types, typed test lint, runtime/UI builds and the full selected exact-head CI pass on the final tree.
  • A built Gateway and CLI with isolated persisted profiles and controlled HTTPS prove B selection, failed-refresh inventory retention, recovery, account invalidation and successful-empty clearing. The browser records B's model missing before and available after.
  • Fresh SQLite and legacy JSON migrated by the built Doctor both pass the real session-pin, resolver, refresh-manager and auth-controller flow: locked A fails, outer selection explicitly uses B with B's identity, only A receives failure bookkeeping, and the pin survives. Only the refresh HTTP boundary is simulated.
  • A separate credentialed OpenAI request through the selected stored-profile catalog path observed one sent GET /v1/models, HTTP 200, the matching ready outcome and 11 compatible models. Credential bytes and response bodies were not logged. Subscription routing is covered with controlled HTTPS, not claimed as a credentialed subscription run.
  • Direct Codex source inspection at 728cb12fe5794b0c3a8e776fb4994b1650b973a8 verifies per-request auth-mode, bearer and account coupling. No universal native-session account-isolation change is claimed.

Visual evidence

Before After
Before: preferred account's GPT-5.4 Nano is missing from search After: preferred account's GPT-5.4 Nano is available

Before and after: search the real Gateway model picker

openai-catalog-proof.mp4

Visual verification

  • Baseline: 51647fa
  • Exact head: b352767a5b1941684dc722f925a483d690d6d192
  • Scenario: Persist accounts A then B, configure B first, open the real Gateway model picker and search for GPT-5.4 Nano. Controlled HTTPS inventories distinguish the two accounts.
  • Runtime/build: OpenClaw 2026.9.2; candidate source tree ecd5f835965332678f2b3c7cf0b1455ccd28693d; built entry SHA256 84850e50bec27179b36626ca02b29cd4640827a4024c5bed70109134ca21e251; real Linux Gateway and Chromium
  • Catalog request account: A before; configured preferred B after
  • Preferred account's model: Absent before; available after
  • Duplicate visible model rows: 0
  • Menu bounds: 340 x 296.78; within 1280 x 900 viewport
  • Recording: 10.24 seconds, 1280 x 900, 25 fps
  • Actual Gateway WebSocket traffic matches configured agent and refresh scope
  • Completed model inventory membership and availability match browser metadata
  • Browser model row absent before and selectable after
  • No session creation, chat send, account selection or operator-state mutation
  • All screenshots and full recording frame sequence inspected; published media is credential-free
  • Startup trimmed at 2.8 seconds; original recordings retained; final frames held 1 second per arm for legibility
  • Minor unrelated sidebar build-status difference does not affect the picker or controlled account fixture

@shakkernerd
shakkernerd requested a review from a team as a code owner September 3, 2026 07:02
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling extensions: openai size: M maintainer Maintainer-authored PR labels Sep 3, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 6, 2026, 2:04 AM ET / 06:04 UTC.

ClawSweeper review

What this changes

Makes model discovery honor configured account ordering and carry the selected credential’s identity, authentication mode, and refreshed token through catalog requests.

Merge readiness

⛔ Blocked before merge - 4 items remain

This PR remains necessary: current main still contains the reported discovery-order mismatch. The reviewed patch addresses it coherently, preserves earlier catalog compatibility fixes, and has substantial behavior evidence; no blocking code defect was identified.

Priority: P1
Reviewed head: b352767a5b1941684dc722f925a483d690d6d192
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, coherent repair with strong runtime evidence and no blocking code findings; the remaining compatibility approval does not reduce patch quality.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Captured evidence connects the changed catalog and credential owners to built Gateway/CLI controlled-HTTPS selection and recovery, fresh and migrated outer-controller recovery, and a credentialed selected-profile catalog GET with a matching successful outcome. Visual artifacts were unavailable to this reviewer and are not used to establish auth correctness.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Captured evidence connects the changed catalog and credential owners to built Gateway/CLI controlled-HTTPS selection and recovery, fresh and migrated outer-controller recovery, and a credentialed selected-profile catalog GET with a matching successful outcome. Visual artifacts were unavailable to this reviewer and are not used to establish auth correctness.
Evidence reviewed 11 items Pinned introduction boundary: The clean checkout matches b352767. Review used the verified merge-base-to-head changes, excluding the unrelated Mattermost, daemon, and Gateway endpoint drift. The supplied test merge has the pinned base followed by this exact head as parents.
Current main still needs the ordering repair: Inspection of fetched main shows createProviderAuthResolver still enumerating listProfilesForProvider and retaining a separate OAuth candidate instead of applying canonical configured ordering. The supplied related issue describes the same persisted A,B versus configured B,A mismatch: #137033.
Shipped resolver compatibility boundary: Both v2026.9.2 and fetched main omit allowProfileFallback when materializing an explicitly selected profile. This PR passes !lockedProfile, preventing the lower OAuth resolver from substituting a legacy alternate account after refresh failure. Existing direct locked callers therefore receive a failure where legacy recovery could previously succeed.
Findings None None.
Security None None.

How this fits together

Model discovery combines configured providers and stored credentials into account-specific model inventories used by the Gateway, CLI, and model pickers. Authentication selection determines which account supplies that inventory and how discovery failures are reported.

flowchart TD
  A[Configured account order] --> C[Credential selection]
  B[Stored profiles and cooldowns] --> C
  C --> D[Prepare selected credential]
  D --> E[Provider catalog request]
  E --> F[Account inventory and outcome]
  F --> G[Gateway CLI and model pickers]
Loading

Decision needed

Question Recommendation
Should lockedProfile forbid legacy alternate-account OAuth recovery for every shared resolver caller, as this PR implements? Accept the shared lock contract: Have the listed auth-path owner accept exact-profile materialization, with permitted account rotation owned explicitly by callers.

Why: The change tightens behavior present in v2026.9.2 beyond catalog discovery; source and recovery proof support the implementation, but the required auth-path owner's acceptance is not established.

Before merge

  • Resolve merge risk (P1) - Direct locked-profile callers lose legacy alternate-account recovery after OAuth refresh failure and can now stop until the selected account is repaired; fresh and migrated outer-controller recovery is evidenced, but listed-owner acceptance of this shared contract remains unconfirmed.
  • Resolve merge risk (P1) - The historical Codex revision cited in the body and linked visual media could not be independently inspected here; available dependency source and the captured runtime evidence were assessed without substituting them for those artifacts.
  • Complete next step (P2) - Obtain listed auth-path owner acceptance of the shared locked-profile contract, including direct callers that previously received legacy alternate-account recovery.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source +290, Tests +1132, Docs +20. Total +1442 across 24 files.

View PR surface stats
Area Files Added Removed Net
Source 14 453 163 +290
Tests 8 1216 84 +1132
Docs 2 20 0 +20
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 24 1689 247 +1442

Review metrics

Metric Value Why it matters
Production and regression coverage Net production +290 lines; tests +1,132 lines Production growth supports credential preparation and provenance, while most growth supplies regression coverage across account selection and recovery boundaries.
Public catalog metadata 1 optional return field; 0 new user settings Credential mode is additive metadata on the existing API-key callback, avoiding a parallel public resolver.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #137033
Summary: This PR is the explicit implementation candidate for the linked configured-account discovery mismatch.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Approve exact-profile resolution (recommended)
    Accept the documented loss of implicit alternate-account recovery for direct locked callers after listed-owner review of the shared contract.
  2. Limit the initial rollout
    Narrow the stricter materialization behavior to catalog discovery if the owner requires legacy recovery elsewhere.

Technical review

Best possible solution:

Keep account selection canonical and request identity stable, with listed-owner acceptance of the shared locked-profile contract and explicit rotation remaining in the outer auth controller.

Do we have a high-confidence way to reproduce the issue?

Yes: persist accounts A then B, configure B first, and give the accounts distinct catalog responses. Current-main source still selects by persisted order; this review did not execute a reproduction.

Is this the best way to solve the issue?

Yes for the ordering repair: reusing canonical selection and carrying credential facts together fixes the producer boundary. Applying strict locking to every shared resolver caller remains an explicit compatibility choice.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1ad2e83fd7d5.

Labels

Label justifications:

  • P1: The existing mismatch can hide models available to the configured usable account across Gateway, CLI, and picker workflows.
  • merge-risk: 🚨 compatibility: Shared locked-profile resolution stops legacy alternate-account recovery that shipped callers could previously receive.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Captured evidence connects the changed catalog and credential owners to built Gateway/CLI controlled-HTTPS selection and recovery, fresh and migrated outer-controller recovery, and a credentialed selected-profile catalog GET with a matching successful outcome. Visual artifacts were unavailable to this reviewer and are not used to establish auth correctness.
  • proof: sufficient: Contributor real behavior proof is sufficient. Captured evidence connects the changed catalog and credential owners to built Gateway/CLI controlled-HTTPS selection and recovery, fresh and migrated outer-controller recovery, and a credentialed selected-profile catalog GET with a matching successful outcome. Visual artifacts were unavailable to this reviewer and are not used to establish auth correctness.

Evidence

What I checked:

  • Pinned introduction boundary: The clean checkout matches b352767. Review used the verified merge-base-to-head changes, excluding the unrelated Mattermost, daemon, and Gateway endpoint drift. The supplied test merge has the pinned base followed by this exact head as parents. (b352767a5b19)
  • Current main still needs the ordering repair: Inspection of fetched main shows createProviderAuthResolver still enumerating listProfilesForProvider and retaining a separate OAuth candidate instead of applying canonical configured ordering. The supplied related issue describes the same persisted A,B versus configured B,A mismatch: [Bug]: OpenAI model discovery ignores configured auth profile order #137033. (src/agents/models-config.providers.secrets.ts:206, 1ad2e83fd7d5)
  • Shipped resolver compatibility boundary: Both v2026.9.2 and fetched main omit allowProfileFallback when materializing an explicitly selected profile. This PR passes !lockedProfile, preventing the lower OAuth resolver from substituting a legacy alternate account after refresh failure. Existing direct locked callers therefore receive a failure where legacy recovery could previously succeed. (src/agents/model-auth-provider.ts:233, b352767a5b19)
  • Selection and preparation stay at their owners: Catalog selection reuses canonical ordering with account-wide cooldown scope. OAuth preparation excludes failed expiring candidates locally and carries refreshed material only for the matching selected profile. The timeout owner checks active after preparation before starting the catalog. (src/agents/models-config.providers.implicit.ts:378, b352767a5b19)
  • Earlier outcome findings are resolved: The shared catalog wrapper forwards provider-owned outcomes without requiring unique callback provenance, including multiple credential probes. The optional mode field preserves the existing callback signature, and its documentation explicitly ties mode to the credential returned by that lookup. (src/plugins/provider-catalog.types.ts:25, b352767a5b19)
  • Focused production-composition coverage: The integration tests exercise persisted profile ordering, OAuth preparation failure followed by explicit candidate selection, configured subscription routing, refreshed Chutes material, and absence of late catalog I/O after timeout. These tests were read, not executed during this read-only review. (test/openai-model-discovery-auth-order.test.ts:125, b352767a5b19)

Likely related people:

  • openclaw/openclaw-secops: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (22 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-03T15:15:25.557Z sha 4ade0ba :: blocked before merge. :: [P1] Preserve legacy profile-scoped catalog outcomes
  • reviewed 2026-09-03T15:49:47.981Z sha 830c91a :: blocked before merge. :: [P1] Preserve profile-scoped catalog outcome compatibility
  • reviewed 2026-09-03T16:12:00.065Z sha 830c91a :: blocked before merge. :: [P1] Preserve multi-profile catalog outcome compatibility
  • reviewed 2026-09-03T16:39:44.326Z sha 040507d :: blocked before merge. :: none
  • reviewed 2026-09-06T04:25:56.569Z sha 77ec7fff3e65b6c4ef08893e491ba06d145fa889 :: blocked before merge. :: none
  • reviewed 2026-09-06T04:48:37.668Z sha e154066250f8a852e03e12fa09597587dbb4b78e :: blocked before merge. :: none
  • reviewed 2026-09-06T05:08:47.614Z sha b352767 :: blocked before merge. :: none
  • reviewed 2026-09-06T05:59:01.397Z sha b352767 :: blocked before merge. :: none

@shakkernerd shakkernerd closed this Sep 3, 2026
@shakkernerd shakkernerd reopened this Sep 3, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Sep 3, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 3, 2026
@shakkernerd

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 3, 2026
@shakkernerd

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@shakkernerd
shakkernerd force-pushed the workloop/fix-openai-catalog-auth-profile-c22cf759 branch from e154066 to b352767 Compare September 6, 2026 05:01
@shakkernerd shakkernerd self-assigned this Sep 6, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Sep 6, 2026
@shakkernerd
shakkernerd merged commit 21a4cae into main Sep 6, 2026
184 checks passed
@shakkernerd
shakkernerd deleted the workloop/fix-openai-catalog-auth-profile-c22cf759 branch September 6, 2026 06:50
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: OpenAI model discovery now follows configured profile priority and keeps each catalog request bound to its selected account.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
…#137120)

Use canonical eligible auth-profile ordering for OpenAI model discovery and keep the selected credential's mode, current material, and profile identity together. Preserve shared provider catalog compatibility.

Closes openclaw#137033.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: minimax extensions: openai maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OpenAI model discovery ignores configured auth profile order

1 participant