Skip to content

refactor(models): compose prepared catalog sources before lookup - #143837

Merged
obviyus merged 4 commits into
mainfrom
fix/prepared-registry-composition
Sep 10, 2026
Merged

obviyus merged 4 commits into
mainfrom
fix/prepared-registry-composition

Conversation

@obviyus

@obviyus obviyus commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

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.

@obviyus obviyus self-assigned this Sep 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

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

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Sep 10, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 10, 2026, 11:43 AM ET / 15:43 UTC (Revision 9).

ClawSweeper review

What this changes

The 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
Reviewed head: 90e97e021b032ec88cd19d1c518dc2799b02ad8a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level correction with useful retained behavior proof, meaningful regression coverage, and no remaining blocking finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Retained independent Gateway and SDK/loopback HTTP observations cover the changed registry and publication boundaries, including route isolation, current-key removal, recovery, and replace exclusivity. Their original build attribution is preserved; rebased integration tests supplement them without claiming a fresh live run or external-provider authentication.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): Retained independent Gateway and SDK/loopback HTTP observations cover the changed registry and publication boundaries, including route isolation, current-key removal, recovery, and replace exclusivity. Their original build attribution is preserved; rebased integration tests supplement them without claiming a fresh live run or external-provider authentication.
Evidence reviewed 8 items Introduced composition and request authority: The pinned merge-base delta adds static and current configured sources to the existing registry composition. Current declarations replace the provider request settings captured from an older authored file; generated inventory is stripped of request headers.
Current main still lacks this composition: At fetched main, loadModels composes captured plugin and authored-file sources without this PR's static/current configuration composition or replace-mode exclusion. The merged prerequisite #143664 therefore does not supersede this work.
Latest release comparison: The v2026.9.3 registry still concatenates authored and captured plugin models; it does not contain the proposed prepared-source composition. GitHub identifies this release as published on 2026-09-08.
Findings None None.
Security None None.

How this fits together

OpenClaw'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
Loading

Before merge

  • Resolve merge risk (P1) - Existing setups using credentials or headers only in models.json can stop authenticating when a current provider declaration takes authority; recovery requires current credentials or authored current configuration. The PR explicitly records acceptance of this transition.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +123, Tests +456, Docs +8. Total +587 across 20 files.

View PR surface stats
Area Files Added Removed Net
Source 14 353 230 +123
Tests 5 461 5 +456
Docs 1 12 4 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 20 826 239 +587

Review metrics

Metric Value Why it matters
Production versus test growth production +123 net lines; tests +456 net lines Production growth supplies source composition and catalog-boundary enforcement; the normalization module primarily relocates existing code.

Stored data model

Persistent data-model change detected: unknown-data-model-change: src/agents/sessions/model-registry.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Retain the accepted authority transition (recommended)
    Keep current declarations authoritative while retaining the documented SDK exception and the existing removal-and-recovery evidence.

Technical review

Best 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.

Labels

Label justifications:

  • P2: This is a bounded model-catalog correctness improvement without evidence of an urgent user-facing outage.
  • merge-risk: 🚨 compatibility: The accepted request-authority transition can stop authentication for setups relying on stale file-only keys or headers.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): Retained independent Gateway and SDK/loopback HTTP observations cover the changed registry and publication boundaries, including route isolation, current-key removal, recovery, and replace exclusivity. Their original build attribution is preserved; rebased integration tests supplement them without claiming a fresh live run or external-provider authentication.
  • proof: sufficient: Contributor real behavior proof is sufficient. Retained independent Gateway and SDK/loopback HTTP observations cover the changed registry and publication boundaries, including route isolation, current-key removal, recovery, and replace exclusivity. Their original build attribution is preserved; rebased integration tests supplement them without claiming a fresh live run or external-provider authentication.

Evidence

