Repository navigation
fix(models): list standalone models with the catalog owner's plugin registry - #166361
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 9:55 PM ET / October 7, 2026, 01:55 UTC (Revision 6). ClawSweeper reviewWhat this changesThe PR uses each prepared model catalog’s plugin registry to recognize Claude CLI model availability and runtime choices in standalone refreshed lists. Merge readiness✅ Ready for maintainer review This remains a useful fix absent from current main. The updated test-cost record satisfies the previous review request, and no blocking patch finding remains. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s model catalog combines configured models, plugin registrations, and prepared authentication facts. Its projections feed the CLI model list, Gateway model picker, and chat metadata. flowchart TD
A[Configured models] --> D[Prepared catalog owner]
B[Plugin registry] --> D
C[Authentication facts] --> D
D --> E[Prepare model availability]
E --> F[Published model projection]
F --> G[CLI list and Gateway picker]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +126, Tests +151. Total +277 across 6 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep registry-dependent facts with the prepared catalog owner while preserving inexpensive, current-generation published reads. Do we have a high-confidence way to reproduce the issue? Yes: source shows standalone owners can register Claude CLI while ambient lookups miss it, and the contributor reports matching real baseline failures. This review did not execute a reproduction. Is this the best way to solve the issue? Yes: using the existing owner's registry repairs the shared preparation boundary without adding another registry owner, configuration option, or per-read discovery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fdcbcf5c2ebd. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
|
@clawsweeper review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
The remaining test-cost blocker looks resolvable from data already extracted by the latest ClawSweeper review. The review records from run
Those are explicitly shared-shard CI measurements, not per-file timings. So the PR body can satisfy the current ask without inventing unavailable per-file CI data by adding something like:
That matches the current review wording: “labeling shared-shard totals separately from per-file timings and noting cancelled or unavailable measurements.” |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…6311) 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 #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 | |---|---| |  |  | Search "sonnet 5": | origin/main | this head | |---|---| |  |  | 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.
…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.
…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 | |---|---| |  |  | Search "sonnet 5": | origin/main | this head | |---|---| |  |  | 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.
Prerequisite for #166311.
What Problem This Solves
Fixes: without a running Gateway,
openclaw models list --refreshlists every configuredanthropic/*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 theirclaude-cli/*copies.User Impact
After
openclaw onboard --auth-choice anthropic-cli,openclaw models list --refreshwithout 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 listand the embedded TUI use a temporary owner, and Gateway owners belong to a workspace generation.prepareModelsListResultalready passesowner.pluginRegistryto some calls, but CLI backend bindings, Claude CLI auth evaluation and runtime choices still read the ambient registry (for examplelistCliRuntimeModelBackendBindings()inmodel-catalog-decisions.ts). The standalone command's active registry has no CLI backends. Soanthropic/*rows pinned toclaude-clifail auth, and the default view drops 9 of the 10.prepareModelsListResultnow resolves the owner first (resolveModelsListOwner), then runs preparation insidewithPluginRuntimeRegistryScope(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'spluginRegistryincreateModelCatalogDecisionsinstead of from the ambient registry on every read. The scoped preparation covers everyprepareModelsListResultcaller: 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) andchat-metadata-session-projection.tsprojecting its preloaded catalog before preparation still read the ambient registry; the tests here don't claim those paths. Owner resolution moved unchanged intomodels-list-result.owner.ts, becausemodels-list-result.tsis at the repository line cap.One existing runtime-choices case changed its fixture:
picker-fixture+ generic harnesspicker-native→picker-fixture+codex. The old case only came outunsupported-runtimebecause the registered fixture harness was invisible to ambient-registry lookups. A registered generic harness is compatible with any provider, whilecodexexplicitly 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 realopenclaw onboard --non-interactive --auth-choice anthropic-cli, and Claude Code logged in through a copied credentials file in an isolatedCLAUDE_CONFIG_DIR. Both checkouts were built withpnpm 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."):anthropic/*available: falseavailable: trueclaude-cli/*5 of 5 runs on each side matched its column. All three
claude auth statusprobes 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 configuredanthropic/*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"andview: "default", 3 calls each. Every call returned 10anthropic/*rows, allavailable: truewithagentRuntime.id: "claude-cli", plus 11claude-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 realopenclaw models listcommand, with a standalone owner whose registry alone has the Claude CLI backend. On origin/main it fails withanthropic/claude-opus-5available: false; here it passes.models-list-result.plugin-runtime.test.ts: a prepared owner reached throughprepareModelsListResult, as the Gateway andchat.metadatareach it, with an empty active registry. It fails on origin/main and also fails when onlybuildModelsListResultis scoped; here it passes.models-list-result.plugin-runtime.test.ts(runtime choice): a configuredanthropic/claude-opus-5withpickerRuntimes: ["openclaw", "claude-cli"], owner registry with the Claude CLI backend, empty active registry. Before the decisions fix theclaude-clichoice readsavailable: false; nowtrue.models-list-result.*,models*.test.ts(incl.models.prepared.test.ts),chat-metadata*,src/commands/models/list*,model-catalog-decisionsandmodels.test.tspassed on this change.tsgo:core:testandnode scripts/check-changed.mjspassed too.First run after a rebuild showing only
anthropic/claude-opus-5-5 falseDuring 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 noclaude-cli/*rows. That isn't this change, and it isn't a build artifact. It's the existing Claude login probe:claude auth status --jsonthree 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.claudeprocesses 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.run-nodecall in that session rebuilt because the tree was dirty, and the other rebuild runs were correct.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
read()(previously the bindings were listed on every runtime-choice read). No I/O, discovery or probing: with start-logging, every standalone list started threeclaude auth statusprobes on both origin/main and this branch.pnpm test <file> --maxWorkers=1wall time (Apple Silicon):src/commands/models/list.prepared-catalog.test.ts33.5 s (17 tests, vitest 28.3 s) andsrc/gateway/server-methods/models-list-result.runtime-choices.test.ts30.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.ts40.5 s (11 tests, vitest 32.8 s) on c979689. Transform dominates (75-80%); test bodies are 12-17%.list.prepared-catalog2.6 s (17 tests, shardagentic-commands-models),models-list-result.runtime-choices2.1 s (9 tests,agentic-gateway-methods-hosted-5),models-list-result.plugin-runtime2.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.