Skip to content

fix(models): list each Claude CLI model once in the model picker - #166311

Merged
obviyus merged 1 commit into
mainfrom
fix/claude-cli-picker-dedupe
Oct 7, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix/claude-cli-picker-dedupe

Conversation

@obviyus

@obviyus obviyus commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #153707, #82546, #166361

What Problem This Solves

Fixes: the Control UI model picker lists every Claude model twice, both labelled "Claude CLI · native", after openclaw onboard sets up Claude CLI. openclaw models list without a running Gateway shows the same duplicates.

User Impact

People who chose Claude CLI during onboarding now see each Claude model once: the configured anthropic/* row, which keeps its alias, its Default tag and the Claude CLI route label. API rows and Claude CLI rows stay separate, and claude-cli/* models you haven't configured (for example Haiku 4.5) still appear. Standalone openclaw models list --refresh lists the same rows as the picker.

Why This Change Was Made

Onboarding pins each anthropic/claude-* model to agentRuntime: claude-cli. That pin is deliberate: without it, gateway turns fell through to Anthropic API billing (#82546, #84374), and Doctor canonicalizes claude-cli/* refs to anthropic/* plus the pin. The bundled Claude CLI catalog still publishes claude-cli/<same model>, so models.list returned two rows for one model on one route.

The models.list read (shared by models.list, chat.metadata and openclaw models list) now drops a <cli-runtime>/<model> row when the canonical <modelProvider>/<model> row is published on that runtime and config pins it there (resolveModelRuntimePolicy).

Twin routes come from the catalog owner's registry

Which rows are twins is plugin policy: the CLI backend modelProvider bindings and the provider's catalog model id (resolveProviderModelCatalogId). Both are resolved from the same registry that decides availability:

  • createModelCatalogDecisions exposes the CLI backend bindings it already resolves from the owner's pluginRegistry as cliRuntimeBindings.
  • resolveCliRuntimeTwinRoute runs during preparation, inside prepareEntry, which runs in the owner's registry scope. It maps a claude-cli/* row to its canonical provider, resolves the catalog model id, and reads the config pin with the runtime id normalized (so a padded or mixed-case Claude-CLI pin still matches).
  • The read path stays a pure projection. omitCliRuntimeAliasTwins only compares the prepared twin routes with each row's own agentRuntime; it calls no plugin or registry code. This keeps the Gateway and the standalone CLI (whose ambient registry differs from the owner's, see fix(models): list standalone models with the catalog owner's plugin registry #166361) on the same answer.

Selection policies keep the alias

A claude-cli/* row stays when some selection policy allows it but not its anthropic/* twin. The policies checked are the agent's manual model policy and every gateway.roles.definitions[*].modelPolicy, prepared once with the owner's manifest metadata. So an operator role or agent policy that allows only claude-cli/* still sees those rows and can select them.

These are left alone too:

  • canonical rows on Claude CLI only because of a session runtime override. Choosing that row (or Default) resets to the configured route, so the CLI twin is still a different choice;
  • rows whose canonical twin runs on another runtime, such as the API route;
  • the all inventory view.

No selected-row exception is needed. Session display identity already maps CLI runtime refs to their canonical provider (resolveSessionDisplayModelIdentityRefCached, src/gateway/session-utils-model.ts), so a session on claude-cli/claude-opus-5 renders as anthropic/claude-opus-5 and the picker checks that row.

This keeps #153707's invariant (API and Claude CLI routes stay distinguishable) and removes the second copy of the same route. The CLI wizard picker already hides CLI runtime providers (createModelPickerVisibleProviderPredicate); only models.list was missing the canonical collapse.

Evidence

Isolated macOS run on this head (4d4b7cf) and on origin/main (2beca62), both built with pnpm build. State, config and HOME were under /tmp, the Gateway had its own port, and there was no Anthropic API key. Config came from the real openclaw onboard --non-interactive --auth-choice anthropic-cli, with Claude Code logged in through a copied credentials file in an isolated CLAUDE_CONFIG_DIR. Before and after use the same state.

Gateway models.list, Claude rows:

view origin/main this head
configured 10 anthropic/* on claude-cli + 11 claude-cli/* 10 anthropic/* on claude-cli + claude-cli/claude-haiku-4-5, claude-cli/claude-mythos-5
default 10 anthropic/* on claude-cli + 11 claude-cli/* 10 anthropic/* on claude-cli + claude-cli/claude-haiku-4-5, claude-cli/claude-mythos-5
all 10 anthropic/* + 12 claude-cli/* 10 anthropic/* + 12 claude-cli/* (unchanged)

Standalone openclaw models list --refresh --json (same state, OPENCLAW_GATEWAY_PORT unset, no Gateway running), Claude rows:

origin/main this head
anthropic/* 10 rows, all available: true on claude-cli 10 rows, all available: true on claude-cli
claude-cli/* 11 rows claude-haiku-4-5, claude-mythos-5
runs matching 5 of 5 3 of 3

Every claude auth status probe in these runs exited 0 (0.13–2.1 s).

Control UI model picker:

origin/main this head
search "opus 5.5" 2 rows (Default row plus a second "Claude CLI · native" copy) 1 row (the Default row)
search "sonnet 5" 4 rows for two models 2 rows
unfiltered groups Anthropic 10 / Claude CLI 11 Anthropic 10 / Claude CLI 2

Search "opus 5.5":

origin/main this head
origin/main: Claude Opus 5.5 listed twice on the Claude CLI route this head: Claude Opus 5.5 listed once

Search "sonnet 5":

origin/main this head
origin/main: Sonnet 5 and Sonnet 5.5 each listed twice this head: Sonnet 5 and Sonnet 5.5 listed once

Tests:

  • list.prepared-catalog.test.ts: the real openclaw models list command with a standalone owner whose registry alone has Claude CLI. It lists anthropic/claude-opus-5 and claude-cli/claude-haiku-4-5, without the claude-cli/claude-opus-5 twin.
  • models-list-result.plugin-runtime.test.ts: Gateway buildModelsListResult with an empty active registry and Claude CLI only in the owner's registry. Configured and default views drop the twin; a role allowing only claude-cli/* and an agent modelPolicy allowing only claude-cli/* keep it.
  • model-runtime-aliases.test.ts: twin-rule boundary table. Kept: a canonical row on Claude CLI only through a session override, an API-routed canonical row, and their CLI twins; a padded, mixed-case runtime pin (Claude-CLI) still collapses; a role allowing only Claude CLI rows keeps them.
  • Red/green: both owner-registry tests fail when the collapse reads the ambient registry at read time, and pass on this head. The role and agent-policy cases fail without the selection-policy rule and pass now.
  • On this head: tsgo:core and tsgo:test:src pass; 474 vitest tests pass across model-runtime-aliases, models-list-result.*, models.test, models.prepared, models-list.*, chat-metadata-*, model-discovery-policy and commands/models/list.*. node scripts/check-changed.mjs fails only the full-tree dead-export scan (7 unused exports in src/agents/auth-profiles.runtime.ts, untouched here), which fails the same way on origin/main 2beca62.

Known and unchanged:

  • anthropic/claude-opus-4-7, -4-6 and claude-sonnet-4-6 already showed raw ids on main, because the Anthropic API catalog has no entries for them without an API key.

Bounded cost

  • Twin routes are resolved once per catalog entry during preparation, which already runs per entry: a binding lookup, a config runtime-policy lookup and a catalog-id lookup. Role model policies are prepared once per prepared result, alongside the catalog; reads reuse them.
  • Each read makes two passes over the already-projected rows: one map build and one filter. Only claude-cli/* rows whose canonical twin is listed on the same runtime check the selection policies.
  • No new state, config or protocol change, and no new warnings or messages. The all view skips the work.

Test wall time on this head: locally with pnpm test <file> --maxWorkers=1 (transform is 72–92% of each), and the Vitest duration in CI run 37568557325 (shard wall time in parentheses):

file tests local CI
src/agents/model-runtime-aliases.test.ts 23 18.9 s 6.8 s (9.5 s)
src/commands/models/list.prepared-catalog.test.ts 18 21.0 s 15.2 s (17.1 s)
src/gateway/server-methods/models-list-result.plugin-runtime.test.ts 15 23.8 s 7.6 s (8.9 s)

LOC: production +118/-13, docs +5/-2, tests +184/-16.

@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:

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling extensions: anthropic size: S 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, 11:55 PM ET / October 7, 2026, 03:55 UTC (Revision 9).

ClawSweeper review

What this changes

The shared model catalog hides duplicate Claude CLI choices in the Control UI and CLI while preserving distinct routes and choices required by selection policies.

Merge readiness

✅ Ready for maintainer review

The PR remains necessary: current main still publishes duplicate Claude CLI choices. The previous review follow-up is resolved, and the inspected patch and proof support readiness with no additional review blocker.

Priority: P2
Reviewed head: 4d4b7cfabc2f6fb1637097496cf35e8c17f20093

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, policy-preserving repair with strong visible proof and consumer-boundary coverage.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The changed shared catalog projection is exercised by reported exact-head macOS Gateway and standalone CLI runs using real onboarding and native Claude login; inspected before/after picker screenshots directly show duplicate removal. Existing configuration is reused, and 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 (screenshot): The changed shared catalog projection is exercised by reported exact-head macOS Gateway and standalone CLI runs using real onboarding and native Claude login; inspected before/after picker screenshots directly show duplicate removal. Existing configuration is reused, and no stored-data contract changes.
Evidence reviewed 10 items Pinned introduced change: Reviewed the merge-base-to-head delta, rather than endpoint drift; unrelated base-branch changes are excluded.
Route and policy preservation: Collapse requires a published canonical row on the configured CLI runtime. Agent and Gateway-role policies retain an alias when its canonical counterpart is not selectable; session-only runtime overrides do not establish a configured twin.
Preparation owns plugin facts: Twin routes use the catalog owner's prepared CLI bindings during preparation. Reads compare prepared facts without introducing plugin discovery, persistent state, or a new public plugin API.
Findings None None.
Security None None.

How this fits together

The model catalog combines configured models, plugin metadata, and runtime availability. Its shared projection supplies model choices to Gateway clients, the Control UI, and the standalone CLI.

flowchart TD
  A[Configured models and policies] --> C[Prepared model catalog]
  B[Plugin routes and availability] --> C
  C --> D[Compare canonical and CLI routes]
  D --> E[Preserve policy-required choices]
  E --> F[Gateway and Control UI choices]
  E --> G[Standalone CLI listing]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +105, Tests +168, Docs +3. Total +276 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 118 13 +105
Tests 3 184 16 +168
Docs 1 5 2 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 307 31 +276

Review metrics

Metric Value Why it matters
Production versus test growth Production +118/-13; tests +184/-16 The body justifies production growth with owner-scoped preparation and pure policy-preserving projection.

Technical review

Best possible solution:

Keep one selectable row per configured model route through the existing shared projection, retaining aliases whenever they represent a distinct route or policy-required choice.

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

Yes: Claude CLI onboarding publishes canonical Anthropic rows pinned to Claude CLI alongside matching CLI catalog rows, and current main projects both. Contributor before/after captures corroborate this; the reviewer did not execute target code.

Is this the best way to solve the issue?

Yes: collapsing equivalent choices in the shared prepared projection addresses both consumers without changing execution routing, stored configuration, or authorization.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Duplicate model choices cause bounded picker and CLI confusion while existing model execution remains available.
  • 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 (screenshot): The changed shared catalog projection is exercised by reported exact-head macOS Gateway and standalone CLI runs using real onboarding and native Claude login; inspected before/after picker screenshots directly show duplicate removal. Existing configuration is reused, and no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed shared catalog projection is exercised by reported exact-head macOS Gateway and standalone CLI runs using real onboarding and native Claude login; inspected before/after picker screenshots directly show duplicate removal. Existing configuration is reused, and no stored-data contract changes.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The changed shared catalog projection is exercised by reported exact-head macOS Gateway and standalone CLI runs using real onboarding and native Claude login; inspected before/after picker screenshots directly show duplicate removal. Existing configuration is reused, and no stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: 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 (8 earlier review cycles)
  • reviewed 2026-10-06T21:41:29.792Z sha e4b69f5da0a1619536ce53dcdd702ef46a3585ca :: needs changes before merge. :: none
  • reviewed 2026-10-06T22:01:40.422Z sha a509bd4a0924dcd3d35896f34dccb9a1e599a630 :: blocked before merge. :: none
  • reviewed 2026-10-06T22:51:45.009Z sha f5e82de :: needs changes before merge. :: none
  • reviewed 2026-10-06T23:15:57.322Z sha 802a7d32d488033f175f9b98fc7e40aa95be8896 :: needs changes before merge. :: none
  • reviewed 2026-10-07T00:08:09.709Z sha 23a68d546c3673e3f743613de7be6836a89c484b :: needs maintainer review before merge. :: none
  • reviewed 2026-10-07T00:31:47.022Z sha b94bef7 :: blocked before merge. :: none
  • reviewed 2026-10-07T02:01:44.986Z sha b94bef7 :: needs changes before merge. :: none
  • reviewed 2026-10-07T03:27:05.619Z sha 4d4b7cf :: needs changes before merge. :: none

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Oct 6, 2026
obviyus added a commit that referenced this pull request Oct 6, 2026
…efs (#166319)

Related: #166311

## What Problem This Solves

The CLI backends page tells people Claude Code is a "text-only fallback… not a primary path", and its quick start uses a `claude-cli/claude-sonnet-5` ref. Neither matches what onboarding sets up today, and Doctor rewrites that ref anyway.

## User Impact

Someone who sets up Claude Code with OpenClaw now reads the setup that onboarding actually writes. That setup keeps `anthropic/*` model refs and runs them through Claude Code as the primary runtime, with Gateway tools available through the MCP bridge. The quick start, fallback, and Docker examples all use the canonical form that Doctor produces, so copying them no longer leaves config for Doctor to rewrite.

## Why This Change Was Made

- **Where the wording came from.** The "text-only fallback / safety net, not a primary path" framing dates back to the first CLI backend commit (d8f1124, January 2026), when a CLI backend had no tools. Later docs rewrites (852e8f7 and #100142) kept the framing, even after `bundleMcp` arrived. Today the bundled `claude-cli` backend sets `bundleMcp: true` (`extensions/anthropic/cli-backend.ts`). Choosing **Claude CLI** in onboarding (`buildAnthropicCliMigrationResult` in `extensions/anthropic/cli-migration.ts`) sets an `anthropic/*` default model and adds `agentRuntime: { id: "claude-cli" }` to the Claude model entries. So Claude Code is the primary runtime.
- **Canonical refs.** The quick start, the fallback example, and the Docker smoke command now use `anthropic/*` refs, relying on the runtime pin that the login writes. This matches `docs/providers/anthropic.md` and `docs/concepts/agent-runtimes.md`, which already document `anthropic/*` plus `agentRuntime.id` as the preferred form and `claude-cli/*` as legacy compatibility input.
- **How it works.** Step 1 now says the backend is chosen by the model's runtime policy. A standalone backend's provider prefix still works, matching `docs/plugins/cli-backend-plugins.md#selecting-the-backend`.
- **Not changed.** `docs/providers/anthropic.md` is untouched. Its route paragraph is owned by #166311, and the rest of the page already shows the canonical form.
- **ACP page.** `docs/tools/acp-agents.md` said CLI backends are "text-only local fallback runtimes" with "no OpenClaw tools". Its comparison row and operator rule now describe them as a model runtime for normal agent turns, with Gateway tools only through the MCP bridge.

## Evidence

- **Doctor (real path, origin/main 91236e8).** Doctor rewrites the old fallback example into the new one. I ran `openclaw doctor --fix --non-interactive` from source on an isolated `HOME`, `OPENCLAW_STATE_DIR` and `OPENCLAW_CONFIG_PATH` under `/tmp`, using the previous docs fallback config. It rewrote `fallbacks: ["claude-cli/claude-sonnet-5"]` and the `claude-cli/claude-sonnet-5` model key to `anthropic/claude-sonnet-5` with `agentRuntime: { id: "claude-cli" }`. That is exactly the new example.
- **Onboarding (real path, isolated state, Claude Code logged in).** `openclaw onboard --non-interactive --auth-choice anthropic-cli` wrote `model.primary: "anthropic/claude-opus-5-5"` and `agentRuntime: { id: "claude-cli" }` on all ten bundled Claude model entries, including `anthropic/claude-sonnet-5` and `anthropic/claude-sonnet-4-6`. No `claude-cli/*` keys were written. That is the shape the quick start and Docker text describe.
- **Docs checks.**
  - Passed: `pnpm format:docs:check`, `pnpm docs:check-mdx`, `pnpm docs:check-config-examples` (the new fallback block is validated against the schema), `pnpm docs:check-links:anchors` (0 broken links), `pnpm docs:check-i18n-glossary`, and `git diff --check`.
  - `pnpm docs:spellcheck` reports only 4 existing findings, all in untouched files (`web/control-ui/chat.md`, `cli/fleet.md`, `channels/x.md`).
- Docs only. There is no UI change, so no screenshots.

## Bounded cost

- **Runtime and config.** Nothing changes at runtime. The new examples are exactly the config Doctor and onboarding already produce, so readers who copy them get the same config, without a later Doctor rewrite.
- **Scope.** Docs only: 3 files, +20/−17. There is no code, config schema, protocol, or migration change.

Co-authored-by: Ayaan Zaidi <[email protected]>
@obviyus
obviyus force-pushed the fix/claude-cli-picker-dedupe branch from a509bd4 to f5e82de Compare October 6, 2026 22:31
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: M and removed size: S labels Oct 6, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Oct 6, 2026
@obviyus
obviyus force-pushed the fix/claude-cli-picker-dedupe branch from 802a7d3 to 23a68d5 Compare October 6, 2026 23:49
@obviyus
obviyus marked this pull request as ready for review October 7, 2026 00:03
@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 force-pushed the fix/claude-cli-picker-dedupe branch from 23a68d5 to b94bef7 Compare October 7, 2026 00:20
@obviyus
obviyus marked this pull request as draft October 7, 2026 00:24
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 7, 2026
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]>
@clawsweeper clawsweeper Bot added 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 added a commit that referenced this pull request Oct 7, 2026
…egistry (#166361)

Prerequisite for #166311.

## What Problem This Solves

Fixes: without a running Gateway, `openclaw models list --refresh` lists every configured `anthropic/*` model that runs through Claude CLI as unavailable, even when Claude Code is logged in. Only the default row is left (unavailable); the usable models show up only as their `claude-cli/*` copies.

## User Impact

After `openclaw onboard --auth-choice anthropic-cli`, `openclaw models list --refresh` without a Gateway now lists the configured Claude models as available on Claude CLI, the same as the Gateway picker. Gateway output doesn't change.

## Why This Change Was Made

A prepared model-catalog owner carries its own plugin registry, and that registry can differ from the process's active one. The standalone `openclaw models list` and the embedded TUI use a temporary owner, and Gateway owners belong to a workspace generation. `prepareModelsListResult` already passes `owner.pluginRegistry` to some calls, but CLI backend bindings, Claude CLI auth evaluation and runtime choices still read the ambient registry (for example `listCliRuntimeModelBackendBindings()` in `model-catalog-decisions.ts`). The standalone command's active registry has no CLI backends. So `anthropic/*` rows pinned to `claude-cli` fail auth, and the default view drops 9 of the 10.

`prepareModelsListResult` now resolves the owner first (`resolveModelsListOwner`), then runs preparation inside `withPluginRuntimeRegistryScope(owner.pluginRegistry, …)`, the helper the row projection already uses for worker placement. Reads stay pure projections of the prepared facts and never enter a plugin scope, keeping #162326's published-read invariant (`models.prepared.test.ts`); the existing per-row worker-placement scope is kept as is. The one read-time plugin fact, the CLI backend bindings behind picker runtime choices, is now resolved once from the decisions owner's `pluginRegistry` in `createModelCatalogDecisions` instead of from the ambient registry on every read. The scoped preparation covers every `prepareModelsListResult` caller: the Gateway handler, `chat.metadata`, the standalone CLI, the TUI and the preloaded projector. Not covered and unchanged: uncached runtime-choice auth evaluations (`model-auth-availability.ts`) and `chat-metadata-session-projection.ts` projecting its preloaded catalog before preparation still read the ambient registry; the tests here don't claim those paths. Owner resolution moved unchanged into `models-list-result.owner.ts`, because `models-list-result.ts` is at the repository line cap.

One existing runtime-choices case changed its fixture: `picker-fixture` + generic harness `picker-native` → `picker-fixture` + `codex`. The old case only came out `unsupported-runtime` because the registered fixture harness was invisible to ambient-registry lookups. A registered generic harness is compatible with any provider, while `codex` explicitly rejects non-OpenAI providers (`session-runtime-compat.ts`), so the case still asserts "registered harness, incompatible provider → `unsupported-runtime`".

#166311 (one picker row per Claude CLI model) depends on this. Its twin collapse has to read CLI backends from the same registry as availability.

## Evidence

Live proof on the exact head `c9796892845`, rerun after the design changed (pure reads; decisions resolve CLI backend bindings from the owner registry). Setup is unchanged: `HOME`, state and config under /tmp, no Anthropic API key, config from the real `openclaw onboard --non-interactive --auth-choice anthropic-cli`, and Claude Code logged in through a copied credentials file in an isolated `CLAUDE_CONFIG_DIR`. Both checkouts were built with `pnpm build`, and runs alternated main/head one after the other.

Standalone `openclaw models list --refresh --json`, no Gateway running (stderr: "Gateway is not running. Refreshing the local model catalog."):

| | origin/main (8775756) | this branch (c979689) |
|---|---|---|
| `anthropic/*` | 10 rows, all `available: false` | 10 rows, all `available: true` |
| `claude-cli/*` | 11 rows, all available | 11 rows, all available |

5 of 5 runs on each side matched its column. All three `claude auth status` probes finished in 0.15-0.44 s with exit 0 in every run, so no row depended on the probe timeout described below. (Current main now lists all 10 configured `anthropic/*` rows, where the earlier 2c620bb showed only the default row. All 10 are still unavailable.)

Isolated Gateway on c979689 (`openclaw gateway run`, same state), `gateway call models.list`: `view: "configured"` and `view: "default"`, 3 calls each. Every call returned 10 `anthropic/*` rows, all `available: true` with `agentRuntime.id: "claude-cli"`, plus 11 `claude-cli/*` rows. The Gateway and standalone paths agree.

Earlier rounds on 2c620bb vs this change (before the pure-read redesign) matched too: 14 runs on origin/main and 5 on the branch, plus 23 inside #166311.

Tests, both through the real consumer:
- `list.prepared-catalog.test.ts`: the real `openclaw models list` command, with a standalone owner whose registry alone has the Claude CLI backend. On origin/main it fails with `anthropic/claude-opus-5` `available: false`; here it passes.
- `models-list-result.plugin-runtime.test.ts`: a prepared owner reached through `prepareModelsListResult`, as the Gateway and `chat.metadata` reach it, with an empty active registry. It fails on origin/main and also fails when only `buildModelsListResult` is scoped; here it passes.
- `models-list-result.plugin-runtime.test.ts` (runtime choice): a configured `anthropic/claude-opus-5` with `pickerRuntimes: ["openclaw", "claude-cli"]`, owner registry with the Claude CLI backend, empty active registry. Before the decisions fix the `claude-cli` choice reads `available: false`; now `true`.
- `models-list-result.*`, `models*.test.ts` (incl. `models.prepared.test.ts`), `chat-metadata*`, `src/commands/models/list*`, `model-catalog-decisions` and `models.test.ts` passed on this change. `tsgo:core:test` and `node scripts/check-changed.mjs` passed too.

### First run after a rebuild showing only `anthropic/claude-opus-5-5 false`

During the work on #166311, one standalone run of the fixed code came back like origin/main's logged-out output: only `anthropic/claude-opus-5-5`, `available: false`, and no `claude-cli/*` rows. That isn't this change, and it isn't a build artifact. It's the existing Claude login probe:
- A standalone list runs `claude auth status --json` three times (`extensions/anthropic/cli-auth-seam.ts`, 3 s timeout). If the second probe times out, it counts as unreadable, so every Claude row is unavailable.
- Delaying exactly that probe to 3.5 s gives the identical output on origin/main, on this branch and on #166311. Delaying the first or third probe changes nothing.
- Observed probe times ranged from 0.14 s to 3.0 s; the slow ones came when several `claude` processes shared one config dir. Once in 23 runs, during a concurrent test run, the slow case happened on its own: that run took 4 s longer and logged only two completed probes.
- "Right after a rebuild" was a coincidence. Every `run-node` call in that session rebuilt because the tree was dirty, and the other rebuild runs were correct.
- On a Gateway, #166305's background recheck corrects a timed-out probe within a minute.

Known and unchanged: the read-only `openclaw models list` (no `--refresh`, no Gateway) reads a cached owner that has no plugin registry. It still shows the single unavailable default row.

## Bounded cost

- One AsyncLocalStorage frame around preparation and one CLI backend listing per decisions owner; none per `read()` (previously the bindings were listed on every runtime-choice read). No I/O, discovery or probing: with start-logging, every standalone list started three `claude auth status` probes on both origin/main and this branch.
- No new state, config, protocol or messages.
- Local test cost, `pnpm test <file> --maxWorkers=1` wall time (Apple Silicon): `src/commands/models/list.prepared-catalog.test.ts` 33.5 s (17 tests, vitest 28.3 s) and `src/gateway/server-methods/models-list-result.runtime-choices.test.ts` 30.2 s (9 tests, vitest 26.9 s), both measured on 355ced4 and unchanged since; `src/gateway/server-methods/models-list-result.plugin-runtime.test.ts` 40.5 s (11 tests, vitest 32.8 s) on c979689. Transform dominates (75-80%); test bodies are 12-17%.
- CI test cost, run [37555824195](https://github.com/openclaw/openclaw/actions/runs/37555824195) on c979689, summed per-test times per file: `list.prepared-catalog` 2.6 s (17 tests, shard `agentic-commands-models`), `models-list-result.runtime-choices` 2.1 s (9 tests, `agentic-gateway-methods-hosted-5`), `models-list-result.plugin-runtime` 2.9 s (11 tests, `agentic-gateway-methods-hosted-6`). Shared-shard totals, not per-file: those vitest batches took 16.9 s (8 files), 78.0 s (7 files) and 58.6 s (9 files). Several other shards in that run were cancelled by fail-fast after an unrelated red (see CI below), so no whole-run total is available.

LOC vs origin/main: +408/-131 total; 199 production lines are owner resolution moved verbatim into `models-list-result.owner.ts`; tests +153/-2.



## CI

On c979689, the only red test is `src/gateway/server.chat.gateway-server-chat-b.test.ts` > "chat.history advances past a replay boundary that cannot fit all projected siblings" (line 5681); the other failed jobs were cancelled by fail-fast. It fails 3/3 on clean origin/main 6c352f4 and passes 3/3 on this branch locally, so it's unrelated. The earlier 4eaa9da red, `src/flows/doctor-health.plugin-load.test.ts` (3 ENOSPC cases), also fails on clean origin/main 6c352f4.
@obviyus
obviyus force-pushed the fix/claude-cli-picker-dedupe branch from b94bef7 to 4d4b7cf Compare October 7, 2026 03:21
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Oct 7, 2026
@obviyus
obviyus marked this pull request as ready for review October 7, 2026 03:49
@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 merged commit 5be0e77 into main Oct 7, 2026
253 of 279 checks passed
@obviyus
obviyus deleted the fix/claude-cli-picker-dedupe branch October 7, 2026 04:16
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
…efs (openclaw#166319)

Related: openclaw#166311

## What Problem This Solves

The CLI backends page tells people Claude Code is a "text-only fallback… not a primary path", and its quick start uses a `claude-cli/claude-sonnet-5` ref. Neither matches what onboarding sets up today, and Doctor rewrites that ref anyway.

## User Impact

Someone who sets up Claude Code with OpenClaw now reads the setup that onboarding actually writes. That setup keeps `anthropic/*` model refs and runs them through Claude Code as the primary runtime, with Gateway tools available through the MCP bridge. The quick start, fallback, and Docker examples all use the canonical form that Doctor produces, so copying them no longer leaves config for Doctor to rewrite.

## Why This Change Was Made

- **Where the wording came from.** The "text-only fallback / safety net, not a primary path" framing dates back to the first CLI backend commit (711d884, January 2026), when a CLI backend had no tools. Later docs rewrites (46236a1 and openclaw#100142) kept the framing, even after `bundleMcp` arrived. Today the bundled `claude-cli` backend sets `bundleMcp: true` (`extensions/anthropic/cli-backend.ts`). Choosing **Claude CLI** in onboarding (`buildAnthropicCliMigrationResult` in `extensions/anthropic/cli-migration.ts`) sets an `anthropic/*` default model and adds `agentRuntime: { id: "claude-cli" }` to the Claude model entries. So Claude Code is the primary runtime.
- **Canonical refs.** The quick start, the fallback example, and the Docker smoke command now use `anthropic/*` refs, relying on the runtime pin that the login writes. This matches `docs/providers/anthropic.md` and `docs/concepts/agent-runtimes.md`, which already document `anthropic/*` plus `agentRuntime.id` as the preferred form and `claude-cli/*` as legacy compatibility input.
- **How it works.** Step 1 now says the backend is chosen by the model's runtime policy. A standalone backend's provider prefix still works, matching `docs/plugins/cli-backend-plugins.md#selecting-the-backend`.
- **Not changed.** `docs/providers/anthropic.md` is untouched. Its route paragraph is owned by openclaw#166311, and the rest of the page already shows the canonical form.
- **ACP page.** `docs/tools/acp-agents.md` said CLI backends are "text-only local fallback runtimes" with "no OpenClaw tools". Its comparison row and operator rule now describe them as a model runtime for normal agent turns, with Gateway tools only through the MCP bridge.

## Evidence

- **Doctor (real path, origin/main e832181).** Doctor rewrites the old fallback example into the new one. I ran `openclaw doctor --fix --non-interactive` from source on an isolated `HOME`, `OPENCLAW_STATE_DIR` and `OPENCLAW_CONFIG_PATH` under `/tmp`, using the previous docs fallback config. It rewrote `fallbacks: ["claude-cli/claude-sonnet-5"]` and the `claude-cli/claude-sonnet-5` model key to `anthropic/claude-sonnet-5` with `agentRuntime: { id: "claude-cli" }`. That is exactly the new example.
- **Onboarding (real path, isolated state, Claude Code logged in).** `openclaw onboard --non-interactive --auth-choice anthropic-cli` wrote `model.primary: "anthropic/claude-opus-5-5"` and `agentRuntime: { id: "claude-cli" }` on all ten bundled Claude model entries, including `anthropic/claude-sonnet-5` and `anthropic/claude-sonnet-4-6`. No `claude-cli/*` keys were written. That is the shape the quick start and Docker text describe.
- **Docs checks.**
  - Passed: `pnpm format:docs:check`, `pnpm docs:check-mdx`, `pnpm docs:check-config-examples` (the new fallback block is validated against the schema), `pnpm docs:check-links:anchors` (0 broken links), `pnpm docs:check-i18n-glossary`, and `git diff --check`.
  - `pnpm docs:spellcheck` reports only 4 existing findings, all in untouched files (`web/control-ui/chat.md`, `cli/fleet.md`, `channels/x.md`).
- Docs only. There is no UI change, so no screenshots.

## Bounded cost

- **Runtime and config.** Nothing changes at runtime. The new examples are exactly the config Doctor and onboarding already produce, so readers who copy them get the same config, without a later Doctor rewrite.
- **Scope.** Docs only: 3 files, +20/−17. There is no code, config schema, protocol, or migration change.

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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
…egistry (openclaw#166361)

Prerequisite for openclaw#166311.

## What Problem This Solves

Fixes: without a running Gateway, `openclaw models list --refresh` lists every configured `anthropic/*` model that runs through Claude CLI as unavailable, even when Claude Code is logged in. Only the default row is left (unavailable); the usable models show up only as their `claude-cli/*` copies.

## User Impact

After `openclaw onboard --auth-choice anthropic-cli`, `openclaw models list --refresh` without a Gateway now lists the configured Claude models as available on Claude CLI, the same as the Gateway picker. Gateway output doesn't change.

## Why This Change Was Made

A prepared model-catalog owner carries its own plugin registry, and that registry can differ from the process's active one. The standalone `openclaw models list` and the embedded TUI use a temporary owner, and Gateway owners belong to a workspace generation. `prepareModelsListResult` already passes `owner.pluginRegistry` to some calls, but CLI backend bindings, Claude CLI auth evaluation and runtime choices still read the ambient registry (for example `listCliRuntimeModelBackendBindings()` in `model-catalog-decisions.ts`). The standalone command's active registry has no CLI backends. So `anthropic/*` rows pinned to `claude-cli` fail auth, and the default view drops 9 of the 10.

`prepareModelsListResult` now resolves the owner first (`resolveModelsListOwner`), then runs preparation inside `withPluginRuntimeRegistryScope(owner.pluginRegistry, …)`, the helper the row projection already uses for worker placement. Reads stay pure projections of the prepared facts and never enter a plugin scope, keeping openclaw#162326's published-read invariant (`models.prepared.test.ts`); the existing per-row worker-placement scope is kept as is. The one read-time plugin fact, the CLI backend bindings behind picker runtime choices, is now resolved once from the decisions owner's `pluginRegistry` in `createModelCatalogDecisions` instead of from the ambient registry on every read. The scoped preparation covers every `prepareModelsListResult` caller: the Gateway handler, `chat.metadata`, the standalone CLI, the TUI and the preloaded projector. Not covered and unchanged: uncached runtime-choice auth evaluations (`model-auth-availability.ts`) and `chat-metadata-session-projection.ts` projecting its preloaded catalog before preparation still read the ambient registry; the tests here don't claim those paths. Owner resolution moved unchanged into `models-list-result.owner.ts`, because `models-list-result.ts` is at the repository line cap.

One existing runtime-choices case changed its fixture: `picker-fixture` + generic harness `picker-native` → `picker-fixture` + `codex`. The old case only came out `unsupported-runtime` because the registered fixture harness was invisible to ambient-registry lookups. A registered generic harness is compatible with any provider, while `codex` explicitly rejects non-OpenAI providers (`session-runtime-compat.ts`), so the case still asserts "registered harness, incompatible provider → `unsupported-runtime`".

openclaw#166311 (one picker row per Claude CLI model) depends on this. Its twin collapse has to read CLI backends from the same registry as availability.

## Evidence

Live proof on the exact head `c9796892845`, rerun after the design changed (pure reads; decisions resolve CLI backend bindings from the owner registry). Setup is unchanged: `HOME`, state and config under /tmp, no Anthropic API key, config from the real `openclaw onboard --non-interactive --auth-choice anthropic-cli`, and Claude Code logged in through a copied credentials file in an isolated `CLAUDE_CONFIG_DIR`. Both checkouts were built with `pnpm build`, and runs alternated main/head one after the other.

Standalone `openclaw models list --refresh --json`, no Gateway running (stderr: "Gateway is not running. Refreshing the local model catalog."):

| | origin/main (7fa4352) | this branch (c979689) |
|---|---|---|
| `anthropic/*` | 10 rows, all `available: false` | 10 rows, all `available: true` |
| `claude-cli/*` | 11 rows, all available | 11 rows, all available |

5 of 5 runs on each side matched its column. All three `claude auth status` probes finished in 0.15-0.44 s with exit 0 in every run, so no row depended on the probe timeout described below. (Current main now lists all 10 configured `anthropic/*` rows, where the earlier b7dc0bc showed only the default row. All 10 are still unavailable.)

Isolated Gateway on c979689 (`openclaw gateway run`, same state), `gateway call models.list`: `view: "configured"` and `view: "default"`, 3 calls each. Every call returned 10 `anthropic/*` rows, all `available: true` with `agentRuntime.id: "claude-cli"`, plus 11 `claude-cli/*` rows. The Gateway and standalone paths agree.

Earlier rounds on b7dc0bc vs this change (before the pure-read redesign) matched too: 14 runs on origin/main and 5 on the branch, plus 23 inside openclaw#166311.

Tests, both through the real consumer:
- `list.prepared-catalog.test.ts`: the real `openclaw models list` command, with a standalone owner whose registry alone has the Claude CLI backend. On origin/main it fails with `anthropic/claude-opus-5` `available: false`; here it passes.
- `models-list-result.plugin-runtime.test.ts`: a prepared owner reached through `prepareModelsListResult`, as the Gateway and `chat.metadata` reach it, with an empty active registry. It fails on origin/main and also fails when only `buildModelsListResult` is scoped; here it passes.
- `models-list-result.plugin-runtime.test.ts` (runtime choice): a configured `anthropic/claude-opus-5` with `pickerRuntimes: ["openclaw", "claude-cli"]`, owner registry with the Claude CLI backend, empty active registry. Before the decisions fix the `claude-cli` choice reads `available: false`; now `true`.
- `models-list-result.*`, `models*.test.ts` (incl. `models.prepared.test.ts`), `chat-metadata*`, `src/commands/models/list*`, `model-catalog-decisions` and `models.test.ts` passed on this change. `tsgo:core:test` and `node scripts/check-changed.mjs` passed too.

### First run after a rebuild showing only `anthropic/claude-opus-5-5 false`

During the work on openclaw#166311, one standalone run of the fixed code came back like origin/main's logged-out output: only `anthropic/claude-opus-5-5`, `available: false`, and no `claude-cli/*` rows. That isn't this change, and it isn't a build artifact. It's the existing Claude login probe:
- A standalone list runs `claude auth status --json` three times (`extensions/anthropic/cli-auth-seam.ts`, 3 s timeout). If the second probe times out, it counts as unreadable, so every Claude row is unavailable.
- Delaying exactly that probe to 3.5 s gives the identical output on origin/main, on this branch and on openclaw#166311. Delaying the first or third probe changes nothing.
- Observed probe times ranged from 0.14 s to 3.0 s; the slow ones came when several `claude` processes shared one config dir. Once in 23 runs, during a concurrent test run, the slow case happened on its own: that run took 4 s longer and logged only two completed probes.
- "Right after a rebuild" was a coincidence. Every `run-node` call in that session rebuilt because the tree was dirty, and the other rebuild runs were correct.
- On a Gateway, openclaw#166305's background recheck corrects a timed-out probe within a minute.

Known and unchanged: the read-only `openclaw models list` (no `--refresh`, no Gateway) reads a cached owner that has no plugin registry. It still shows the single unavailable default row.

## Bounded cost

- One AsyncLocalStorage frame around preparation and one CLI backend listing per decisions owner; none per `read()` (previously the bindings were listed on every runtime-choice read). No I/O, discovery or probing: with start-logging, every standalone list started three `claude auth status` probes on both origin/main and this branch.
- No new state, config, protocol or messages.
- Local test cost, `pnpm test <file> --maxWorkers=1` wall time (Apple Silicon): `src/commands/models/list.prepared-catalog.test.ts` 33.5 s (17 tests, vitest 28.3 s) and `src/gateway/server-methods/models-list-result.runtime-choices.test.ts` 30.2 s (9 tests, vitest 26.9 s), both measured on 355ced4 and unchanged since; `src/gateway/server-methods/models-list-result.plugin-runtime.test.ts` 40.5 s (11 tests, vitest 32.8 s) on c979689. Transform dominates (75-80%); test bodies are 12-17%.
- CI test cost, run [37555824195](https://github.com/openclaw/openclaw/actions/runs/37555824195) on c979689, summed per-test times per file: `list.prepared-catalog` 2.6 s (17 tests, shard `agentic-commands-models`), `models-list-result.runtime-choices` 2.1 s (9 tests, `agentic-gateway-methods-hosted-5`), `models-list-result.plugin-runtime` 2.9 s (11 tests, `agentic-gateway-methods-hosted-6`). Shared-shard totals, not per-file: those vitest batches took 16.9 s (8 files), 78.0 s (7 files) and 58.6 s (9 files). Several other shards in that run were cancelled by fail-fast after an unrelated red (see CI below), so no whole-run total is available.

LOC vs origin/main: +408/-131 total; 199 production lines are owner resolution moved verbatim into `models-list-result.owner.ts`; tests +153/-2.



## CI

On c979689, the only red test is `src/gateway/server.chat.gateway-server-chat-b.test.ts` > "chat.history advances past a replay boundary that cannot fit all projected siblings" (line 5681); the other failed jobs were cancelled by fail-fast. It fails 3/3 on clean origin/main 877a911 and passes 3/3 on this branch locally, so it's unrelated. The earlier 4eaa9da red, `src/flows/doctor-health.plugin-load.test.ts` (3 ENOSPC cases), also fails on clean origin/main 877a911.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
…nclaw#166311)

Related: openclaw#153707, openclaw#82546, openclaw#166361

## What Problem This Solves

Fixes: the Control UI model picker lists every Claude model twice, both labelled "Claude CLI · native", after `openclaw onboard` sets up Claude CLI. `openclaw models list` without a running Gateway shows the same duplicates.

## User Impact

People who chose Claude CLI during onboarding now see each Claude model once: the configured `anthropic/*` row, which keeps its alias, its Default tag and the Claude CLI route label. API rows and Claude CLI rows stay separate, and `claude-cli/*` models you haven't configured (for example Haiku 4.5) still appear. Standalone `openclaw models list --refresh` lists the same rows as the picker.

## Why This Change Was Made

Onboarding pins each `anthropic/claude-*` model to `agentRuntime: claude-cli`. That pin is deliberate: without it, gateway turns fell through to Anthropic API billing (openclaw#82546, openclaw#84374), and Doctor canonicalizes `claude-cli/*` refs to `anthropic/*` plus the pin. The bundled Claude CLI catalog still publishes `claude-cli/<same model>`, so `models.list` returned two rows for one model on one route.

The `models.list` read (shared by `models.list`, `chat.metadata` and `openclaw models list`) now drops a `<cli-runtime>/<model>` row when the canonical `<modelProvider>/<model>` row is published on that runtime **and** config pins it there (`resolveModelRuntimePolicy`).

### Twin routes come from the catalog owner's registry

Which rows are twins is plugin policy: the CLI backend `modelProvider` bindings and the provider's catalog model id (`resolveProviderModelCatalogId`). Both are resolved from the same registry that decides availability:

- `createModelCatalogDecisions` exposes the CLI backend bindings it already resolves from the owner's `pluginRegistry` as `cliRuntimeBindings`.
- `resolveCliRuntimeTwinRoute` runs during preparation, inside `prepareEntry`, which runs in the owner's registry scope. It maps a `claude-cli/*` row to its canonical provider, resolves the catalog model id, and reads the config pin with the runtime id normalized (so a padded or mixed-case ` Claude-CLI ` pin still matches).
- The read path stays a pure projection. `omitCliRuntimeAliasTwins` only compares the prepared twin routes with each row's own `agentRuntime`; it calls no plugin or registry code. This keeps the Gateway and the standalone CLI (whose ambient registry differs from the owner's, see openclaw#166361) on the same answer.

### Selection policies keep the alias

A `claude-cli/*` row stays when some selection policy allows it but not its `anthropic/*` twin. The policies checked are the agent's manual model policy and every `gateway.roles.definitions[*].modelPolicy`, prepared once with the owner's manifest metadata. So an operator role or agent policy that allows only `claude-cli/*` still sees those rows and can select them.

These are left alone too:
- canonical rows on Claude CLI only because of a session runtime override. Choosing that row (or Default) resets to the configured route, so the CLI twin is still a different choice;
- rows whose canonical twin runs on another runtime, such as the API route;
- the `all` inventory view.

No selected-row exception is needed. Session display identity already maps CLI runtime refs to their canonical provider (`resolveSessionDisplayModelIdentityRefCached`, `src/gateway/session-utils-model.ts`), so a session on `claude-cli/claude-opus-5` renders as `anthropic/claude-opus-5` and the picker checks that row.

This keeps openclaw#153707's invariant (API and Claude CLI routes stay distinguishable) and removes the second copy of the same route. The CLI wizard picker already hides CLI runtime providers (`createModelPickerVisibleProviderPredicate`); only `models.list` was missing the canonical collapse.

## Evidence

Isolated macOS run on this head (4d4b7cf) and on origin/main (5cc5969), both built with `pnpm build`. State, config and `HOME` were under /tmp, the Gateway had its own port, and there was no Anthropic API key. Config came from the real `openclaw onboard --non-interactive --auth-choice anthropic-cli`, with Claude Code logged in through a copied credentials file in an isolated `CLAUDE_CONFIG_DIR`. Before and after use the same state.

Gateway `models.list`, Claude rows:

| view | origin/main | this head |
|---|---|---|
| `configured` | 10 `anthropic/*` on `claude-cli` + 11 `claude-cli/*` | 10 `anthropic/*` on `claude-cli` + `claude-cli/claude-haiku-4-5`, `claude-cli/claude-mythos-5` |
| `default` | 10 `anthropic/*` on `claude-cli` + 11 `claude-cli/*` | 10 `anthropic/*` on `claude-cli` + `claude-cli/claude-haiku-4-5`, `claude-cli/claude-mythos-5` |
| `all` | 10 `anthropic/*` + 12 `claude-cli/*` | 10 `anthropic/*` + 12 `claude-cli/*` (unchanged) |

Standalone `openclaw models list --refresh --json` (same state, `OPENCLAW_GATEWAY_PORT` unset, no Gateway running), Claude rows:

| | origin/main | this head |
|---|---|---|
| `anthropic/*` | 10 rows, all `available: true` on `claude-cli` | 10 rows, all `available: true` on `claude-cli` |
| `claude-cli/*` | 11 rows | `claude-haiku-4-5`, `claude-mythos-5` |
| runs matching | 5 of 5 | 3 of 3 |

Every `claude auth status` probe in these runs exited 0 (0.13–2.1 s).

Control UI model picker:

| | origin/main | this head |
|---|---|---|
| search "opus 5.5" | 2 rows (Default row plus a second "Claude CLI · native" copy) | 1 row (the Default row) |
| search "sonnet 5" | 4 rows for two models | 2 rows |
| unfiltered groups | Anthropic 10 / Claude CLI 11 | Anthropic 10 / Claude CLI 2 |

Search "opus 5.5":

| origin/main | this head |
|---|---|
| ![origin/main: Claude Opus 5.5 listed twice on the Claude CLI route](https://github.com/user-attachments/assets/3c6f10fd-8c3e-48f2-9247-f2fd409d59aa) | ![this head: Claude Opus 5.5 listed once](https://github.com/user-attachments/assets/8b7cf849-b292-42cd-81e0-803cd8d16c80) |

Search "sonnet 5":

| origin/main | this head |
|---|---|
| ![origin/main: Sonnet 5 and Sonnet 5.5 each listed twice](https://github.com/user-attachments/assets/339dc319-8c80-45fc-a0e7-3241506e122d) | ![this head: Sonnet 5 and Sonnet 5.5 listed once](https://github.com/user-attachments/assets/1b0001ca-61fd-43d7-8a2f-602d2e8c7aca) |

Tests:
- `list.prepared-catalog.test.ts`: the real `openclaw models list` command with a standalone owner whose registry alone has Claude CLI. It lists `anthropic/claude-opus-5` and `claude-cli/claude-haiku-4-5`, without the `claude-cli/claude-opus-5` twin.
- `models-list-result.plugin-runtime.test.ts`: Gateway `buildModelsListResult` with an empty active registry and Claude CLI only in the owner's registry. Configured and default views drop the twin; a role allowing only `claude-cli/*` and an agent `modelPolicy` allowing only `claude-cli/*` keep it.
- `model-runtime-aliases.test.ts`: twin-rule boundary table. Kept: a canonical row on Claude CLI only through a session override, an API-routed canonical row, and their CLI twins; a padded, mixed-case runtime pin (` Claude-CLI `) still collapses; a role allowing only Claude CLI rows keeps them.
- Red/green: both owner-registry tests fail when the collapse reads the ambient registry at read time, and pass on this head. The role and agent-policy cases fail without the selection-policy rule and pass now.
- On this head: `tsgo:core` and `tsgo:test:src` pass; 474 vitest tests pass across `model-runtime-aliases`, `models-list-result.*`, `models.test`, `models.prepared`, `models-list.*`, `chat-metadata-*`, `model-discovery-policy` and `commands/models/list.*`. `node scripts/check-changed.mjs` fails only the full-tree dead-export scan (7 unused exports in `src/agents/auth-profiles.runtime.ts`, untouched here), which fails the same way on origin/main 5cc5969.

Known and unchanged:
- `anthropic/claude-opus-4-7`, `-4-6` and `claude-sonnet-4-6` already showed raw ids on main, because the Anthropic API catalog has no entries for them without an API key.

## Bounded cost

- Twin routes are resolved once per catalog entry during preparation, which already runs per entry: a binding lookup, a config runtime-policy lookup and a catalog-id lookup. Role model policies are prepared once per prepared result, alongside the catalog; reads reuse them.
- Each read makes two passes over the already-projected rows: one map build and one filter. Only `claude-cli/*` rows whose canonical twin is listed on the same runtime check the selection policies.
- No new state, config or protocol change, and no new warnings or messages. The `all` view skips the work.

Test wall time on this head: locally with `pnpm test <file> --maxWorkers=1` (transform is 72–92% of each), and the Vitest duration in CI run 37568557325 (shard wall time in parentheses):

| file | tests | local | CI |
|---|---|---|---|
| `src/agents/model-runtime-aliases.test.ts` | 23 | 18.9 s | 6.8 s (9.5 s) |
| `src/commands/models/list.prepared-catalog.test.ts` | 18 | 21.0 s | 15.2 s (17.1 s) |
| `src/gateway/server-methods/models-list-result.plugin-runtime.test.ts` | 15 | 23.8 s | 7.6 s (8.9 s) |

LOC: production +118/-13, docs +5/-2, tests +184/-16.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation extensions: anthropic gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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