Skip to content

fix(models): keep logged-out Claude CLI models listed with a login reason - #166338

Merged
obviyus merged 4 commits into
mainfrom
fix/claude-cli-picker-login-reason
Oct 7, 2026
Merged

obviyus merged 4 commits into
mainfrom
fix/claude-cli-picker-login-reason

Conversation

@obviyus

@obviyus obviyus commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

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 fix(models): pair full catalog with native auth #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 fix(models): pair full catalog with native auth #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 feat(models): make per-agent model allowlist explicit; aliases/defaults no longer restrict #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. feat(models): curate default model picker to current-generation catalogs #113594 also promised that "nobody's pinned model disappears".

Earlier decisions are kept:

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 main logged in
this branch branch logged out: Claude Code hint, every pinned model listed with Sign-in needed branch logged in: unchanged

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 fix(models): restore missing picker choices after startup #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 fix(models): recheck Claude CLI login for model lists after Gateway startup #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.

@clawsweeper

clawsweeper Bot commented Oct 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.

@obviyus

obviyus commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 45dce114217141f91504a24c6f912edcdeee9708
  • Maintainer: @obviyus
  • Repository role: maintain

These security sensitive changes were made:

  • src/agents/model-auth-availability.cli-runtime.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/model-auth-availability.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: M labels Oct 6, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 6, 2026
@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 9:50 PM ET / October 7, 2026, 01:50 UTC (Revision 6).

ClawSweeper review

What this changes

The PR keeps configured models visible when authentication is missing and adds Claude Code login guidance to the chat picker and channel model menus.

Merge readiness

✅ Ready for maintainer review

This remains a useful, distinct fix that current main does not provide. The earlier test findings are resolved, the added Telegram evidence satisfies the previous proof request, and no blocking patch defect was found.

Priority: P2
Reviewed head: 45dce114217141f91504a24c6f912edcdeee9708

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with strong visual and Telegram evidence, meaningful regression coverage, and no blocking findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Inspected picker before-and-after screenshots show retained unavailable choices and the new hint; production UI files are unchanged since that capture. The exact-head Telegram Test Server transcript exercises the real Gateway /models path and shows retained logged-out choices plus the corrected guidance at startup and after discovery, satisfying the previous rank-up request. The logged-in screenshot control uses a declared auth-status fixture. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Inspected picker before-and-after screenshots show retained unavailable choices and the new hint; production UI files are unchanged since that capture. The exact-head Telegram Test Server transcript exercises the real Gateway /models path and shows retained logged-out choices plus the corrected guidance at startup and after discovery, satisfying the previous rank-up request. The logged-in screenshot control uses a declared auth-status fixture. No stored-data contract changes.
Evidence reviewed 10 items Verified introduced change: Reviewed the pinned merge-base-to-head delta. The checkout is the original PR head; base-only changes were excluded from attribution. The supplied test merge is stale and was not used to infer removal of main behavior.
Configured runtime authentication: The evaluator reuses the configured-provider collector used during startup preparation. Missing prepared login now receives missing-auth for configured runtimes, while later-discovered unconfigured runtimes retain unknown readiness until full preparation. Existing plugin-disablement, selected-account, and native-login checks remain intact.
Visibility remains separate from availability: Configured keys are retained in wildcard catalog membership without making their authentication available. Final policy filtering remains in place, and UI selection still rejects disabled model choices.
Findings None None.
Security None None.

How this fits together

The Gateway combines configured model choices with prepared runtime authentication facts to publish its model catalog. The Control UI and channel model menus consume that catalog to show available choices and recovery guidance.

flowchart LR
  A[Configured model choices] --> C[Gateway model catalog]
  B[Prepared CLI login facts] --> C
  C --> D[Visibility and readiness]
  D --> E[Control UI picker]
  D --> F[Channel model menu]
  E --> G[Unavailable rows and login guidance]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +64, Tests +70, Docs +2. Total +136 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 7 182 118 +64
Tests 5 82 12 +70
Docs 1 3 1 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 267 131 +136

Review metrics

Metric Value Why it matters
Production versus test growth production +182/-118 (net +64); tests +82/-12 (net +70) Most production additions relocate the existing CLI evaluator; remaining growth implements configured-row retention and recovery presentation.

Technical review

Best possible solution:

Keep configured choices visible with truthful readiness and route-specific recovery guidance while preserving native-login, selected-account, and model-policy restrictions.

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

Yes: onboarding-shaped Claude CLI pins with an empty Claude configuration reproduce the reported catalog conditions in source and contributor before-and-after evidence; this review did not execute the application.

Is this the best way to solve the issue?