What I checked:

  • Introduced composition and request authority: The pinned merge-base delta adds static and current configured sources to the existing registry composition. Current declarations replace the provider request settings captured from an older authored file; generated inventory is stripped of request headers. (src/agents/sessions/model-registry.ts:504, 90e97e021b03)
  • Current main still lacks this composition: At fetched main, loadModels composes captured plugin and authored-file sources without this PR's static/current configuration composition or replace-mode exclusion. The merged prerequisite fix(sdk): preserve authored requests when model catalogs overlap #143664 therefore does not supersede this work. (src/agents/sessions/model-registry.ts:471, 25a6148d1a9a)
  • Latest release comparison: The v2026.9.3 registry still concatenates authored and captured plugin models; it does not contain the proposed prepared-source composition. GitHub identifies this release as published on 2026-09-08. (src/agents/sessions/model-registry.ts:456, 1391f7cd2d40)
  • Prior projection finding addressed: Initial snapshots and scoped catalogs now pass configured static entries into materialization, while replace mode excludes those fallback entries. Full-catalog projection carries the current static projection through the same materializer. Source tests cover startup/full agreement, replace exclusivity, current credentials, and isolated request forks. (src/agents/prepared-model-runtime.full-catalog.ts:326, 90e97e021b03)
  • Accepted compatibility transition and retained proof: The captured primary body, sourceRevision 9f4b8b560ecdacbbaa6f0d3afcd118e1e190eea926d97875d4e79ae005366cf8, explicitly records approval of current-declaration authority and the raw authored-file SDK exception. It retains independent Gateway observations for catalog agreement, refresh failure retention, empty retirement, and replace exclusivity, plus SDK/loopback HTTP observations for route isolation, current-key removal, and recovery. These remain attributed to their original tested builds; the body reports 462 supplemental tests on the rebased candidate. The previous completed review contains no remaining findings. (90e97e021b03)
  • Normalization owner cutover: Catalog row normalization moves intact into a credential-independent module. The existing provider barrel and direct callers use that owner; no compatibility alias, public SDK subpath, dependency change, or credential writer is introduced. The changed behavior uses OpenClaw's registry and workspace packages; no Codex dependency contract is required by this diff. (src/agents/models-config.providers.catalog.ts:116, 90e97e021b03)

Likely related people:

  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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-09-10T07:46:26.945Z sha 2eaea5f :: needs real behavior proof before merge. :: [P1] Capture effective compatibility before merging provider sources
  • reviewed 2026-09-10T08:48:55.249Z sha 085d1de :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-10T09:15:03.762Z sha 038b62c :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-10T10:21:55.567Z sha 038b62c :: blocked before merge. :: [P2] [P2] Restore configured static projection for initial snapshots
  • reviewed 2026-09-10T10:55:39.587Z sha 361170c :: blocked before merge. :: none
  • reviewed 2026-09-10T11:12:03.189Z sha 4b96fbf :: blocked before merge. :: none
  • reviewed 2026-09-10T12:07:19.950Z sha 4b96fbf :: blocked before merge. :: none
  • reviewed 2026-09-10T12:24:18.790Z sha bdfa347 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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. and removed merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 10, 2026
@obviyus
obviyus force-pushed the fix/prepared-registry-composition branch from bdfa347 to 90e97e0 Compare September 10, 2026 15:35
@obviyus
obviyus merged commit f7a419a into main Sep 10, 2026
186 of 187 checks passed
@obviyus
obviyus deleted the fix/prepared-registry-composition branch September 10, 2026 15:58
@obviyus

obviyus commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator Author

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.

  • Bug: Prepared lookup assembled model sources inconsistently, and importing credential normalization into the registry introduced an import cycle.
  • Fix: The registry composes admitted sources before lookup; catalog row normalization has one owner separate from credential resolution.
Before After
Static, generated, authored, and current rows could disagree at lookup boundaries. Prepared views consume the registry composition with current request settings and replace membership.
The import-cycle check failed. Both import-cycle checks pass without an allowlist exception.

Merged as f7a419aeaf720d655e47d177a5e0de2322d5be24. No unrelated-CI exception was needed.

obviyus added a commit that referenced this pull request Sep 11, 2026
)

## 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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 11, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 11, 2026
… (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]>
obviyus added a commit that referenced this pull request Nov 17, 2026
)

## 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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 18, 2026
…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]>
RomneyDa added a commit that referenced this pull request Nov 19, 2026
)

## 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)
obviyus added a commit that referenced this pull request Nov 20, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 21, 2026
…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]>
tideclaw-bot pushed a commit that referenced this pull request Nov 23, 2026
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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