Skip to content

fix(models): restore missing picker choices after startup - #139848

Merged
steipete merged 1 commit into
mainfrom
codex/models-inventory-139498-139499
Sep 6, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/models-inventory-139498-139499

Conversation

@steipete

@steipete steipete commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #139498
Closes #139499

What Problem This Solves

Fixes an issue where model pickers stayed on configured-only choices after a Gateway restart until another client explicitly refreshed the inventory. Channel pickers also omitted configured models routed through an authenticated CLI, even when Gateway model listing recognized their availability.

Reported by @goslingmanagment.

Why This Change Was Made

Ordinary inventory demand now initializes an undiscovered catalog through its existing lifecycle owner. The same queue, generation checks, and paired catalog/auth publication remain responsible for discovery. Explicit refresh still queries providers after compatible reloads, even when retained inventory first needs native-harness projection. Startup, prepared-only reads, and turn preparation remain passive.

Prepared channel auth evaluation now uses the existing CLI-runtime projection, preserving disabled-plugin and selected-account restrictions. Unprepared setup hints retain their existing provider-only behavior. When discovery exceeds the existing browse deadline, channel rendering retains the current prepared owner instead of dropping its configured rows and auth facts.

This is a bounded repair to current behavior, separate from the broader model-surface work in draft #136257. There are no new configuration options, dependencies, database changes, or protocol changes.

User Impact

After restart, ordinary browsing converges to the discovered inventory without opening another client or requesting an explicit refresh. Configured CLI-bound choices remain visible when the prepared native runtime is ready, including while discovery continues. A provider API key does not substitute for that runtime's native login.

Evidence

Observed results from the final real-Gateway harness:

{
  "scenariosPassed": 2,
  "initialNativeProviderButton": "anthropic (2)",
  "nativeSelectableModels": [
    "claude-haiku-4-5",
    "claude-sonnet-4-6"
  ],
  "gatewayNativeModelsAvailable": true,
  "nativeAuthStatusCalls": 2,
  "initialDiscoveryRequests": 3,
  "discoveryAttemptsDuringReuse": 0,
  "requestsAfterExplicitRefresh": 4
}
  • Captured failing regressions before each repair: cold inventory never started discovery; channel auth omitted native-ready choices and incorrectly accepted a provider key/disabled runtime; bounded fallback dropped already prepared native facts.
  • All 290 focused tests passed together across ten files, covering catalog ownership, concurrent discovery, retired generations, passive reads, channel menus, CLI setup pickers, and Gateway account restrictions. Assertions were retained; command-output fixtures now control clocks instead of racing host load against the 750 ms deadline.
  • Real behavior is exercised with the existing isolated Gateway and Telegram polling/callback harness. Only the external Bot API, Ollama endpoint, and native CLI auth-status process are simulated. The cold inventory and native picker flows passed, including the first anthropic (2) menu and Haiku/Sonnet selection buttons. The final exact-source rerun after the explicit-refresh correction also passed both scenarios. The native case observes startup readiness with preparedOnly: true, then exercises the first cold /models menu and callback without warming full discovery.
  • Fresh independent review found no remaining P0–P2 findings after the timeout-owner and explicit-refresh corrections. Changed-surface checks, core/E2E typechecks, and targeted lint passed.
  • Production delta: +33 net lines to preserve inventory intent and prepared-auth ownership; no parallel catalog implementation.
  • Live Telegram Test Server verification is unavailable on this host: no authenticated Convex CLI or broker credentials are present. No live Anthropic account, model turn, or Windows execution is claimed.

The separate existing channel session-account-context propagation gap is not addressed here: this PR does not claim end-to-end channel account-selection parity. Model execution retains its own account and authorization checks.

Runtime proof used Node 26.8.1/pnpm 12.3.4 on macOS arm64, base b3bdf3e11da5671dac9b6033edd49673c129f511 plus the four-file candidate. Production/test postimages match this commit. The initial package-bootstrap timeout is excluded from behavior proof; final fixtures run the existing built-Gateway path with synthetic external boundaries.

CI passed on the reviewed head, including the required openclaw/ci-gate.

Owner involvement

This repair was explicitly directed by @steipete, the PR author and an active maintainer of the listed authentication owner team, openclaw/openclaw-secops. Live GitHub verification on 2026-09-06 via GET /orgs/openclaw/teams/openclaw-secops/memberships/steipete returned {"state":"active","role":"maintainer"}. This establishes the listed-owner involvement requested in the ClawSweeper review; no ownership policy or enforced GitHub approval requirement is changed.

Additional remote validation

The prepared head 0171ed498cb764d189712a3b2ba3c70dea0dacec was independently validated on Blacksmith Testbox. Its changed runtime and E2E fixture postimages match landed commit 48f76a5c11193086b1ec2b7abe408aac34214812, whose ancestry on main was verified. These runs completed after the independent landing.