Yes: the patch reuses startup preparation and configured-key ownership, preserves authorization checks, and changes recovery copy without adding a competing catalog or authentication policy.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. Inspected picker before-and-after screenshots show retained unavailable choices and the new hint; production UI files are unchanged since that capture. The exact-head Telegram Test Server transcript exercises the real Gateway /models path and shows retained logged-out choices plus the corrected guidance at startup and after discovery, satisfying the previous rank-up request. The logged-in screenshot control uses a declared auth-status fixture. No stored-data contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This repairs misleading logged-out model presentation and recovery guidance within a bounded catalog workflow.
  • 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): Inspected picker before-and-after screenshots show retained unavailable choices and the new hint; production UI files are unchanged since that capture. The exact-head Telegram Test Server transcript exercises the real Gateway /models path and shows retained logged-out choices plus the corrected guidance at startup and after discovery, satisfying the previous rank-up request. The logged-in screenshot control uses a declared auth-status fixture. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. Inspected picker before-and-after screenshots show retained unavailable choices and the new hint; production UI files are unchanged since that capture. The exact-head Telegram Test Server transcript exercises the real Gateway /models path and shows retained logged-out choices plus the corrected guidance at startup and after discovery, satisfying the previous rank-up request. The logged-in screenshot control uses a declared auth-status fixture. No stored-data contract changes.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The PR changes visible /models choices and recovery text; supplied exact-head Telegram Test Server evidence covers that behavior.

Evidence

What I checked:

  • Verified introduced change: Reviewed the pinned merge-base-to-head delta. The checkout is the original PR head; base-only changes were excluded from attribution. The supplied test merge is stale and was not used to infer removal of main behavior. (45dce1142171)
  • Configured runtime authentication: The evaluator reuses the configured-provider collector used during startup preparation. Missing prepared login now receives missing-auth for configured runtimes, while later-discovered unconfigured runtimes retain unknown readiness until full preparation. Existing plugin-disablement, selected-account, and native-login checks remain intact. (src/agents/model-auth-availability.cli-runtime.ts:131, 45dce1142171)
  • Visibility remains separate from availability: Configured keys are retained in wildcard catalog membership without making their authentication available. Final policy filtering remains in place, and UI selection still rejects disabled model choices. (src/agents/model-catalog-visibility.ts:246, 45dce1142171)
  • Still necessary on current main: Fetched main still filters ordinary catalog membership through authBacked and only emits the CLI missing-auth reason after preparedSyntheticAuthComplete. Neither central repair is already present. (src/agents/model-auth-availability.ts:120, 19cd32da3326)
  • Latest-release comparison: The v2026.9.8 source still builds defaultVisibleCatalog using authBacked alone at line 210. GitHub contents inspection succeeded after the local release blob could not be fetched. (src/agents/model-catalog-visibility.ts:210, fc23bc864e45)
  • Inspected visual before-and-after proof: Directly inspected all four current picker attachments: logged-out baseline, logged-out branch, logged-in baseline, and logged-in branch. They show the new conditional login hint and retained unavailable rows, with matching logged-in presentation. The UI and agent production files are unchanged between the screenshot revision and the reviewed head. (ui/src/pages/chat/components/chat-model-picker.ts:348, 45dce1142171)

Likely related people:

  • obviyus: 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)
  • fuller-stack-dev: 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 (5 earlier review cycles)
  • reviewed 2026-10-06T23:11:46.841Z sha ee8192802c33cfd5df41c379209b1a7c3d2d0a41 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-06T23:21:13.960Z sha cafa27bf10f626426a8b21536ca2681a4f92b322 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-06T23:55:29.231Z sha 36b263f :: needs changes before merge. :: [P2] Update channel visibility tests for retained configured rows | [P2] Update the configured CLI command's readiness expectation
  • reviewed 2026-10-07T00:16:02.617Z sha 74cda6e :: needs changes before merge. :: none
  • reviewed 2026-10-07T00:39:13.276Z sha 45dce11 :: needs changes before merge. :: none

@obviyus
obviyus force-pushed the fix/claude-cli-picker-login-reason branch from ee81928 to cafa27b Compare October 6, 2026 23:14
@obviyus

obviyus commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus
obviyus force-pushed the fix/claude-cli-picker-login-reason branch from cafa27b to 36b263f Compare October 6, 2026 23:39
@obviyus

obviyus commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. 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. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 6, 2026
@obviyus

obviyus commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Oct 7, 2026
@obviyus

obviyus commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 7, 2026
@obviyus
obviyus merged commit 8775756 into main Oct 7, 2026
146 of 148 checks passed
@obviyus
obviyus deleted the fix/claude-cli-picker-login-reason branch October 7, 2026 01:54
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]>
RomneyDa added a commit that referenced this pull request Oct 17, 2026
…75114)

