Repository navigation
fix(models): preserve authored rows during generated catalog refresh - #142302
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 8, 2026, 12:36 PM ET / 16:36 UTC. ClawSweeper reviewWhat this changesPreserves manually authored model entries during generated catalog refresh and requires current authentication before deferred plugins contribute cached models. Merge readiness✅ Ready for maintainer review This focused repair remains useful: current main still combines authored and generated providers before planning. No blocking introduced defect was established, and the related staging PR does not supersede this work. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw combines manually declared models with plugin-generated inventory to populate model lists and agent registries. Catalog planning maintains those sources, while registry loading decides which generated entries are currently eligible. flowchart TD
A[Manual model declarations] --> C[Catalog planning]
B[Generated plugin inventory] --> C
C --> D[Separate root and generated catalogs]
D --> E[Registry loading]
F[Current ownership endpoints and authentication] --> E
E --> G[Model lists and agent registry]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +10, Tests +262, Docs +6, Other 0. Total +278 across 11 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep authored declarations independent from generated inventory while preserving existing replacement, secret-management, and request-authorization contracts. Do we have a high-confidence way to reproduce the issue? Yes, from source: a generated catalog sharing a provider ID overwrites its manual root declaration before current-main planning. The PR reports compiled before/after reproduction; this review did not execute it. Is this the best way to solve the issue? Yes. Separating the two sources at the planning owner directly repairs the overwrite, and registry admission reuses existing ownership, endpoint, and authentication predicates. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0ce2595f8904. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
landpr-approve-admin-merge |
|
Thanks @obviyus! Proof: Compiled models-list checks and independent acceptance verify that refresh keeps manual models and that deferred generated inventory requires current authentication.
Exact-head local review is clean at B with proof A. Required CI run 34249831444 passed on attempt 2. Attempt 1's Gateway-fixture startup timeout remains in the evidence; the failed jobs recovered through the existing GitHub-runner retry path, with no test, timeout, source, or workflow change. The assertion-count failure from the preceding revision was corrected separately. No unrelated-CI exception was used. The procedural owner-review hold for the root-authorship test was resolved by the recorded exact-head approval. Code, security, proof, and CI gates remained enforced. Compiled runtime evidence retains its original build/source identity; standalone installation and live-provider behavior are outside this proof. |
…penclaw#142302) Preserve manual root models during generated catalog refresh and require current authentication for deferred generated inventory. Keep root authorship separate from disposable cache membership, reuse the shared owner/endpoint filter, and consolidate generated-marker detection. Compiled CLI regressions and controls, focused source checks, and independent acceptance verify the behavior. Co-authored-by: Ayaan Zaidi <[email protected]>
…ies (#174641) ## What Problem This Solves Fixes: usage reports show Claude CLI models at $0.00 when an older OpenClaw version copied plugin catalog rows into an agent's root `models.json`. Those rows also outrank the live catalog forever. On one affected install this hid $220 of `claude-opus-4-8` usage behind a frozen zero price. ## User Impact - New writes never put discovered plugin rows in the root `models.json`. - `openclaw doctor --fix`, which update also runs, removes old copies. It removes a provider block only when it is an exact copy of a block in that plugin's generated catalog. - Doctor saves the previous file as `models.json.bak-<timestamp>` and lists every removed provider. - Edited blocks, blocks with credentials or overrides, and ids that config declares are never touched. - Afterwards, prices come from the current catalog, and `models status` shows Claude CLI native auth instead of `missing`. ## Why This Change Was Made Discovery copies a plugin's provider under its hook aliases, so `claude-cli` received the `anthropic` catalog. When owner lookup failed, the writer sent that copy to the author-owned root file instead of the plugin catalog. Owner lookup fails for a scoped plugin snapshot, or for an alias no manifest claims (on main today: `google-antigravity`, `google-interactions`, `azure-openai`, `modelstudio-native`). Since #142302 the root file merge keeps every existing provider, so the copy never left. The cost resolver reads the root file first, so its zero placeholders for unpriced models won over catalog prices. - **Writer:** records which plugin produced each discovered provider id. When owner lookup fails, it stores the row with that producer unless config declares the id. - **Doctor:** the catalog owner (`doctor-plugin-model-catalog.ts`) gets the legacy repair. A detector compares root blocks with the generated catalogs and requires exact equality, so no pricing or shape heuristics are involved. The file is rewritten, never deleted, because registry reads require it. ## Evidence - **Census:** in 8 releases (2026.5.28 → 2026.10.4) run in isolated state, plain Claude CLI use never wrote the root file. The leak needs a scoped or partial owner snapshot. A real affected file, from 2026-09-06, is a byte-for-byte deep copy of the `anthropic` block in that install's generated catalog. - **Upgrade harness:** I seeded 2026.9.2 state with that real file plus a hand-authored `my-proxy` provider, then ran the candidate's `openclaw doctor --fix --non-interactive`. - `claude-cli` was removed and `my-proxy` kept. The backup is byte-identical to the seeded file. - A second Doctor run found nothing. - Two later `models.json` writes left the file hash unchanged (`3bcc218b…`). - Control (same migrated state with the original file restored): - unchanged: default model, resolved model, allowlist, fallbacks, and the agent turn (`provider=claude-cli model=claude-opus-5`); - the model list drops only the 7 duplicate `claude-cli/*` rows; - Claude CLI runtime auth goes from `missing` to `claude-cli:runtime-synthetic`, the same in repeated runs. - **Upgrade from the latest stable (2026.10.4):** - Seeding: 2026.10.4 created the state, with a config provider carrying a fake key, an `openai` API-key auth profile and one real Claude CLI session. I then added the real leaked `claude-cli` root block, its generated `anthropic` catalog row and an authored root provider with a fake key. The candidate's `doctor --fix --non-interactive` then ran. - Removed: `claude-cli` only. The backup is byte-identical to the seeded file, and a second Doctor run changed nothing. - Kept: the authored root provider with its key, the config provider with its key, the auth profile, and the session (same key and id). - The Claude CLI turn works before and after. - Every other config or auth change also happens with 2026.10.4's own Doctor on the same seed: the legacy `claude-cli/*` default canonicalized to `anthropic/*`, and plaintext keys copied into auth profiles. The one exception is main's existing `"anthropic/*"` runtime entry. That Doctor leaves the `claude-cli` copy in place. - **Copy of a real install** (credentials, leases and other plugins' catalogs stripped; isolated Gateway): Doctor found and removed the copy. `sessions.usage` for June–October, with a fresh cache and only the root file differing: | claude-cli model | turns | stale root | repaired | |---|---|---|---| | claude-opus-4-8 | 2105 | $0.00 | $220.04 | | claude-haiku-4-5 | 12 | $0.00 | $0.20 | | other Claude models | 609 | $95.35 | $95.35 | Token totals are identical (4,307,266,930). The $220.04 equals the transcript token sums at the catalog's Opus 4.8 rates. - **Comparison with the CLI's own cost:** Claude Code recorded `costUSD` for 35 sessions on that install. Catalog rates reproduce all of them exactly ($2.5640 vs $2.5640) once cache writes are priced at the 1h rate. Historical OpenClaw transcripts did not store that split, so they estimate those turns about 31% low. #173792 records the split for new turns. - **Tests:** - Doctor: exact copy removed once with a byte-exact backup; edited copy kept; config-declared id kept. - Writer: an unowned hook alias goes to the producing plugin's catalog, not the root file. It fails without the fix. - The `models-config`, plugin catalog and Doctor catalog suites pass (208 tests). **Merge risk:** - **Writer change:** a two-way door; revert restores the old routing. - **Doctor repair:** rewrites user files, but only exact generated copies, always with a full backup, so a removal is recoverable by restoring the backup. - **Blast radius:** agents whose root `models.json` holds generated plugin copies, mainly Claude CLI installs from 2026-05 to 2026-10. Unowned alias copies no longer appear as separate models; they carried the producer's baseUrl under another id. Co-authored-by: Ayaan Zaidi <[email protected]>
…ies (openclaw#174641) ## What Problem This Solves Fixes: usage reports show Claude CLI models at $0.00 when an older OpenClaw version copied plugin catalog rows into an agent's root `models.json`. Those rows also outrank the live catalog forever. On one affected install this hid $220 of `claude-opus-4-8` usage behind a frozen zero price. ## User Impact - New writes never put discovered plugin rows in the root `models.json`. - `openclaw doctor --fix`, which update also runs, removes old copies. It removes a provider block only when it is an exact copy of a block in that plugin's generated catalog. - Doctor saves the previous file as `models.json.bak-<timestamp>` and lists every removed provider. - Edited blocks, blocks with credentials or overrides, and ids that config declares are never touched. - Afterwards, prices come from the current catalog, and `models status` shows Claude CLI native auth instead of `missing`. ## Why This Change Was Made Discovery copies a plugin's provider under its hook aliases, so `claude-cli` received the `anthropic` catalog. When owner lookup failed, the writer sent that copy to the author-owned root file instead of the plugin catalog. Owner lookup fails for a scoped plugin snapshot, or for an alias no manifest claims (on main today: `google-antigravity`, `google-interactions`, `azure-openai`, `modelstudio-native`). Since openclaw#142302 the root file merge keeps every existing provider, so the copy never left. The cost resolver reads the root file first, so its zero placeholders for unpriced models won over catalog prices. - **Writer:** records which plugin produced each discovered provider id. When owner lookup fails, it stores the row with that producer unless config declares the id. - **Doctor:** the catalog owner (`doctor-plugin-model-catalog.ts`) gets the legacy repair. A detector compares root blocks with the generated catalogs and requires exact equality, so no pricing or shape heuristics are involved. The file is rewritten, never deleted, because registry reads require it. ## Evidence - **Census:** in 8 releases (2026.5.28 → 2026.10.4) run in isolated state, plain Claude CLI use never wrote the root file. The leak needs a scoped or partial owner snapshot. A real affected file, from 2026-09-06, is a byte-for-byte deep copy of the `anthropic` block in that install's generated catalog. - **Upgrade harness:** I seeded 2026.9.2 state with that real file plus a hand-authored `my-proxy` provider, then ran the candidate's `openclaw doctor --fix --non-interactive`. - `claude-cli` was removed and `my-proxy` kept. The backup is byte-identical to the seeded file. - A second Doctor run found nothing. - Two later `models.json` writes left the file hash unchanged (`3bcc218b…`). - Control (same migrated state with the original file restored): - unchanged: default model, resolved model, allowlist, fallbacks, and the agent turn (`provider=claude-cli model=claude-opus-5`); - the model list drops only the 7 duplicate `claude-cli/*` rows; - Claude CLI runtime auth goes from `missing` to `claude-cli:runtime-synthetic`, the same in repeated runs. - **Upgrade from the latest stable (2026.10.4):** - Seeding: 2026.10.4 created the state, with a config provider carrying a fake key, an `openai` API-key auth profile and one real Claude CLI session. I then added the real leaked `claude-cli` root block, its generated `anthropic` catalog row and an authored root provider with a fake key. The candidate's `doctor --fix --non-interactive` then ran. - Removed: `claude-cli` only. The backup is byte-identical to the seeded file, and a second Doctor run changed nothing. - Kept: the authored root provider with its key, the config provider with its key, the auth profile, and the session (same key and id). - The Claude CLI turn works before and after. - Every other config or auth change also happens with 2026.10.4's own Doctor on the same seed: the legacy `claude-cli/*` default canonicalized to `anthropic/*`, and plaintext keys copied into auth profiles. The one exception is main's existing `"anthropic/*"` runtime entry. That Doctor leaves the `claude-cli` copy in place. - **Copy of a real install** (credentials, leases and other plugins' catalogs stripped; isolated Gateway): Doctor found and removed the copy. `sessions.usage` for June–October, with a fresh cache and only the root file differing: | claude-cli model | turns | stale root | repaired | |---|---|---|---| | claude-opus-4-8 | 2105 | $0.00 | $220.04 | | claude-haiku-4-5 | 12 | $0.00 | $0.20 | | other Claude models | 609 | $95.35 | $95.35 | Token totals are identical (4,307,266,930). The $220.04 equals the transcript token sums at the catalog's Opus 4.8 rates. - **Comparison with the CLI's own cost:** Claude Code recorded `costUSD` for 35 sessions on that install. Catalog rates reproduce all of them exactly ($2.5640 vs $2.5640) once cache writes are priced at the 1h rate. Historical OpenClaw transcripts did not store that split, so they estimate those turns about 31% low. openclaw#173792 records the split for new turns. - **Tests:** - Doctor: exact copy removed once with a byte-exact backup; edited copy kept; config-declared id kept. - Writer: an unowned hook alias goes to the producing plugin's catalog, not the root file. It fails without the fix. - The `models-config`, plugin catalog and Doctor catalog suites pass (208 tests). **Merge risk:** - **Writer change:** a two-way door; revert restores the old routing. - **Doctor repair:** rewrites user files, but only exact generated copies, always with a full backup, so a removal is recoverable by restoring the backup. - **Blast radius:** agents whose root `models.json` holds generated plugin copies, mainly Claude CLI installs from 2026-05 to 2026-10. Unowned alias copies no longer appear as separate models; they carried the producer's baseUrl under another id. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #136257.
What Problem This Solves
Fixes an issue where generated catalog refresh hid an authored root model when a plugin owned the same provider. Deferred plugins could also restore cached models without current authentication.
Why This Change Was Made
Keep authored root providers separate during planning. Admit deferred generated inventory only after current ownership, endpoint eligibility and authentication checks. Consolidate generated-marker detection in one implementation.
User Impact
Merge mode retains manual models and authentication-only records. Explicit replacement, empty replacement, recovery and managed secrets retain their contracts. No schema or migration change.
Consumers: generated-catalog planning and deferred cache admission distinguish authored rows from generated inventory.
Evidence
Compiled refresh lost the authored model before the fix and retained all four models afterward. Deferred cache returned no models without credentials, while valid environment/configured keys retained the model. Focused membership, registry, planning and credential tests passed. Proof used compiled commands and synthetic services, not a standalone installation or live provider.