Source Lease Run Result
Baseline b3bdf3e11da5671dac9b6033edd49673c129f511, with only the candidate E2E fixture tbx_01m1tq88j2m393641cg1ev21zh before Both original defects reproduced
Exact prepared head 0171ed498cb764d189712a3b2ba3c70dea0dacec tbx_01m1tq6a1rzdv6903fnwqjzyyx after Both scenarios passed

Both sources passed pnpm build and harness-owned QA runtime preparation, followed by:

node scripts/run-vitest.mjs \
  test/e2e/qa-lab/runtime/telegram-model-picker-prepared-gateway.e2e.test.ts \
  -t 'initializes unrestricted|lists native CLI-bound'

Sanitized behavior transcript:

Before: 2 failed; 1 unrelated scenario unselected
  Ordinary models.list omitted ollama/discovered-model
  Telegram: expected "anthropic (2)", received "anthropic (1)"
After: 2 passed; 1 unrelated scenario unselected
  Ordinary discovery, cached reuse and explicit-refresh assertions passed
  Telegram "anthropic (2)" and Haiku/Sonnet selection callbacks passed
  Gateway native availability and zero native-command model requests passed

A separate built-CLI check stopped and restarted each Gateway with the same isolated state. At both startup and restart, baseline ordinary models.list omitted the two synthetic Ollama rows until refresh: true; the candidate returned both before refresh. This supplemental check proves membership only: its rows were deliberately unavailable, and native readiness is established by the Telegram E2E above.

The Gateway/plugin/channel paths were real; the external Telegram Bot API, Ollama endpoint, and Claude CLI auth-status executable were synthetic. All state, homes, workspaces, and free loopback ports were isolated. No live inference or Telegram Test Server execution is claimed: the remote hosts had no authenticated Convex CLI or broker pair. Both leases were stopped and independently reported completed; Gateway logs showed clean shutdowns.

Fresh independent branch review found no actionable P0–P2 findings. git diff --numstat totals: production +56/-23 (+33), tests +495/-51 (+444), docs +8/-0. Production growth restores missing cold-inventory initialization and deadline recovery while applying the existing runtime-auth decision to channel browsing; no second catalog or auth policy is introduced.

Initialize cold inventory through its existing owner, preserve explicit
refresh after reload, and retain prepared facts through browse deadlines.
Apply CLI-runtime availability to prepared channel auth while preserving
unprepared setup hints and explicit account restrictions.

Fixes #139498 and #139499. Reported by @goslingmanagment.
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Sep 6, 2026
@steipete
steipete marked this pull request as ready for review September 6, 2026 06:30
@steipete
steipete requested a review from a team as a code owner September 6, 2026 06:30
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Ready to land the repair for #139498 and #139499. Cold inventory demand uses the existing owner queue; channel availability honors prepared CLI authentication; bounded fallback retains current owner facts; explicit refresh remains forced after compatible reloads.

Validation on 0171ed498cb764d189712a3b2ba3c70dea0dacec:

  • 290 focused tests passed across catalog lifecycle, provider auth, channel commands, setup pickers, and Gateway account restrictions. Each repaired defect has a failing pre-fix regression.
  • The exact-source isolated Gateway/Telegram harness passed both scenarios. Actual first-menu text was anthropic (2); callbacks included Haiku and Sonnet, matching Gateway available: true rows. Discovery reused its prepared catalog and queried again for explicit refresh.
  • Independent review found no remaining P0–P2 findings. Changed-surface checks and final targeted core/E2E typecheck and lint passed.

Focused command:

node scripts/run-vitest.mjs src/agents/prepared-model-runtime.scoped-refresh.test.ts src/agents/prepared-model-catalog.test.ts src/agents/prepared-model-runtime.startup-static.test.ts src/agents/prepared-model-runtime.reload-auth.test.ts src/agents/model-provider-auth.test.ts src/agents/model-catalog-browse.test.ts src/gateway/server-methods/models-list-result.cli-runtime-availability.test.ts src/auto-reply/reply/commands-models.catalog-recovery.test.ts src/auto-reply/reply/commands-models.test.ts src/commands/model-picker.test.ts

Real Gateway boundary command:

node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts test/e2e/qa-lab/runtime/telegram-model-picker-prepared-gateway.e2e.test.ts -t 'initializes unrestricted|lists native CLI-bound'

The external Telegram Bot API, Ollama endpoint, and CLI auth-status process are simulated; no live Telegram/Claude account or Windows execution is claimed. Full cold runtime builds and task-owned fixture cleanup completed. Existing channel session-account-context propagation remains a separate documented follow-up.

CI passed, including the required openclaw/ci-gate: https://github.com/openclaw/openclaw/actions/runs/34016661831

@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