The Claude CLI readiness probe (`claude auth status`) always stripped the
Claude clear list, including CLAUDE_CODE_OAUTH_TOKEN, while CLI execution
keeps keys named in OPENCLAW_LIVE_CLI_BACKEND_PRESERVE_ENV for native-login
runs. Since #166338 made a configured runtime without prepared native auth
authoritatively `missing-auth`, that mismatch makes sessions_spawn refuse
an anthropic/* child pinned to claude-cli ("The selected account or native
runtime is unavailable") even though the parent turn runs. The Docker live
CLI backend lane (env-token subscription auth) hit this on every 2026.10.5
candidate and main, and its announce barrier then timed out at 240s.

Probe the same child environment execution uses: preserved keys survive the
clear list. Unlisted credentials (for example ANTHROPIC_API_KEY) stay
cleared, and a genuinely logged-out CLI still reports missing.
RomneyDa added a commit that referenced this pull request Oct 17, 2026
…75114)

The Claude CLI readiness probe (`claude auth status`) always stripped the
Claude clear list, including CLAUDE_CODE_OAUTH_TOKEN, while CLI execution
keeps keys named in OPENCLAW_LIVE_CLI_BACKEND_PRESERVE_ENV for native-login
runs. Since #166338 made a configured runtime without prepared native auth
authoritatively `missing-auth`, that mismatch makes sessions_spawn refuse
an anthropic/* child pinned to claude-cli ("The selected account or native
runtime is unavailable") even though the parent turn runs. The Docker live
CLI backend lane (env-token subscription auth) hit this on every 2026.10.5
candidate and main, and its announce barrier then timed out at 240s.

Probe the same child environment execution uses: preserved keys survive the
clear list. Unlisted credentials (for example ANTHROPIC_API_KEY) stay
cleared, and a genuinely logged-out CLI still reports missing.

(cherry picked from commit a2e6a6b)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…enclaw#175114)

The Claude CLI readiness probe (`claude auth status`) always stripped the
Claude clear list, including CLAUDE_CODE_OAUTH_TOKEN, while CLI execution
keeps keys named in OPENCLAW_LIVE_CLI_BACKEND_PRESERVE_ENV for native-login
runs. Since openclaw#166338 made a configured runtime without prepared native auth
authoritatively `missing-auth`, that mismatch makes sessions_spawn refuse
an anthropic/* child pinned to claude-cli ("The selected account or native
runtime is unavailable") even though the parent turn runs. The Docker live
CLI backend lane (env-token subscription auth) hit this on every 2026.10.5
candidate and main, and its announce barrier then timed out at 240s.

Probe the same child environment execution uses: preserved keys survive the
clear list. Unlisted credentials (for example ANTHROPIC_API_KEY) stay
cleared, and a genuinely logged-out CLI still reports missing.
wheakerd pushed a commit to wheakerd/clawdbot that referenced this pull request Oct 22, 2026
…enclaw#175114)

The Claude CLI readiness probe (`claude auth status`) always stripped the
Claude clear list, including CLAUDE_CODE_OAUTH_TOKEN, while CLI execution
keeps keys named in OPENCLAW_LIVE_CLI_BACKEND_PRESERVE_ENV for native-login
runs. Since openclaw#166338 made a configured runtime without prepared native auth
authoritatively `missing-auth`, that mismatch makes sessions_spawn refuse
an anthropic/* child pinned to claude-cli ("The selected account or native
runtime is unavailable") even though the parent turn runs. The Docker live
CLI backend lane (env-token subscription auth) hit this on every 2026.10.5
candidate and main, and its announce barrier then timed out at 240s.

Probe the same child environment execution uses: preserved keys survive the
clear list. Unlisted credentials (for example ANTHROPIC_API_KEY) stay
cleared, and a genuinely logged-out CLI still reports missing.

(cherry picked from commit a2e6a6b)
(cherry picked from commit ad67421)
Co-authored-by: RomneyDa <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 27, 2026
…75114)

The Claude CLI readiness probe (`claude auth status`) always stripped the
Claude clear list, including CLAUDE_CODE_OAUTH_TOKEN, while CLI execution
keeps keys named in OPENCLAW_LIVE_CLI_BACKEND_PRESERVE_ENV for native-login
runs. Since #166338 made a configured runtime without prepared native auth
authoritatively `missing-auth`, that mismatch makes sessions_spawn refuse
an anthropic/* child pinned to claude-cli ("The selected account or native
runtime is unavailable") even though the parent turn runs. The Docker live
CLI backend lane (env-token subscription auth) hit this on every 2026.10.5
candidate and main, and its announce barrier then timed out at 240s.

Probe the same child environment execution uses: preserved keys survive the
clear list. Unlisted credentials (for example ANTHROPIC_API_KEY) stay
cleared, and a genuinely logged-out CLI still reports missing.

(cherry picked from commit a2e6a6b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed size: M 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.

1 participant