Repository navigation
refactor(models): compose prepared catalog sources before lookup - #143837
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: blocked before merge. Reviewed September 10, 2026, 11:43 AM ET / 15:43 UTC (Revision 9). ClawSweeper reviewWhat this changesThe PR combines model inventory sources before lookup, applies current provider request settings, restricts replace-mode inventory, and separates catalog normalization from credential handling. Merge readiness⛔ Blocked before merge - 2 items remain This PR remains useful: current main includes the SDK prerequisite but lacks the complete prepared-catalog composition. No blocking introduced defect was found, and the documented authority transition should not be reopened as an unresolved prior finding. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw's prepared model runtime turns provider declarations, generated catalogs, and authored model files into inventory shared by agent runs and model lists. The model registry also resolves request credentials and headers for the selected model. flowchart TD
A[Static and generated catalogs] --> D[Compose model registry]
B[Authored model file] --> D
C[Current provider configuration] --> D
D --> E[Apply merge or replace rules]
E --> F[Startup and full model lists]
E --> G[Request-local model selection]
C --> H[Current request credentials]
H --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +123, Tests +456, Docs +8. Total +587 across 20 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one registry composition owner, preserve the documented raw SDK exception, and retain the accepted upgrade behavior and credential-removal recovery coverage. Do we have a high-confidence way to reproduce the issue? Yes, source inspection establishes a focused path: current main builds the registry without composing static and current configured rows, and the supplied tests exercise the affected startup, full-catalog, and replace-mode boundaries. This review did not execute a reproduction. Is this the best way to solve the issue? Yes. Extending the existing registry and shared materializer keeps source precedence in one owner, and moving catalog normalization avoids importing credential handling into that boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 25a6148d1a9a. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
bdfa347 to
90e97e0
Compare
|
Thanks @obviyus! Proof: 462 tests passed across 33 catalog, prepared-runtime, registry, provider-normalization, and PDF caller files. Retained Gateway catalog operations and published-SDK HTTP observations cover source composition, replace membership, current-key removal, and recovery at their recorded build identities. Exact-head review passed with zero findings, and CI is green.
Merged as |
) ## What Problem This Solves Fixes an issue where Gateway startup fails after plugin auto-enable when a bundled provider has credentials or settings but no custom `models` array. This addresses an operator report of a regression introduced by #143837. The reported provider-level `enabled` keys are not accepted by the current schema. The valid credentials-only form reproduces the crash when startup automatically enables a configured channel. ## Why This Change Was Made The catalog composition owner now maps custom rows only when they exist. Existing merge logic keeps inherited catalog rows and routes, and the provider loop still applies current request credentials and headers. No schema or configuration keys change. ## User Impact Operators can start the Gateway with provider settings that omit custom models, including when a channel is automatically enabled. Bundled models remain available to catalog browsing. ## Evidence - Pinned main `a48c47a09c86`: real isolated Gateway startup exits 1 with `TypeError: Cannot read properties of undefined (reading 'map')` at `ModelRegistry.loadModels`, introduced in #143837. - Both new regression tests fail on the original code at that same call. The composition test verifies inherited rows, routes, token limits, and current credentials/headers. The Gateway test waits for full startup and then requests public readiness. - Fixed code passes 61 focused tests across catalog composition, the model-catalog sibling, the Gateway catalog-startup suite, and the neighboring WebSocket contract. - Real CLI proof: Gateway reaches readiness; explicit catalog refresh exposes 10 bundled OpenAI models; the following list without refresh retains those rows. Credential status reports the synthetic sources. Fake keys leave models unavailable and provider discovery incomplete; no successful upstream authentication is claimed. - The exact reported `enabled` shape remains rejected before startup on both revisions. The channel token is synthetic, and channel connections are disabled; this is startup proof, not message-delivery proof. - Changed-file formatter, lint, line-count and assertion checks pass. Typechecks and full suites run in GitHub CI. Co-authored-by: Ayaan Zaidi <[email protected]>
…nclaw#143837) Compose prepared static, generated, authored-file, and current configured model sources in the registry before defaults and lookup. Preserve route precedence, current request authority, the raw authored-file SDK exception, and replace-mode membership. Separate pure catalog normalization from credential resolution to remove the registry import cycle without weakening architecture checks. Validated with focused owner and sibling tests, before/after import-cycle proof, retained Gateway/SDK observations, and exact-head review and CI. Co-authored-by: Ayaan Zaidi <[email protected]>
… (openclaw#144599) ## What Problem This Solves Fixes an issue where Gateway startup fails after plugin auto-enable when a bundled provider has credentials or settings but no custom `models` array. This addresses an operator report of a regression introduced by openclaw#143837. The reported provider-level `enabled` keys are not accepted by the current schema. The valid credentials-only form reproduces the crash when startup automatically enables a configured channel. ## Why This Change Was Made The catalog composition owner now maps custom rows only when they exist. Existing merge logic keeps inherited catalog rows and routes, and the provider loop still applies current request credentials and headers. No schema or configuration keys change. ## User Impact Operators can start the Gateway with provider settings that omit custom models, including when a channel is automatically enabled. Bundled models remain available to catalog browsing. ## Evidence - Pinned main `7a28adad1faf`: real isolated Gateway startup exits 1 with `TypeError: Cannot read properties of undefined (reading 'map')` at `ModelRegistry.loadModels`, introduced in openclaw#143837. - Both new regression tests fail on the original code at that same call. The composition test verifies inherited rows, routes, token limits, and current credentials/headers. The Gateway test waits for full startup and then requests public readiness. - Fixed code passes 61 focused tests across catalog composition, the model-catalog sibling, the Gateway catalog-startup suite, and the neighboring WebSocket contract. - Real CLI proof: Gateway reaches readiness; explicit catalog refresh exposes 10 bundled OpenAI models; the following list without refresh retains those rows. Credential status reports the synthetic sources. Fake keys leave models unavailable and provider discovery incomplete; no successful upstream authentication is claimed. - The exact reported `enabled` shape remains rejected before startup on both revisions. The channel token is synthetic, and channel connections are disabled; this is startup proof, not message-delivery proof. - Changed-file formatter, lint, line-count and assertion checks pass. Typechecks and full suites run in GitHub CI. Co-authored-by: Ayaan Zaidi <[email protected]>
) ## What Problem This Solves Some providers list their models live from the account: Together, Tencent TokenHub/TokenPlan, and other OpenAI-compatible live catalogs. When a listed model is missing from the plugin's built-in rows, OpenClaw ignores the hosted catalog's details for it and uses discovery defaults: 128k context, a 32k output cap and text-only input. For example, Together `moonshotai/Kimi-K3` has a 1M context window and accepts images according to the hosted catalog. Before this change, the picker showed it as 128k text-only and requests were capped at 32,768 output tokens. ## User Impact Live-listed models now get the hosted catalog's context window, output limit, input modalities, reasoning/compat data and price. This reaches the picker, `models list`, run-time model resolution, compaction limits and request `max_tokens`. The account listing still decides which models exist. A catalog row the account does not list stays hidden, and a listed ID with no catalog row keeps its discovered values. Stored catalog rows are unchanged. ## Why This Change Was Made The planner already merges bundled and hosted rows correctly (`planEffectiveModelCatalogRows`). The prepared catalog then drops planned rows for runtime/refreshable providers on purpose (#143837): a manifest row must not publish a model the account does not list. The live projection is left to fill in the details for a listed ID, but it only searches the plugin's own static rows. This change does not add a second merge. `ModelRegistry`, when it reads a generated (live-listed) provider catalog, describes each listed ID with that planner's effective row. The catalog value wins field by field, and a discovered value fills only what the catalog omits. The row keeps its ID, its route and a declared non-chat kind. <details><summary>Single-owner trace: every consumer reads the registry rows</summary> - **Picker / `models list`:** `buildModelsListResult` reads the published snapshot from `prepareFullCatalogFacts` (`src/agents/prepared-model-runtime.full-catalog.ts`). It passes `templateModelRegistry.getAll()` (`ModelRegistry`) as `models` into `buildPreparedModelCatalogSnapshot`, whose `dynamicManifestKeys` filter (`src/agents/model-catalog.ts`) still drops the planned rows, so registry rows are the only source for these providers. - **Run-time resolution:** `resolveModelAsync` → `resolveExplicitModelWithRegistry` (`model.registry-resolution.ts`) reads `preparedCatalogModel ?? modelRegistry.find(...)`. `preparedCatalogModel` comes from `completeConfiguredRuntimeModels`, which resolves through the same registry. - **Context window / compaction:** `src/agents/context.ts` projects `owner.modelCatalog.entries`, the registry-derived snapshot above, and the resolved model's `contextWindow`. - **Request max tokens:** taken from the resolved runtime model (above). The captured request moves from 32768 to about 1M for Kimi-K3. - **Usage cost:** `withResolvedPricing` → `resolveModelCostConfig` and the Gateway usage paths (`captureModelCostPricing`) price through `prepareModelPricingContext`. That pricing owner already reads the same planner plus hosted prices, so turn cost was already correct for these rows on main (measured below). The registry row now carries the same price, so the two agree. No change was made to the pricing owner. - **Persistence:** `models-config.plan.ts` keeps the plain admission filter (`filterGeneratedPluginModelCatalogProviders`), so stored generated rows stay as discovered and the description is applied at read time only. </details> ## Evidence Regression test `model-registry.catalog-description.test.ts`: it fails on base `f52f728d3415` (the listed row keeps `name`/`maxTokens`/`input` discovery defaults) and passes on the branch. Real E2E, base main `f52f728d3415` vs this branch, both dist builds. Each side ran an isolated Gateway with dummy keys and a candidate hosted catalog republished from the branch with `scripts/publish-model-catalog.mts`, served on loopback. Provider traffic for the real Together and Tencent host names went to a self-signed TLS mock through a test-only preload; the configured base URLs stayed the real ones. | row | base: list | base: request / cost | branch: list | branch: request / cost | |---|---|---|---|---| | together `moonshotai/Kimi-K3` (hosted-only) | **128000, text** | **max_tokens 32768** / $0.000105 | 1048576, text+image | max_tokens 1020067 / $0.000105 | | together `zai-org/GLM-5.2` (control) | 262144, text | 131072 / $0.000036 | same | same | | tencent-tokenhub `hy4` | 1024000/960000, text+image | 64000, effort high / $0.0000208 | same | same | | tencent-tokenhub `hy4-flash` | 1048576/983040, text+image | 65536, effort high / $0.0000021 | same | same | | tencent-tokenhub `hy4-preview` (control) | 1024000, text | 64000, effort high / $0.0000208 | same | same | Tencent `hy4`/`hy4-flash` are already correct on main because the bundled Tencent manifest now carries their rows, so they serve as controls here. On 2026.11.4 the same hosted rows showed 128k text-only; that is the case this change fixes for any provider whose plugin lacks the row. Gates: consumer tests (model registry, `model-catalog`, prepared runtime catalog projection/publication/configured catalog, `models list` prepared catalog, manifest planner, pricing), `src/agents/agent-tools.prefix-stability.test.ts`, `pnpm tsgo:core`, oxlint and format on the changed files all pass. Production delta against the merge base: +68/−3 lines in `src/agents` (one read-time function plus a call-site swap). Test: +109. **Merge danger:** low. The change is read-time only, with no schema, protocol or stored-row change. If a hosted row is wrong for a listed model, its values now apply to that model, where before they were silently ignored. **Blast radius:** generated (live-listed) provider catalogs read through `ModelRegistry`. These are providers with `modelCatalog.discovery: runtime | refreshable` whose plugin manifest or the hosted catalog has a row for a listed ID. Static providers and authored `models.json` rows are untouched. Co-authored-by: Ayaan Zaidi <[email protected]>
…claw#200403) ## What Problem This Solves Some providers list their models live from the account: Together, Tencent TokenHub/TokenPlan, and other OpenAI-compatible live catalogs. When a listed model is missing from the plugin's built-in rows, OpenClaw ignores the hosted catalog's details for it and uses discovery defaults: 128k context, a 32k output cap and text-only input. For example, Together `moonshotai/Kimi-K3` has a 1M context window and accepts images according to the hosted catalog. Before this change, the picker showed it as 128k text-only and requests were capped at 32,768 output tokens. ## User Impact Live-listed models now get the hosted catalog's context window, output limit, input modalities, reasoning/compat data and price. This reaches the picker, `models list`, run-time model resolution, compaction limits and request `max_tokens`. The account listing still decides which models exist. A catalog row the account does not list stays hidden, and a listed ID with no catalog row keeps its discovered values. Stored catalog rows are unchanged. ## Why This Change Was Made The planner already merges bundled and hosted rows correctly (`planEffectiveModelCatalogRows`). The prepared catalog then drops planned rows for runtime/refreshable providers on purpose (openclaw#143837): a manifest row must not publish a model the account does not list. The live projection is left to fill in the details for a listed ID, but it only searches the plugin's own static rows. This change does not add a second merge. `ModelRegistry`, when it reads a generated (live-listed) provider catalog, describes each listed ID with that planner's effective row. The catalog value wins field by field, and a discovered value fills only what the catalog omits. The row keeps its ID, its route and a declared non-chat kind. <details><summary>Single-owner trace: every consumer reads the registry rows</summary> - **Picker / `models list`:** `buildModelsListResult` reads the published snapshot from `prepareFullCatalogFacts` (`src/agents/prepared-model-runtime.full-catalog.ts`). It passes `templateModelRegistry.getAll()` (`ModelRegistry`) as `models` into `buildPreparedModelCatalogSnapshot`, whose `dynamicManifestKeys` filter (`src/agents/model-catalog.ts`) still drops the planned rows, so registry rows are the only source for these providers. - **Run-time resolution:** `resolveModelAsync` → `resolveExplicitModelWithRegistry` (`model.registry-resolution.ts`) reads `preparedCatalogModel ?? modelRegistry.find(...)`. `preparedCatalogModel` comes from `completeConfiguredRuntimeModels`, which resolves through the same registry. - **Context window / compaction:** `src/agents/context.ts` projects `owner.modelCatalog.entries`, the registry-derived snapshot above, and the resolved model's `contextWindow`. - **Request max tokens:** taken from the resolved runtime model (above). The captured request moves from 32768 to about 1M for Kimi-K3. - **Usage cost:** `withResolvedPricing` → `resolveModelCostConfig` and the Gateway usage paths (`captureModelCostPricing`) price through `prepareModelPricingContext`. That pricing owner already reads the same planner plus hosted prices, so turn cost was already correct for these rows on main (measured below). The registry row now carries the same price, so the two agree. No change was made to the pricing owner. - **Persistence:** `models-config.plan.ts` keeps the plain admission filter (`filterGeneratedPluginModelCatalogProviders`), so stored generated rows stay as discovered and the description is applied at read time only. </details> ## Evidence Regression test `model-registry.catalog-description.test.ts`: it fails on base `e28416097d78` (the listed row keeps `name`/`maxTokens`/`input` discovery defaults) and passes on the branch. Real E2E, base main `e28416097d78` vs this branch, both dist builds. Each side ran an isolated Gateway with dummy keys and a candidate hosted catalog republished from the branch with `scripts/publish-model-catalog.mts`, served on loopback. Provider traffic for the real Together and Tencent host names went to a self-signed TLS mock through a test-only preload; the configured base URLs stayed the real ones. | row | base: list | base: request / cost | branch: list | branch: request / cost | |---|---|---|---|---| | together `moonshotai/Kimi-K3` (hosted-only) | **128000, text** | **max_tokens 32768** / $0.000105 | 1048576, text+image | max_tokens 1020067 / $0.000105 | | together `zai-org/GLM-5.2` (control) | 262144, text | 131072 / $0.000036 | same | same | | tencent-tokenhub `hy4` | 1024000/960000, text+image | 64000, effort high / $0.0000208 | same | same | | tencent-tokenhub `hy4-flash` | 1048576/983040, text+image | 65536, effort high / $0.0000021 | same | same | | tencent-tokenhub `hy4-preview` (control) | 1024000, text | 64000, effort high / $0.0000208 | same | same | Tencent `hy4`/`hy4-flash` are already correct on main because the bundled Tencent manifest now carries their rows, so they serve as controls here. On 2026.11.4 the same hosted rows showed 128k text-only; that is the case this change fixes for any provider whose plugin lacks the row. Gates: consumer tests (model registry, `model-catalog`, prepared runtime catalog projection/publication/configured catalog, `models list` prepared catalog, manifest planner, pricing), `src/agents/agent-tools.prefix-stability.test.ts`, `pnpm tsgo:core`, oxlint and format on the changed files all pass. Production delta against the merge base: +68/−3 lines in `src/agents` (one read-time function plus a call-site swap). Test: +109. **Merge danger:** low. The change is read-time only, with no schema, protocol or stored-row change. If a hosted row is wrong for a listed model, its values now apply to that model, where before they were silently ignored. **Blast radius:** generated (live-listed) provider catalogs read through `ModelRegistry`. These are providers with `modelCatalog.discovery: runtime | refreshable` whose plugin manifest or the hosted catalog has a row for a listed ID. Static providers and authored `models.json` rows are untouched. Co-authored-by: Ayaan Zaidi <[email protected]>
) ## What Problem This Solves Some providers list their models live from the account: Together, Tencent TokenHub/TokenPlan, and other OpenAI-compatible live catalogs. When a listed model is missing from the plugin's built-in rows, OpenClaw ignores the hosted catalog's details for it and uses discovery defaults: 128k context, a 32k output cap and text-only input. For example, Together `moonshotai/Kimi-K3` has a 1M context window and accepts images according to the hosted catalog. Before this change, the picker showed it as 128k text-only and requests were capped at 32,768 output tokens. ## User Impact Live-listed models now get the hosted catalog's context window, output limit, input modalities, reasoning/compat data and price. This reaches the picker, `models list`, run-time model resolution, compaction limits and request `max_tokens`. The account listing still decides which models exist. A catalog row the account does not list stays hidden, and a listed ID with no catalog row keeps its discovered values. Stored catalog rows are unchanged. ## Why This Change Was Made The planner already merges bundled and hosted rows correctly (`planEffectiveModelCatalogRows`). The prepared catalog then drops planned rows for runtime/refreshable providers on purpose (#143837): a manifest row must not publish a model the account does not list. The live projection is left to fill in the details for a listed ID, but it only searches the plugin's own static rows. This change does not add a second merge. `ModelRegistry`, when it reads a generated (live-listed) provider catalog, describes each listed ID with that planner's effective row. The catalog value wins field by field, and a discovered value fills only what the catalog omits. The row keeps its ID, its route and a declared non-chat kind. <details><summary>Single-owner trace: every consumer reads the registry rows</summary> - **Picker / `models list`:** `buildModelsListResult` reads the published snapshot from `prepareFullCatalogFacts` (`src/agents/prepared-model-runtime.full-catalog.ts`). It passes `templateModelRegistry.getAll()` (`ModelRegistry`) as `models` into `buildPreparedModelCatalogSnapshot`, whose `dynamicManifestKeys` filter (`src/agents/model-catalog.ts`) still drops the planned rows, so registry rows are the only source for these providers. - **Run-time resolution:** `resolveModelAsync` → `resolveExplicitModelWithRegistry` (`model.registry-resolution.ts`) reads `preparedCatalogModel ?? modelRegistry.find(...)`. `preparedCatalogModel` comes from `completeConfiguredRuntimeModels`, which resolves through the same registry. - **Context window / compaction:** `src/agents/context.ts` projects `owner.modelCatalog.entries`, the registry-derived snapshot above, and the resolved model's `contextWindow`. - **Request max tokens:** taken from the resolved runtime model (above). The captured request moves from 32768 to about 1M for Kimi-K3. - **Usage cost:** `withResolvedPricing` → `resolveModelCostConfig` and the Gateway usage paths (`captureModelCostPricing`) price through `prepareModelPricingContext`. That pricing owner already reads the same planner plus hosted prices, so turn cost was already correct for these rows on main (measured below). The registry row now carries the same price, so the two agree. No change was made to the pricing owner. - **Persistence:** `models-config.plan.ts` keeps the plain admission filter (`filterGeneratedPluginModelCatalogProviders`), so stored generated rows stay as discovered and the description is applied at read time only. </details> ## Evidence Regression test `model-registry.catalog-description.test.ts`: it fails on base `f52f728d3415` (the listed row keeps `name`/`maxTokens`/`input` discovery defaults) and passes on the branch. Real E2E, base main `f52f728d3415` vs this branch, both dist builds. Each side ran an isolated Gateway with dummy keys and a candidate hosted catalog republished from the branch with `scripts/publish-model-catalog.mts`, served on loopback. Provider traffic for the real Together and Tencent host names went to a self-signed TLS mock through a test-only preload; the configured base URLs stayed the real ones. | row | base: list | base: request / cost | branch: list | branch: request / cost | |---|---|---|---|---| | together `moonshotai/Kimi-K3` (hosted-only) | **128000, text** | **max_tokens 32768** / $0.000105 | 1048576, text+image | max_tokens 1020067 / $0.000105 | | together `zai-org/GLM-5.2` (control) | 262144, text | 131072 / $0.000036 | same | same | | tencent-tokenhub `hy4` | 1024000/960000, text+image | 64000, effort high / $0.0000208 | same | same | | tencent-tokenhub `hy4-flash` | 1048576/983040, text+image | 65536, effort high / $0.0000021 | same | same | | tencent-tokenhub `hy4-preview` (control) | 1024000, text | 64000, effort high / $0.0000208 | same | same | Tencent `hy4`/`hy4-flash` are already correct on main because the bundled Tencent manifest now carries their rows, so they serve as controls here. On 2026.11.4 the same hosted rows showed 128k text-only; that is the case this change fixes for any provider whose plugin lacks the row. Gates: consumer tests (model registry, `model-catalog`, prepared runtime catalog projection/publication/configured catalog, `models list` prepared catalog, manifest planner, pricing), `src/agents/agent-tools.prefix-stability.test.ts`, `pnpm tsgo:core`, oxlint and format on the changed files all pass. Production delta against the merge base: +68/−3 lines in `src/agents` (one read-time function plus a call-site swap). Test: +109. **Merge danger:** low. The change is read-time only, with no schema, protocol or stored-row change. If a hosted row is wrong for a listed model, its values now apply to that model, where before they were silently ignored. **Blast radius:** generated (live-listed) provider catalogs read through `ModelRegistry`. These are providers with `modelCatalog.discovery: runtime | refreshable` whose plugin manifest or the hosted catalog has a row for a listed ID. Static providers and authored `models.json` rows are untouched. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit cacbd46) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 35ae84abfb92e7b89de680273338474f190bf3f6)
…ng on the Gateway's first read (#202618) ## Problem A model that the provider's account listing omits could appear in `models.list` on the Gateway's first read after start. Follow-up to #202490. The approved rule: the provider's listing is the only source of which models exist. The hosted catalog and the manifest only describe models. ## Interleaving 1. The Gateway starts and publishes a quick `static` catalog (`publishConfiguredModelRuntimeSnapshots`, `src/gateway/server-startup-model-runtime.ts:59`). 2. That build seeds the registry for every signed-in provider with `loadManifestModelProviderConfigs` (`src/agents/prepared-model-runtime.facts.ts:556`, added in #167460). The manifest plan contains the hosted catalog rows, so the refreshable Together provider got `zz-lab/zz-day0-live` even though the saved listing (already loaded, `pluginCatalogs=1`) omits it. 3. `prepareCapturedRuntimeFacts` publishes the registry rows as list entries (`src/agents/prepared-model-runtime.configured-catalog.ts:124`). 4. `models.list` serves the published snapshot (`src/gateway/server-methods/models.ts:148`). The live full catalog, built from the account listing, publishes 5–24 s after `ready` and drops the row. The leak depends on timing. It happens only when the first read arrives before step 4's live publication. A scratch build with logging showed this in 10 of 10 runs: all 5 runs where the first read came before the publication leaked, and none of the 5 where it came after. The suspect `includeProviderPluginAugmentation === false` branch in `model-catalog.ts` never ran during these reads. ## Fix The fix is in `loadManifestModelProviderConfigs`, the single source of manifest rows that claim a model exists. It no longer returns rows for providers that declare `runtime` or `refreshable` discovery. Those providers list only their saved or live account listing. While the first listing is pending they list nothing (`pendingProviders`), and they also list nothing after a failed first listing. Static providers and providers without a discovery declaration keep their manifest rows at once, as before. Description consumers (limits, price, thinking, typed-ref resolution) are unchanged: typed refs to an unlisted model still resolve, run and are priced. Kept: the `includeProviderPluginAugmentation === false` branch in `buildPreparedModelCatalogSnapshot` (#143837) still passes dynamic manifest rows in no-augmentation builds. The first head removed it, and CI then showed that utility preparation uses those typed rows to refuse a Decisions model a credential has no grant for (`utility-completion.clawrouter.test.ts`). The scratch build showed that branch never runs on the Gateway or CLI list reads measured here. Moving that entitlement data onto a description-only path is a follow-up. **Contract change (approved):** this reverses part of #167460. Right after sign-in, a refreshable or runtime provider shows as pending instead of showing its known manifest models, until its listing arrives. A failed first listing leaves it empty with `refreshFailed`. Docs updated (`docs/plugins/manifest/models.md`). No schema, protocol or config change. ## Evidence Harness: isolated dist Gateways (`env -i`, scratch state), loopback HTTPS vendor mock, hosted catalog served on loopback with synthetic day-zero rows (`generatedAt` after each build's `builtAt`). Case `tom`: Together is signed in, the hosted catalog has `together/zz-lab/zz-day0-live`, and the account listing omits it. Each run does fresh setup, then 3 CLI reads (no Gateway; plain, `--refresh`, plain), starts the Gateway, does 4 Gateway reads (first, second, `--refresh`, after refresh), and sends one typed turn to the omitted ref. | 20 runs of `tom` | main `569c60bc2a5c` | this branch (exact head `d8f05863`) | |---|---|---| | CLI, every read | hidden 20/20 | hidden 20/20 | | Gateway first `models.list` | **shown 4/20** | hidden 20/20 | | Gateway later reads | shown 1/20 (run 12: second read and `--refresh`) | hidden 20/20 | | Typed turn runs | 20/20 | 20/20 | | Typed turn priced ($6.0e-5 = catalog price) | 20/20 | 20/20 | Main's leaks were runs 12–15. The branch column is a fresh set of 20 runs on the exact head, after the bypass was restored. An earlier set of 20 on the first head (without the bypass) gave the same result. Other cases, one run each on branch and main, with identical results: static `abl` (hosted row listed everywhere, turn $3.0e-5), Together listing includes the ID `tog` (listed, 524288, $6.0e-5), ChatGPT `oai` (listed, 400000, $9.0e-5). Regression test `src/gateway/server-methods/models-list.first-read.integration.test.ts`: a real Gateway with a signed-in refreshable fixture provider whose `/models` response is held (an explicit gate). The first read and a read during the held listing must not list the manifest-only row, and the provider must be pending. After release, only the listed row appears. On main it fails with `expected [ 'manifest-only' ] to deeply equal []`. On this branch it passes. Gates: 53 consumer test files (`src/agents/model-catalog*`, `src/agents/prepared-model-runtime*`, `src/gateway/server-methods/models-auth-login*`, the new test) plus `src/agents/utility-completion.clawrouter.test.ts` green; full CI green on the exact head; local ClawSweeper review clean; `pnpm tsgo:core`, `pnpm check:test-types`, oxlint and oxfmt clean. `models-auth-login.catalog.integration.test.ts` now asserts the new contract: no rows while held and none after a failed first listing. The #167460 assertions are removed. ## Size Production: +13 / −7 across 3 files (net +6). The new code is the 6-line existence filter in `loadManifestModelProviderConfigs`; the other changed lines are rewritten comments. No production code is deleted. Tests: +97 / −5 (new regression test, plus #167460 assertions flipped). Docs: 2 lines. ## Merge danger and blast radius - Affects every `runtime` or `refreshable` provider (63 bundled declarations) before its first listing and after a failed first listing. The picker shows the provider as pending or failed instead of its manifest models. - Static providers and providers without a declaration (12) are unchanged. - Saved listings, live listings, typed refs and pricing are unchanged. - Rollback is a revert. No stored state changes. Co-authored-by: Ayaan Zaidi <[email protected]>
…ng on the Gateway's first read (openclaw#202618) ## Problem A model that the provider's account listing omits could appear in `models.list` on the Gateway's first read after start. Follow-up to openclaw#202490. The approved rule: the provider's listing is the only source of which models exist. The hosted catalog and the manifest only describe models. ## Interleaving 1. The Gateway starts and publishes a quick `static` catalog (`publishConfiguredModelRuntimeSnapshots`, `src/gateway/server-startup-model-runtime.ts:59`). 2. That build seeds the registry for every signed-in provider with `loadManifestModelProviderConfigs` (`src/agents/prepared-model-runtime.facts.ts:556`, added in openclaw#167460). The manifest plan contains the hosted catalog rows, so the refreshable Together provider got `zz-lab/zz-day0-live` even though the saved listing (already loaded, `pluginCatalogs=1`) omits it. 3. `prepareCapturedRuntimeFacts` publishes the registry rows as list entries (`src/agents/prepared-model-runtime.configured-catalog.ts:124`). 4. `models.list` serves the published snapshot (`src/gateway/server-methods/models.ts:148`). The live full catalog, built from the account listing, publishes 5–24 s after `ready` and drops the row. The leak depends on timing. It happens only when the first read arrives before step 4's live publication. A scratch build with logging showed this in 10 of 10 runs: all 5 runs where the first read came before the publication leaked, and none of the 5 where it came after. The suspect `includeProviderPluginAugmentation === false` branch in `model-catalog.ts` never ran during these reads. ## Fix The fix is in `loadManifestModelProviderConfigs`, the single source of manifest rows that claim a model exists. It no longer returns rows for providers that declare `runtime` or `refreshable` discovery. Those providers list only their saved or live account listing. While the first listing is pending they list nothing (`pendingProviders`), and they also list nothing after a failed first listing. Static providers and providers without a discovery declaration keep their manifest rows at once, as before. Description consumers (limits, price, thinking, typed-ref resolution) are unchanged: typed refs to an unlisted model still resolve, run and are priced. Kept: the `includeProviderPluginAugmentation === false` branch in `buildPreparedModelCatalogSnapshot` (openclaw#143837) still passes dynamic manifest rows in no-augmentation builds. The first head removed it, and CI then showed that utility preparation uses those typed rows to refuse a Decisions model a credential has no grant for (`utility-completion.clawrouter.test.ts`). The scratch build showed that branch never runs on the Gateway or CLI list reads measured here. Moving that entitlement data onto a description-only path is a follow-up. **Contract change (approved):** this reverses part of openclaw#167460. Right after sign-in, a refreshable or runtime provider shows as pending instead of showing its known manifest models, until its listing arrives. A failed first listing leaves it empty with `refreshFailed`. Docs updated (`docs/plugins/manifest/models.md`). No schema, protocol or config change. ## Evidence Harness: isolated dist Gateways (`env -i`, scratch state), loopback HTTPS vendor mock, hosted catalog served on loopback with synthetic day-zero rows (`generatedAt` after each build's `builtAt`). Case `tom`: Together is signed in, the hosted catalog has `together/zz-lab/zz-day0-live`, and the account listing omits it. Each run does fresh setup, then 3 CLI reads (no Gateway; plain, `--refresh`, plain), starts the Gateway, does 4 Gateway reads (first, second, `--refresh`, after refresh), and sends one typed turn to the omitted ref. | 20 runs of `tom` | main `ab79858037db` | this branch (exact head `d8f05863`) | |---|---|---| | CLI, every read | hidden 20/20 | hidden 20/20 | | Gateway first `models.list` | **shown 4/20** | hidden 20/20 | | Gateway later reads | shown 1/20 (run 12: second read and `--refresh`) | hidden 20/20 | | Typed turn runs | 20/20 | 20/20 | | Typed turn priced ($6.0e-5 = catalog price) | 20/20 | 20/20 | Main's leaks were runs 12–15. The branch column is a fresh set of 20 runs on the exact head, after the bypass was restored. An earlier set of 20 on the first head (without the bypass) gave the same result. Other cases, one run each on branch and main, with identical results: static `abl` (hosted row listed everywhere, turn $3.0e-5), Together listing includes the ID `tog` (listed, 524288, $6.0e-5), ChatGPT `oai` (listed, 400000, $9.0e-5). Regression test `src/gateway/server-methods/models-list.first-read.integration.test.ts`: a real Gateway with a signed-in refreshable fixture provider whose `/models` response is held (an explicit gate). The first read and a read during the held listing must not list the manifest-only row, and the provider must be pending. After release, only the listed row appears. On main it fails with `expected [ 'manifest-only' ] to deeply equal []`. On this branch it passes. Gates: 53 consumer test files (`src/agents/model-catalog*`, `src/agents/prepared-model-runtime*`, `src/gateway/server-methods/models-auth-login*`, the new test) plus `src/agents/utility-completion.clawrouter.test.ts` green; full CI green on the exact head; local ClawSweeper review clean; `pnpm tsgo:core`, `pnpm check:test-types`, oxlint and oxfmt clean. `models-auth-login.catalog.integration.test.ts` now asserts the new contract: no rows while held and none after a failed first listing. The openclaw#167460 assertions are removed. ## Size Production: +13 / −7 across 3 files (net +6). The new code is the 6-line existence filter in `loadManifestModelProviderConfigs`; the other changed lines are rewritten comments. No production code is deleted. Tests: +97 / −5 (new regression test, plus openclaw#167460 assertions flipped). Docs: 2 lines. ## Merge danger and blast radius - Affects every `runtime` or `refreshable` provider (63 bundled declarations) before its first listing and after a failed first listing. The picker shows the provider as pending or failed instead of its manifest models. - Static providers and providers without a declaration (12) are unchanged. - Saved listings, live listings, typed refs and pricing are unchanged. - Rollback is a revert. No stored state changes. Co-authored-by: Ayaan Zaidi <[email protected]>
…ng on the Gateway's first read (#202618) ## Problem A model that the provider's account listing omits could appear in `models.list` on the Gateway's first read after start. Follow-up to #202490. The approved rule: the provider's listing is the only source of which models exist. The hosted catalog and the manifest only describe models. ## Interleaving 1. The Gateway starts and publishes a quick `static` catalog (`publishConfiguredModelRuntimeSnapshots`, `src/gateway/server-startup-model-runtime.ts:59`). 2. That build seeds the registry for every signed-in provider with `loadManifestModelProviderConfigs` (`src/agents/prepared-model-runtime.facts.ts:556`, added in #167460). The manifest plan contains the hosted catalog rows, so the refreshable Together provider got `zz-lab/zz-day0-live` even though the saved listing (already loaded, `pluginCatalogs=1`) omits it. 3. `prepareCapturedRuntimeFacts` publishes the registry rows as list entries (`src/agents/prepared-model-runtime.configured-catalog.ts:124`). 4. `models.list` serves the published snapshot (`src/gateway/server-methods/models.ts:148`). The live full catalog, built from the account listing, publishes 5–24 s after `ready` and drops the row. The leak depends on timing. It happens only when the first read arrives before step 4's live publication. A scratch build with logging showed this in 10 of 10 runs: all 5 runs where the first read came before the publication leaked, and none of the 5 where it came after. The suspect `includeProviderPluginAugmentation === false` branch in `model-catalog.ts` never ran during these reads. ## Fix The fix is in `loadManifestModelProviderConfigs`, the single source of manifest rows that claim a model exists. It no longer returns rows for providers that declare `runtime` or `refreshable` discovery. Those providers list only their saved or live account listing. While the first listing is pending they list nothing (`pendingProviders`), and they also list nothing after a failed first listing. Static providers and providers without a discovery declaration keep their manifest rows at once, as before. Description consumers (limits, price, thinking, typed-ref resolution) are unchanged: typed refs to an unlisted model still resolve, run and are priced. Kept: the `includeProviderPluginAugmentation === false` branch in `buildPreparedModelCatalogSnapshot` (#143837) still passes dynamic manifest rows in no-augmentation builds. The first head removed it, and CI then showed that utility preparation uses those typed rows to refuse a Decisions model a credential has no grant for (`utility-completion.clawrouter.test.ts`). The scratch build showed that branch never runs on the Gateway or CLI list reads measured here. Moving that entitlement data onto a description-only path is a follow-up. **Contract change (approved):** this reverses part of #167460. Right after sign-in, a refreshable or runtime provider shows as pending instead of showing its known manifest models, until its listing arrives. A failed first listing leaves it empty with `refreshFailed`. Docs updated (`docs/plugins/manifest/models.md`). No schema, protocol or config change. ## Evidence Harness: isolated dist Gateways (`env -i`, scratch state), loopback HTTPS vendor mock, hosted catalog served on loopback with synthetic day-zero rows (`generatedAt` after each build's `builtAt`). Case `tom`: Together is signed in, the hosted catalog has `together/zz-lab/zz-day0-live`, and the account listing omits it. Each run does fresh setup, then 3 CLI reads (no Gateway; plain, `--refresh`, plain), starts the Gateway, does 4 Gateway reads (first, second, `--refresh`, after refresh), and sends one typed turn to the omitted ref. | 20 runs of `tom` | main `569c60bc2a5c` | this branch (exact head `d8f05863`) | |---|---|---| | CLI, every read | hidden 20/20 | hidden 20/20 | | Gateway first `models.list` | **shown 4/20** | hidden 20/20 | | Gateway later reads | shown 1/20 (run 12: second read and `--refresh`) | hidden 20/20 | | Typed turn runs | 20/20 | 20/20 | | Typed turn priced ($6.0e-5 = catalog price) | 20/20 | 20/20 | Main's leaks were runs 12–15. The branch column is a fresh set of 20 runs on the exact head, after the bypass was restored. An earlier set of 20 on the first head (without the bypass) gave the same result. Other cases, one run each on branch and main, with identical results: static `abl` (hosted row listed everywhere, turn $3.0e-5), Together listing includes the ID `tog` (listed, 524288, $6.0e-5), ChatGPT `oai` (listed, 400000, $9.0e-5). Regression test `src/gateway/server-methods/models-list.first-read.integration.test.ts`: a real Gateway with a signed-in refreshable fixture provider whose `/models` response is held (an explicit gate). The first read and a read during the held listing must not list the manifest-only row, and the provider must be pending. After release, only the listed row appears. On main it fails with `expected [ 'manifest-only' ] to deeply equal []`. On this branch it passes. Gates: 53 consumer test files (`src/agents/model-catalog*`, `src/agents/prepared-model-runtime*`, `src/gateway/server-methods/models-auth-login*`, the new test) plus `src/agents/utility-completion.clawrouter.test.ts` green; full CI green on the exact head; local ClawSweeper review clean; `pnpm tsgo:core`, `pnpm check:test-types`, oxlint and oxfmt clean. `models-auth-login.catalog.integration.test.ts` now asserts the new contract: no rows while held and none after a failed first listing. The #167460 assertions are removed. ## Size Production: +13 / −7 across 3 files (net +6). The new code is the 6-line existence filter in `loadManifestModelProviderConfigs`; the other changed lines are rewritten comments. No production code is deleted. Tests: +97 / −5 (new regression test, plus #167460 assertions flipped). Docs: 2 lines. ## Merge danger and blast radius - Affects every `runtime` or `refreshable` provider (63 bundled declarations) before its first listing and after a failed first listing. The picker shows the provider as pending or failed instead of its manifest models. - Static providers and providers without a declaration (12) are unchanged. - Saved listings, live listings, typed refs and pricing are unchanged. - Rollback is a revert. No stored state changes. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit b9aa2b7) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit b64f67729fe4d977a135b5f20d64101dd66d4374) (cherry picked from commit d871ee076f4e9c2eed84e485ca427dda29327053)
Related: #136257, #143664.
AI-assisted.
What Problem This Solves
Model lookup needed consistent composition of static, generated, authored and current configuration sources while keeping request credentials separate from inventory.
Why This Change Was Made
Compose these sources in the registry before applying defaults. Current declarations own request settings, and replace mode admits only current declarations. Move catalog-row normalization to its existing responsibility boundary to remove a credential-normalization import cycle.
User Impact
Explicit routes, sparse metadata and default precedence are preserved. Removing a current key cannot revive an older file key; developer-interface callers without a replacing declaration keep authored-file settings. No operator option or schema change.
Evidence
The import-cycle check passed on the base, failed before the correction and passed afterward. Four hundred sixty-two tests passed across 33 affected suites. Retained Gateway and recording-service checks covered refresh retention, empty withdrawal, source routes and request isolation; they retain their original build scope.