The PR body contains final before/after proof, exact-source real Gateway observations, and passing CI for the current head. Both independent-review findings were reproduced and addressed. Please review this revision for the native landing gate.

@clawsweeper

clawsweeper Bot commented Sep 6, 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 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

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

ClawSweeper review

What this changes

The PR initializes model inventory on first browse after startup and preserves prepared CLI authentication and configured choices through slow catalog discovery.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains a useful, bounded repair: fetched main still contains both reported failure paths, and the broader draft does not supersede it. No blocking correctness defect was found.

Priority: P2
Reviewed head: 0171ed498cb764d189712a3b2ba3c70dea0dacec

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage and relevant Gateway boundary proof.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The supplied exact-source macOS Gateway transcript exercises cold discovery and native-ready Telegram menus through production polling and callbacks, showing restored choices, catalog reuse, and explicit refresh; external services and CLI auth status are simulated under the repository's accepted channel-boundary proof policy.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The supplied exact-source macOS Gateway transcript exercises cold discovery and native-ready Telegram menus through production polling and callbacks, showing restored choices, catalog reuse, and explicit refresh; external services and CLI auth status are simulated under the repository's accepted channel-boundary proof policy.
Evidence reviewed 9 items Verified introduced production changes: The merge-base-to-head diff changes the existing catalog demand path, prepared authentication projection, and bounded browse fallback; it introduces no parallel inventory implementation.
Repair remains necessary on fetched main: Fetched main still requires catalogStale before initiating inventory repair. Its provider checker also returns evaluateModelAuth directly without the CLI-runtime projection. The supplied reports identify v2026.9.2 as affected; no merged fixing PR or fixed release is established.
Existing lifecycle safeguards retained: The full-catalog owner serializes builds, shares pending discovery, checks generation liveness before and after asynchronous work, publishes catalog/auth together, and forces provider discovery when explicit refresh follows retained-inventory projection.
Findings None None.
Security None None.

How this fits together

The Gateway prepares model inventory and authentication facts for model pickers. Gateway requests and channel commands use those facts to decide which providers and models to display.

flowchart TD
  A[Gateway startup] --> B[Prepared catalog and authentication]
  C[Model browse request] --> D{Inventory initialized?}
  D -->|No| E[Existing discovery owner]
  E --> B
  D -->|Yes| B
  B --> F[Model visibility and runtime readiness]
  F --> G[Gateway and channel pickers]
Loading

Before merge

  • Resolve merge risk (P1) - Listed secops-owner involvement for the authentication changes is not established by the supplied review metadata.
  • Complete next step (P2) - Confirm listed secops-owner involvement for the agent authentication changes before landing.
Agent review details

Security

None.

PR surface

Source +33, Tests +444, Docs +8. Total +485 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 4 56 23 +33
Tests 8 495 51 +444
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 559 74 +485

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +33 net lines; tests +444 net lines The production growth preserves inventory intent and prepared-owner facts, while most growth exercises lifecycle and picker regressions.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep model browsing consistent through the existing catalog lifecycle and shared runtime-readiness rules, without adding configuration or duplicating discovery.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep model browsing consistent through the existing catalog lifecycle and shared runtime-readiness rules, without adding configuration or duplicating discovery.

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

Yes, from source: a static startup catalog is not auth-stale, so ordinary reads never initialize discovery; channel availability also omits the existing CLI projection. No runtime reproduction was executed during this review.

Is this the best way to solve the issue?

Yes. The patch repairs the existing owners, preserves passive prepared reads and account restrictions, and adds targeted cold-start, reload, timeout, and channel-boundary coverage.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: Repairs missing model-picker choices after restart and for CLI-bound models, with existing explicit-refresh and direct-selection workarounds.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The supplied exact-source macOS Gateway transcript exercises cold discovery and native-ready Telegram menus through production polling and callbacks, showing restored choices, catalog reuse, and explicit refresh; external services and CLI auth status are simulated under the repository's accepted channel-boundary proof policy.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The change restores visible Telegram provider counts and model-selection buttons, making it suitable for Telegram Test Server verification.

Label justifications:

  • P2: Repairs missing model-picker choices after restart and for CLI-bound models, with existing explicit-refresh and direct-selection workarounds.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied exact-source macOS Gateway transcript exercises cold discovery and native-ready Telegram menus through production polling and callbacks, showing restored choices, catalog reuse, and explicit refresh; external services and CLI auth status are simulated under the repository's accepted channel-boundary proof policy.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The change restores visible Telegram provider counts and model-selection buttons, making it suitable for Telegram Test Server verification.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Shakker: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • openclaw/openclaw-secops: 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.

@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The PR body now records the missing listed-owner evidence: @steipete explicitly directed this repair and is a live-verified active maintainer of openclaw/openclaw-secops. The reviewed code remains at 0171ed498cb764d189712a3b2ba3c70dea0dacec; all existing proof and green exact-head CI remain unchanged. Please reassess the owner-involvement findings against that evidence.

@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit 48f76a5 into main Sep 6, 2026
255 checks passed
@steipete
steipete deleted the codex/models-inventory-139498-139499 branch September 6, 2026 06:52
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 6, 2026
* refactor(models): centralize runtime-aware availability

Follow up #139848 with one shared runtime-auth evaluator for Gateway, CLI, and prepared channel pickers. Preserve provider-only setup hints and required-account auth. The original picker regressions were reported by @goslingmanagment in #139498 and #139499.

* fix(types): declare runtime auth evaluator receiver-free
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
…39848)

Initialize cold inventory through its existing owner, preserve explicit
refresh after reload, and retain prepared facts through browse deadlines.
Apply CLI-runtime availability to prepared channel auth while preserving
unprepared setup hints and explicit account restrictions.

Fixes openclaw#139498 and openclaw#139499. Reported by @goslingmanagment.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
)

* refactor(models): centralize runtime-aware availability

Follow up openclaw#139848 with one shared runtime-auth evaluator for Gateway, CLI, and prepared channel pickers. Preserve provider-only setup hints and required-account auth. The original picker regressions were reported by @goslingmanagment in openclaw#139498 and openclaw#139499.

* fix(types): declare runtime auth evaluator receiver-free
obviyus added a commit that referenced this pull request Oct 7, 2026
…ason (#166338)

## What Problem This Solves

Claude Code is installed but logged out, and onboarding has pinned the `anthropic/*` models to the `claude-cli` runtime. In that state the Control UI chat picker shows only the default model. It is disabled, has no reason, and the header says "No models available". The other 9 pinned models disappear, so a non-technical user cannot tell what is wrong or how to fix it.

## Root cause and provenance

There are two causes. Both were reproduced live on an isolated Gateway, with debug logging that has since been removed.

1. **The login reason is held back until the full catalog finishes.** `evaluateCliRuntimeModelAuthAvailability` only reports `missing-auth` once `preparedSyntheticAuthComplete` is true. That gate came from #134463 (84e8133), and it exists for a good reason. The full-catalog worker finds direct CLI routes *after* startup, so their login has not been checked yet. In the words of #134463: "the full-catalog worker prepared synthetic auth only for providers present in the configured startup scope".
   The gate is too broad for runtimes the config already names. Preparation already checks their login at startup: `collectPreparedModelRuntimeProviderIds` adds every configured harness runtime to the startup provider scope, and `prepared-model-runtime.facts.ts` checks the synthetic auth of that scope.
   Meanwhile the picker never asks for a full refresh ("Opening the picker reuses prepared catalog facts; explicit Refresh owns discovery", per docs/concepts/models.md). Live logging showed the catalog stayed incomplete, with `anthropic` and `claude-cli` missing from inventory, until someone ran an explicit `refresh`. So the startup check had already returned "logged out", but the picker never displayed it.
2. **Configured rows are hidden when they are not signed in.** With an allow-any policy, the configured view lists only inline provider rows, rows that are signed in, and the default and fallbacks. Each `agents.defaults.models` key is in `configuredKeys` and is tagged `configured`, but it was only listed while signed in.
   This is a side effect of #110888 (09a64f7). That change made the `models` map metadata only. Before it, any entry turned the map into a closed allowlist, and allowlisted rows always showed. #113594 also promised that "nobody's pinned model disappears".

Earlier decisions are kept:
- The per-model `claude-cli` pins (#82546, #84374) are kept, and so is Doctor's canonicalization.
- #134463 still applies to routes found later and to runtimes that are not configured: their availability stays unknown until the full catalog arrives.
- #166305's 60-second login recheck is unchanged. After `claude auth login`, the rows still turn available without a restart.

## Fix

- `src/agents/model-auth-availability.cli-runtime.ts`: a configured runtime with no prepared runtime auth mode now gets `missing-auth` even before the full catalog arrives. "Configured" is decided by the same `collectPreparedModelRuntimeProviderIds` set that startup checks, computed once per resolver and only on this path.
  The CLI-runtime evaluator moved here from `model-auth-availability.ts` unchanged, because the line-cap ratchet does not allow that file to grow (-108 lines there).
- `src/agents/model-catalog-visibility.ts`: configured refs now stay in the default and configured views, shown as unavailable, until their login or key comes back. This uses the same `configuredKeys` that already keeps deprecated configured rows visible.
- Control UI: if the picker has no usable model and a Claude CLI row reports `missing-auth`, the empty-state label becomes "Claude Code isn't ready. If signed out, run claude auth login." instead of "No models available". "Manage models" stays next to it.
  The copy is conditional on purpose. `missing-auth` on a Claude CLI row also covers a disabled or denied anthropic plugin and a missing personal-account pin, so an already signed-in user can see it. The reason enum (`missing-auth` | `auth-failed` | `cooldown`) is closed and shared with the Swift and Kotlin clients, and no existing value fits a disabled plugin, so this PR keeps the protocol unchanged and words the hint to stay true in every `missing-auth` case.
  `claude auth login` is the command OpenClaw's own hints already use (`oauth-refresh-failure.ts`, `doctor-claude-cli.ts`, `extensions/anthropic/auth.runtime.ts`). `claude setup-token` makes an API token for the Anthropic provider; it does not log in the CLI runtime.
- Channel `/models` (`commands-models-menu.ts`): for Claude CLI rows reporting `missing-auth`, the recovery line now uses the same wording as the picker hint ("If Claude Code is signed out, run claude auth login on the Gateway host, or choose another model.") instead of `/login anthropic`. Other routes are unchanged.
- `docs/concepts/models.md`: documents that configured models stay listed as unavailable, and adds the Claude Code login line.

No new config keys and no protocol changes: the existing `missing-auth` value is reused.

## Evidence

Isolated Gateway on this Mac with state, config and `CLAUDE_CONFIG_DIR` under /tmp. The config is the one written by the real `openclaw onboard --non-interactive --auth-choice anthropic-cli`. The logged-out state is a fresh, empty `CLAUDE_CONFIG_DIR` (`claude auth status` → `loggedIn: false`). The logged-in run uses a wrapper that answers only `claude auth status` with `loggedIn: true`. No real Claude login was touched.

Screenshots retaken on the final head (36b263f) and on origin/main (2c620bb), each from its own isolated Gateway:

| | Logged out | Logged in |
|---|---|---|
| origin/main | ![main logged out: "No models available", only the default anthropic row](https://github.com/user-attachments/assets/f8b6d3d6-4f15-4587-9d73-2b0d1a61ccdf) | ![main logged in](https://github.com/user-attachments/assets/9d3af782-a7b0-4f44-9ca7-b2466b5b4f57) |
| this branch | ![branch logged out: Claude Code hint, every pinned model listed with Sign-in needed](https://github.com/user-attachments/assets/ef9cdb9e-adb5-40e3-a1b9-1486523c4d7a) | ![branch logged in: unchanged](https://github.com/user-attachments/assets/f612872e-c63d-4751-81bd-8a7515de99d9) |

Picker contents (search "Claude"):
- **origin/main, logged out:** "No models available"; one `anthropic/*` row (the default), no reason.
- **This branch, logged out:** "Claude Code isn't ready. If signed out, run claude auth login."; all 10 pinned `anthropic/*` rows listed with "Sign-in needed".
- **Logged in:** no empty-state label, and the same 23 picker rows in the same order on both heads.

### Telegram Test Server (`/models anthropic`)

Ran the repository's Telegram userbot runner on the Telegram Test Server with a Convex-leased bot and QA user (`run-mock-sut-user-e2e.mjs --dm --scenario`). The runner starts a fresh Gateway from each checkout's build. The config patch adds two configured `anthropic/*` models pinned to `claude-cli` and enables the anthropic plugin. `CLAUDE_CONFIG_DIR` points at an empty directory, so Claude Code is logged out. The QA user sends `/models anthropic` at 1 s and again at 40 s, after startup discovery. `/models` is a native command, so no model turn runs; the only mock-provider rows are two `/` readiness probes.

| | 1 s | 40 s |
|---|---|---|
| origin/main `2c620bbfe84c` | "anthropic: checking models…" | "Unknown provider: anthropic … Available providers: • openai". The configured Claude CLI models are gone. |
| this branch `45dce1142171` | "Models (anthropic) — 0 of 2 available … anthropic: Sign-in needed. If Claude Code is signed out, run claude auth login on the Gateway host, or choose another model." Buttons: `…needed — Claude CLI · claude-opus-4-7`, `…eded — Claude CLI · claude-sonnet-4-6`, `<< Back`. | Same reply and buttons. |

The `…` at the start of the button labels comes from Telegram's existing button-length truncation; this PR does not touch it.

`models.list {view: "configured"}`, logged out, no refresh:
- **origin/main:** 1 `anthropic/*` row (the default), `available: false`, no reason.
- **This branch:** all 10 pinned `anthropic/*` rows, `available: false`, `unavailableReason: "missing-auth"`.
- **Logged in:** the configured-view rows, runtimes and availability on this branch are identical to the origin/main capture of the same config.

The duplicate `claude-cli/*` rows in the screenshots are the existing twins; #166311 removes them.

## Tests

- `models-list-result.cli-runtime-availability.test.ts`, new case: an onboarding-shaped config, Claude logged out, catalog incomplete, configured view, run through the real `buildModelsListResult`. Every pinned row is listed with `missing-auth`, and the unpinned API row stays hidden. It fails on origin/main for both causes (rows missing, no reason).
- `models.test.ts`: the existing table row for "logged out, catalog incomplete" now expects `missing-auth`, because the runtime is configured. It fails on origin/main.
- `chat-model-catalog-state.test.ts`: the real `renderChatModelPicker`, given a `missing-auth` Claude CLI row, renders exactly the conditional Claude Code hint (the same row a signed-in user gets when the anthropic plugin is disabled, which `models-list-result.cli-runtime-availability.test.ts` already covers on the producer side). Other providers keep "No models available". It fails on origin/main (`expected 'No models available'`).
- `commands-models.catalog-recovery.test.ts` and `commands-models.test.ts` go through the real `/models` handler, which reads the same projection as the picker. A CLI-bound configured model is now listed in every auth state. It is marked "Sign-in needed" unless its prepared native login is present and its plugin is enabled. Its recovery line reads "If Claude Code is signed out, run claude auth login on the Gateway host, or choose another model." instead of `/login anthropic`, which can't fix a Claude Code login or a disabled plugin.
  A logged-out configured Claude CLI default now gets that recovery line instead of "Connection not confirmed". The #139848 rule still holds: with only an API key, the bound row shows "Sign-in needed" and is not available.
- Wall time with `pnpm test <file> --maxWorkers=1`: 35 s, 37 s and 3 s. The new gateway case takes 325 ms. No timers and no new fixtures.
- Also run: affected suites (`model-catalog*`, `model-auth-availability*`, `model-selection*`, `server-methods/models*`, `commands/models`, the chat picker UI and new-session), all passing. `node scripts/check-changed.mjs` exits 0 (tsgo core and UI, lint, import cycles, line-cap ratchet, i18n).

## Bounded cost

- No new processes, probes, network calls or catalog work. The existing startup `claude auth status` check and #166305's 60-second recheck are unchanged.
- The configured-runtime set is built at most once per auth resolver, which is one per `models.list` read. It is built only when a CLI-runtime row has no prepared login, and it is a pure walk over the config's model refs.
- Visibility adds one `Set.has` per catalog row. The UI adds one `.some()` over picker options per render.
- Picker size is bounded by configured refs: at most the number of models the user authored, and they were already listed while signed in.

## User impact

A logged-out Claude Code user sees every configured Claude model, greyed with "Sign-in needed", and a header that names the command to run. Once `claude auth login` succeeds, the rows turn available on the next read after #166305's recheck. Configured models for other providers that have lost their key now also stay listed as unavailable instead of disappearing. The channel `/models` command shows the same rows marked "Sign-in needed", and Claude CLI rows get the conditional `claude auth login` recovery line. The logged-in picker is unchanged.

## LOC vs origin/main

Production +182/-118. The moved evaluator accounts for +147/-112 and is unchanged apart from the configured-runtime check, so the behaviour change itself is about +35. Tests +82/-12. Docs +3/-1.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
…ason (openclaw#166338)

## What Problem This Solves

Claude Code is installed but logged out, and onboarding has pinned the `anthropic/*` models to the `claude-cli` runtime. In that state the Control UI chat picker shows only the default model. It is disabled, has no reason, and the header says "No models available". The other 9 pinned models disappear, so a non-technical user cannot tell what is wrong or how to fix it.

## Root cause and provenance

There are two causes. Both were reproduced live on an isolated Gateway, with debug logging that has since been removed.

1. **The login reason is held back until the full catalog finishes.** `evaluateCliRuntimeModelAuthAvailability` only reports `missing-auth` once `preparedSyntheticAuthComplete` is true. That gate came from openclaw#134463 (47f0122), and it exists for a good reason. The full-catalog worker finds direct CLI routes *after* startup, so their login has not been checked yet. In the words of openclaw#134463: "the full-catalog worker prepared synthetic auth only for providers present in the configured startup scope".
   The gate is too broad for runtimes the config already names. Preparation already checks their login at startup: `collectPreparedModelRuntimeProviderIds` adds every configured harness runtime to the startup provider scope, and `prepared-model-runtime.facts.ts` checks the synthetic auth of that scope.
   Meanwhile the picker never asks for a full refresh ("Opening the picker reuses prepared catalog facts; explicit Refresh owns discovery", per docs/concepts/models.md). Live logging showed the catalog stayed incomplete, with `anthropic` and `claude-cli` missing from inventory, until someone ran an explicit `refresh`. So the startup check had already returned "logged out", but the picker never displayed it.
2. **Configured rows are hidden when they are not signed in.** With an allow-any policy, the configured view lists only inline provider rows, rows that are signed in, and the default and fallbacks. Each `agents.defaults.models` key is in `configuredKeys` and is tagged `configured`, but it was only listed while signed in.
   This is a side effect of openclaw#110888 (69e799e). That change made the `models` map metadata only. Before it, any entry turned the map into a closed allowlist, and allowlisted rows always showed. openclaw#113594 also promised that "nobody's pinned model disappears".

Earlier decisions are kept:
- The per-model `claude-cli` pins (openclaw#82546, openclaw#84374) are kept, and so is Doctor's canonicalization.
- openclaw#134463 still applies to routes found later and to runtimes that are not configured: their availability stays unknown until the full catalog arrives.
- openclaw#166305's 60-second login recheck is unchanged. After `claude auth login`, the rows still turn available without a restart.

## Fix

- `src/agents/model-auth-availability.cli-runtime.ts`: a configured runtime with no prepared runtime auth mode now gets `missing-auth` even before the full catalog arrives. "Configured" is decided by the same `collectPreparedModelRuntimeProviderIds` set that startup checks, computed once per resolver and only on this path.
  The CLI-runtime evaluator moved here from `model-auth-availability.ts` unchanged, because the line-cap ratchet does not allow that file to grow (-108 lines there).
- `src/agents/model-catalog-visibility.ts`: configured refs now stay in the default and configured views, shown as unavailable, until their login or key comes back. This uses the same `configuredKeys` that already keeps deprecated configured rows visible.
- Control UI: if the picker has no usable model and a Claude CLI row reports `missing-auth`, the empty-state label becomes "Claude Code isn't ready. If signed out, run claude auth login." instead of "No models available". "Manage models" stays next to it.
  The copy is conditional on purpose. `missing-auth` on a Claude CLI row also covers a disabled or denied anthropic plugin and a missing personal-account pin, so an already signed-in user can see it. The reason enum (`missing-auth` | `auth-failed` | `cooldown`) is closed and shared with the Swift and Kotlin clients, and no existing value fits a disabled plugin, so this PR keeps the protocol unchanged and words the hint to stay true in every `missing-auth` case.
  `claude auth login` is the command OpenClaw's own hints already use (`oauth-refresh-failure.ts`, `doctor-claude-cli.ts`, `extensions/anthropic/auth.runtime.ts`). `claude setup-token` makes an API token for the Anthropic provider; it does not log in the CLI runtime.
- Channel `/models` (`commands-models-menu.ts`): for Claude CLI rows reporting `missing-auth`, the recovery line now uses the same wording as the picker hint ("If Claude Code is signed out, run claude auth login on the Gateway host, or choose another model.") instead of `/login anthropic`. Other routes are unchanged.
- `docs/concepts/models.md`: documents that configured models stay listed as unavailable, and adds the Claude Code login line.

No new config keys and no protocol changes: the existing `missing-auth` value is reused.

## Evidence

Isolated Gateway on this Mac with state, config and `CLAUDE_CONFIG_DIR` under /tmp. The config is the one written by the real `openclaw onboard --non-interactive --auth-choice anthropic-cli`. The logged-out state is a fresh, empty `CLAUDE_CONFIG_DIR` (`claude auth status` → `loggedIn: false`). The logged-in run uses a wrapper that answers only `claude auth status` with `loggedIn: true`. No real Claude login was touched.

Screenshots retaken on the final head (36b263f) and on origin/main (b7dc0bc), each from its own isolated Gateway:

| | Logged out | Logged in |
|---|---|---|
| origin/main | ![main logged out: "No models available", only the default anthropic row](https://github.com/user-attachments/assets/f8b6d3d6-4f15-4587-9d73-2b0d1a61ccdf) | ![main logged in](https://github.com/user-attachments/assets/9d3af782-a7b0-4f44-9ca7-b2466b5b4f57) |
| this branch | ![branch logged out: Claude Code hint, every pinned model listed with Sign-in needed](https://github.com/user-attachments/assets/ef9cdb9e-adb5-40e3-a1b9-1486523c4d7a) | ![branch logged in: unchanged](https://github.com/user-attachments/assets/f612872e-c63d-4751-81bd-8a7515de99d9) |

Picker contents (search "Claude"):
- **origin/main, logged out:** "No models available"; one `anthropic/*` row (the default), no reason.
- **This branch, logged out:** "Claude Code isn't ready. If signed out, run claude auth login."; all 10 pinned `anthropic/*` rows listed with "Sign-in needed".
- **Logged in:** no empty-state label, and the same 23 picker rows in the same order on both heads.

### Telegram Test Server (`/models anthropic`)

Ran the repository's Telegram userbot runner on the Telegram Test Server with a Convex-leased bot and QA user (`run-mock-sut-user-e2e.mjs --dm --scenario`). The runner starts a fresh Gateway from each checkout's build. The config patch adds two configured `anthropic/*` models pinned to `claude-cli` and enables the anthropic plugin. `CLAUDE_CONFIG_DIR` points at an empty directory, so Claude Code is logged out. The QA user sends `/models anthropic` at 1 s and again at 40 s, after startup discovery. `/models` is a native command, so no model turn runs; the only mock-provider rows are two `/` readiness probes.

| | 1 s | 40 s |
|---|---|---|
| origin/main `b7dc0bc0fda3` | "anthropic: checking models…" | "Unknown provider: anthropic … Available providers: • openai". The configured Claude CLI models are gone. |
| this branch `45dce1142171` | "Models (anthropic) — 0 of 2 available … anthropic: Sign-in needed. If Claude Code is signed out, run claude auth login on the Gateway host, or choose another model." Buttons: `…needed — Claude CLI · claude-opus-4-7`, `…eded — Claude CLI · claude-sonnet-4-6`, `<< Back`. | Same reply and buttons. |

The `…` at the start of the button labels comes from Telegram's existing button-length truncation; this PR does not touch it.

`models.list {view: "configured"}`, logged out, no refresh:
- **origin/main:** 1 `anthropic/*` row (the default), `available: false`, no reason.
- **This branch:** all 10 pinned `anthropic/*` rows, `available: false`, `unavailableReason: "missing-auth"`.
- **Logged in:** the configured-view rows, runtimes and availability on this branch are identical to the origin/main capture of the same config.

The duplicate `claude-cli/*` rows in the screenshots are the existing twins; openclaw#166311 removes them.

## Tests

- `models-list-result.cli-runtime-availability.test.ts`, new case: an onboarding-shaped config, Claude logged out, catalog incomplete, configured view, run through the real `buildModelsListResult`. Every pinned row is listed with `missing-auth`, and the unpinned API row stays hidden. It fails on origin/main for both causes (rows missing, no reason).
- `models.test.ts`: the existing table row for "logged out, catalog incomplete" now expects `missing-auth`, because the runtime is configured. It fails on origin/main.
- `chat-model-catalog-state.test.ts`: the real `renderChatModelPicker`, given a `missing-auth` Claude CLI row, renders exactly the conditional Claude Code hint (the same row a signed-in user gets when the anthropic plugin is disabled, which `models-list-result.cli-runtime-availability.test.ts` already covers on the producer side). Other providers keep "No models available". It fails on origin/main (`expected 'No models available'`).
- `commands-models.catalog-recovery.test.ts` and `commands-models.test.ts` go through the real `/models` handler, which reads the same projection as the picker. A CLI-bound configured model is now listed in every auth state. It is marked "Sign-in needed" unless its prepared native login is present and its plugin is enabled. Its recovery line reads "If Claude Code is signed out, run claude auth login on the Gateway host, or choose another model." instead of `/login anthropic`, which can't fix a Claude Code login or a disabled plugin.
  A logged-out configured Claude CLI default now gets that recovery line instead of "Connection not confirmed". The openclaw#139848 rule still holds: with only an API key, the bound row shows "Sign-in needed" and is not available.
- Wall time with `pnpm test <file> --maxWorkers=1`: 35 s, 37 s and 3 s. The new gateway case takes 325 ms. No timers and no new fixtures.
- Also run: affected suites (`model-catalog*`, `model-auth-availability*`, `model-selection*`, `server-methods/models*`, `commands/models`, the chat picker UI and new-session), all passing. `node scripts/check-changed.mjs` exits 0 (tsgo core and UI, lint, import cycles, line-cap ratchet, i18n).

## Bounded cost

- No new processes, probes, network calls or catalog work. The existing startup `claude auth status` check and openclaw#166305's 60-second recheck are unchanged.
- The configured-runtime set is built at most once per auth resolver, which is one per `models.list` read. It is built only when a CLI-runtime row has no prepared login, and it is a pure walk over the config's model refs.
- Visibility adds one `Set.has` per catalog row. The UI adds one `.some()` over picker options per render.
- Picker size is bounded by configured refs: at most the number of models the user authored, and they were already listed while signed in.

## User impact

A logged-out Claude Code user sees every configured Claude model, greyed with "Sign-in needed", and a header that names the command to run. Once `claude auth login` succeeds, the rows turn available on the next read after openclaw#166305's recheck. Configured models for other providers that have lost their key now also stay listed as unavailable instead of disappearing. The channel `/models` command shows the same rows marked "Sign-in needed", and Claude CLI rows get the conditional `claude auth login` recovery line. The logged-in picker is unchanged.

## LOC vs origin/main

Production +182/-118. The moved evaluator accounts for +147/-112 and is unchanged apart from the configured-runtime check, so the behaviour change itself is about +35. Tests +82/-12. Docs +3/-1.

Co-authored-by: Ayaan Zaidi <[email protected]>
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 maintainer Maintainer-authored PR size: L

Projects

None yet

1 participant