Repository navigation
feat(models): use the v2 catalog and price each route by who bills it - #156535
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 24, 2026, 11:44 AM ET / 15:44 UTC (Revision 14). ClawSweeper reviewWhat this changesThe branch makes the catalog publisher and client use a v2 feed, preserves older downloaded catalogs during upgrades, and estimates each route using the biller's price list. Merge readiness✅ Ready for maintainer review Current main still lacks the client cutover. The pinned head has no remaining code finding from the prior review, and the catalog owner has now explicitly accepted the audited 762-key pricing-coverage change. Priority: P2 Review scores
Verification
How this fits togetherThe catalog publisher combines model data, price feeds, and plugin policies into hosted files. The Gateway downloads a file into local state, then model lookup and usage displays use it for metadata and cost estimates. flowchart LR
A[Vendor price feeds] --> B[Catalog publisher]
C[Plugin pricing policies] --> B
B --> D[Hosted v1 and v2 catalogs]
D --> E[Gateway catalog store]
E --> F[Model and route pricing]
F --> G[Usage cost estimates]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +278, Tests +587, Docs +20, Other +167. Total +1052 across 34 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Complete the coordinated catalog rollout through the existing merge gates, retaining v1 service for released clients and legacy-cache access during upgrades. Do we have a high-confidence way to reproduce the issue? Yes, by comparing direct OpenAI and OpenRouter routes against a feed where OpenRouter discounts the same model: current-main publisher keying can apply the promotional rate to both. This read-only review did not execute the comparison. Is this the best way to solve the issue? Yes. The existing publisher owns price-source selection, plugin manifests describe route policy, and the client projects both wire versions through one ingestion boundary while preserving stored v1 state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0440fa7f72db. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (13 earlier review cycles; latest 8 shown)
|
d3dac3c to
9360742
Compare
|
Pushed a follow-up to this branch: v2 keeps the price that sits on each model row, and gets back the prices for models outside the catalog, without copying them per gateway. Whyv2 as landed dropped v1's standalone
Resolving the live v1 and v2 feeds through Most of v1's map was copies, though: 11,332 of its 14,990 entries repeat an upstream price under each gateway's prefix. In the live v1 feed, Cloudflare and Vercel carried the same 3,617 keys with identical values. Before and afterOne model, Claude Sonnet 4.5: v1 repeats the price under every route: "pricing": {
"anthropic/claude-sonnet-4.5": { "input": 3, "output": 15, … },
"openrouter/anthropic/claude-sonnet-4.5": { "input": 3, "output": 15, … },
"cloudflare-ai-gateway/anthropic/claude-sonnet-4.5": { "input": 3, "output": 15, … },
"vercel-ai-gateway/anthropic/claude-sonnet-4.5": { "input": 3, "output": 15, … },
"kilocode/openrouter/anthropic/claude-sonnet-4.5": { "input": 3, "output": 15, … }
// …14,990 entries
}v2 as landed keeps the price on each catalog row and has no standalone prices: "models": [
{ "id": "claude-sonnet-4-5", "provider": "anthropic",
"pricing": { "status": "known", "currency": "USD", "unit": "million_tokens", "input": 3, "output": 15, … } }
]v2 with this change keeps the model rows and adds two optional sections: "models": [ …unchanged… ],
"upstreamPricing": {
"anthropic/claude-sonnet-4.5": { "input": 3, "output": 15, …, "source": "openRouter", "passthroughOnly": true },
"openai/gpt-4-turbo-2024-04-09": { "input": 10, "output": 30, "source": "liteLLM" }
},
"providerPricing": {
"anthropic/claude-3-haiku": { "input": 0.25, "output": 1.25, …, "source": "openRouter" }
}
A provider's own price still wins, in this order: a configured or discovered model cost, then the provider's catalog row, then Keys
SizeBoth files come from the same publisher run, same source snapshot:
That's about half of v1's size; compressed, v1 is 2.4× larger. The client limit is 4 MiB. Proof
Notes
|
|
Catalog owner decision (@obviyus; @vincentkoc handed catalog ownership over earlier in this PR): I accept the price-coverage change. The 762 keys that lose an estimate are the audited set in the PR body: 294 OpenRouter |
|
@clawsweeper re-review Head: 0b5230a (unchanged). The only remaining item was direct catalog-owner acceptance of the 762-key change, now posted above by the catalog owner. Review only; no repair or merge automation requested. |
|
🦞👀 Re-review progress:
|
|
Landed as f1f18d7. Bug: OpenRouter's price feed was treated as every vendor's price, so a promotion like OpenRouter's 50% off Thanks @vincentkoc for the v2 catalog this builds on, and for the source review that caught the legacy-adoption bug. The hosted catalog picks this up on its next publish from |
…openclaw#156535) Related: openclaw#156507 ## What Problem This Solves Fixes wrong cost estimates when OpenRouter runs a promotion: OpenRouter's price list was treated as every vendor's price list, so OpenAI direct and the Vercel, Kilo and Cloudflare gateways all showed OpenRouter's discounted rate. It also moves clients to the smaller v2 hosted catalog. ## User Impact Cost estimates now use the price of whoever bills the request. During OpenRouter's current 50% promotion on `openai/gpt-5.6-sol`, OpenAI direct, Vercel, Kilo and Cloudflare show $4/$20 per million tokens instead of $2/$10, while OpenRouter keeps $2/$10. Clients download `/models/v2/catalog.json` by default: 1.6 MB instead of v1's 3.0 MB. Prices for models outside the catalog, such as gateway routes and older model IDs, still resolve. Released clients keep reading v1, which the same publisher run keeps in step. Existing installs keep their downloaded catalog across the upgrade, including offline default installs whose stored catalog came from the v1 default URL. Subscription routes such as Kimi Code keep showing pay-as-you-go estimates. After merge, the catalog repository's publish run regenerates both feeds from `main`, so released clients also receive the corrected prices through v1. 762 keys stop resolving; the route audit below shows none is a supported route with a vendor or gateway price. Rollout (maintainer decision: land as one PR): the hosted v2 file gains `upstreamPricing`/`providerPricing` on the first publish after merge (every 4 hours). Released clients read v1 and are unaffected. Only `main`/nightly builds that download v2 before that publish briefly lack estimates for routes outside catalog rows; the next publish restores them. ## Why This Change Was Made - **v2 wire format:** each model carries its price. Two optional sections cover models without a catalog row: - `upstreamPricing` holds each vendor's rate once, with its source, instead of v1's per-gateway copies. - `providerPricing` holds a provider's own rate. - **Price sources follow who bills the request:** - A new `modelsDev` source prices each provider from its own models.dev entry, reusing the models.dev download the publisher already makes. The entry is chosen by the plugin's existing `modelCatalog.modelsDev` mapping or its `modelsDev.provider` policy. - OpenRouter's feed prices only `openrouter/*` keys. - Gateways with their own list (Kilo, Vercel) use it first. Gateways that bill vendor rates (Cloudflare, per its Unified Billing docs) use the vendor's own catalog row. - Plugin manifest policies are updated to match. - **Storage:** v2 is stored in its own slot so older clients never read it. Until the new client writes that slot, it reads the older client's catalog. With the default config, a catalog downloaded from the retired v1 default URL stays active until the v2 download lands; configured mirrors must match exactly. A `304` adopts the older client's row only when that row, read inside the same write transaction, matches the revalidated one; otherwise the v2 slot stays empty. The older slot is never written. ## Evidence - **Pricing, through `resolveModelCostConfig`:** - For `openai/gpt-5.6-sol`, OpenAI, Vercel, Kilo and Cloudflare now resolve $4/$20, and OpenRouter keeps $2/$10. The references are OpenRouter's endpoint list (`discount: 0.5`), models.dev, Vercel's and Kilo's live model lists, and Cloudflare's Unified Billing docs. - Across 13,198 keys, compared with the head before the billing change: 11,842 unchanged, 269 changed (for example Kilo `google/gemini-3.5-flash` now matches Kilo's live $0.75/$4.5, and Qwen routes use Alibaba's pay-as-you-go rate), 120 newly priced, 762 no longer priced. - **Route audit of the 762 (maintainer decision: accepted):** - 294 are OpenRouter batch-mode variants (`:batch`), which no OpenClaw route sends. - 423 are Cloudflare/Vercel keys under OpenRouter-only names: `~vendor/…-latest` aliases, dotted Anthropic IDs (`claude-opus-4.5`; Anthropic's API uses dashes), and OpenRouter variants such as `openai/gpt-5.6-sol-pro` that neither the vendor's own list nor the catalog contains (OpenAI direct already had no price for them). None is a vendor catalog row. One (`inclusionai/ling-3.0-flash-fin`) is in Vercel's live model list and is priced by Vercel's runtime discovery. - 45 are direct-provider keys: retired models the vendor no longer lists (`kimi-k2*`, `claude-opus-4-1`, `claude-sonnet-4`, Gemma, image variants), OpenRouter-style IDs, `zai/glm-4.7-flash` (free on Z.ai; the old number was OpenRouter's), and `qwen/qwen3-coder-next` (only Coding Plan at $0 and resellers list it). - The audit found and fixed two real gaps: Qwen catalog rows (and gateways passing them through) now use Alibaba's pay-as-you-go list, like Kimi Code's subscription routes; vendors whose models.dev slug differs from their provider ID (`moonshotai`) are also keyed by that slug, so gateway pass-through finds them. - Before the billing change, v2 with the standalone sections matched v1 on all 13,198 keys, with no lost or changed prices. - **Real clients against a local mirror of the new feeds:** - This PR's CLI downloaded v1 and v2 (44 providers, 1,071 models) and revalidated with `304`, and its built Gateway started with v2 stored. - Released 2026.9.4 and 2026.8.1 accepted the new v1 and rejected v2 cleanly (`schemaVersion: expected 1`, exit 1). A rejected v2 fetch left their stored v1 intact. - 2026.7.1 predates hosted catalog refresh. - **Upgrade:** - A real 2026.9.4 state directory (schema 17) upgraded by this PR's CLI revalidated its existing v1 mirror catalog with `304`, with no full download, and copied it into the v2 slot. The older client's slot was unchanged. - Default install: 2026.9.4 downloaded the live `catalog.openclaw.ai/models/v1` catalog into fresh state. This PR's code then served that row under the default config, refused it for a configured mirror, and on a mismatched check left the v2 slot empty and the v1 slot byte-identical. - Published driver × candidate: npm-global 2026.9.4 holding that default v1 catalog ran its own `openclaw update --tag <candidate tarball> --yes --no-restart` onto the package built from `2582b9dd`; the final head adds only a price-projection fix in `remote-bundle.ts` and its test, with no update, Doctor or storage changes. All 11 steps exited 0: global update, candidate migration rehearsal, Doctor lint, config validation, plugin resolution, migration continuation, Gateway canary, install swap, `openclaw doctor`, service reconciliation, and post-plugin Doctor lint. The candidate Gateway then stored the live v2 feed (schema 2, same generation) in its own slot. The v1 slot's bytes were identical (same SHA3) before the update, after it, and after the Gateway ran. - **Tests:** regressions cover: - OpenRouter's promotion - gateway own-list and vendor-row precedence - pass-through source policy - standalone parity - a mirror's standalone price colliding with an unknown catalog row (the row wins) - the upgrade fallback, including offline default installs and a legacy row changed by an older client before a `304` (both fail on the previous head) Publisher, catalog, pricing, session-cost, usage-format, Gateway startup and state-database suites pass. Cost, `pnpm test <file> --maxWorkers=1` (new or changed files; mostly transform time on a cold cache): | File | Tests | Duration | |---|---|---| | `packages/model-catalog-core/src/remote-catalog-bundle.test.ts` | 16 | 0.6 s | | `test/scripts/publish-model-catalog-v2.test.ts` | 4 | 1.0 s | | `src/model-catalog/pricing.routing.test.ts` | 4 | 12.2 s | | `src/model-catalog/pricing.v2.test.ts` | 9 | 13.1 s | | `src/model-catalog/remote-overlay.test.ts` | 21 | 13.7 s | | `src/model-catalog/pricing.v2-standalone.test.ts` | 12 | 13.5 s | | `src/model-catalog/remote-store.test.ts` | 3 | 14.8 s | | `src/model-catalog/remote-refresh.test.ts` | 10 | 17.6 s | | `src/infra/session-cost-usage.test.ts` | 62 | 22.1 s | | `test/scripts/publish-model-catalog.test.ts` | 73 | 23.3 s | | `src/model-catalog/pricing.test.ts` | 59 | 28.4 s | | `src/gateway/server.catalog-startup.test.ts` | 3 | 32.5 s | `server.catalog-startup.test.ts` is over 30 s because it boots a real Gateway, which it already did before this PR; this PR only updates its fixture URL and expected prices. - **Checks:** - Hosted CI is running on this head. - Changed-file typecheck on every lane, core and scripts lint, and dead-code scans pass. - The extension lint lane runs in hosted CI, because the local worktree is nested inside another install. The extension changes are manifest JSON only. - **Review:** an independent pricing audit and code reviews. Their findings were fixed, except the follow-ups below. Follow-ups, not in this PR: - LiteLLM long-prompt tiers (`_above_Nk_tokens`) are dropped. - A missing cache-read rate publishes as $0. - OpenAI and Copilot built-in seeds for gpt-5.6 are stale; the hosted catalog corrects them after the first refresh. Co-authored-by: Ayaan Zaidi <[email protected]>
Apply explicitly requested #158863 / 09a6051, crediting Ayaan Zaidi (obviyus). Reuse Vincent Koc's dormant parser (#156518) and opt-in paired generator (#156530). Retain only the optional wire-schema and negative-test compatibility from #156535, not runtime/client/store activation, StandalonePricing infrastructure or billing policy. Provider recommendations preserve order and trim/validate IDs against the same provider. Invalid optional manifest lists are omitted; strict v2 rejects invalid remote lists. V1 output excludes the field and keeps its released contract. No bundled manifest or runtime/picker activates recommendations. Fix the review-exposed paired-output failure: prepare both candidate/previous sets before replacing final paths and retain cross-referenced recovery after interruption or uncertain publication. Do not automatically roll back over foreign replacements. Cleanup after success warns without claiming failure. This is recoverability, not multi-file atomicity or power-loss durability. Fixed-input actual default/priced v1 output remains byte-identical; v2 output remains identical across the settlement repair, and the parser matches the requested upstream source. 59 focused and165 caller cases pass; settlement adds real boundary/interruption proof,13 paired tests and73 publisher tests. Affected types, lint, format, MDX/docs links and frozen eb377ac ratchets pass. Final independent P0-P2 review is scoped-clean on exact tree 2e67a78. No SQLite schema, package version, dependency, runtime activation or public publication change. Version remains2026.9.6 and fs-safe0.20.0. Requested npm preflight/stable FRV still require their separate source/version/admission gates; no CI run or platform clearance is claimed by this commit. ## Work sessions - Original discussion, review and integration: https://team.openclaw.ai/chat/roboclaw/dashboard/db4d78ac-b19b-4f64-adfb-0ca7973a62e4 - Dormant catalog implementation and verification: https://team.openclaw.ai/chat/roboclaw/subagent/5bc0e124-d2e6-4193-9f9b-d2767d326b30 - Paired-output correction and verification: https://team.openclaw.ai/chat/roboclaw/subagent/90593a20-97bf-4134-9221-ff30d55a618a Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: Vincent Koc <[email protected]> Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vyctorbrzezowski <[email protected]> Co-authored-by: steipete <[email protected]> Co-authored-by: jalehman <[email protected]>
…8000) Related: #140086, #141885, #156535, #157838 ## What Problem This Solves A running Gateway doesn't see a newly downloaded hosted model catalog until it restarts. This PR publishes each accepted catalog through the existing prepared-runtime owner, without a restart. Model rows and their prices switch together as one generation, which keeps the invariant from #140086. ## User Impact - Compatible downloads are adopted at the Gateway's background catalog check, or after an explicit `models.list` refresh. That refresh returns the currently accepted rows right away and runs adoption afterward. - A turn admitted on catalog N keeps N's rows and prices until it finishes. New turns use N+1. Rows and prices are never mixed. - A concurrent auth or config publication no longer postpones adoption to the next scheduled check (up to 6 h). Adoption waits for that publication to settle, then retries, up to 3 attempts. - An owner whose build failed or timed out ends the adoption instead of waiting on unbounded work. Gateway shutdown cancels an adoption that is still preparing. - Malformed, schema-invalid, too-new (`minVersion`) and older catalogs are rejected, and the previously accepted catalog stays in use. - Changing `models.catalogRefresh.url` no longer needs a restart: the previous source's catalog stops applying, and the mirror's catalog is adopted at the next catalog check. **Bad-catalog exposure:** with live apply, a *valid but wrong* published catalog reaches running Gateways at their next catalog check (at most every 6 h) or on the next explicit `models.list` refresh. It no longer waits for a restart. Recovery uses existing mechanisms only: - Republish a corrected catalog with a newer `generatedAt`; Gateways adopt it the same way. - Operators can set `models.catalogRefresh.enabled: false`, which withdraws remote rows and prices without a restart (covered by the Gateway integration test). This PR adds no new kill switch, config option or env knob. ### Compatibility No config keys, defaults, types, validation, stored rows, protocol or SDK contracts change. The only config-surface change is the `models.catalogRefresh.url` help text, which drops the stale "Changes apply after a Gateway restart" sentence, and its regenerated config-doc baseline hash. Existing configs validate unchanged and need no Doctor migration (maintainer confirmation: #158000 (comment)). Startup behavior is unchanged. Upgrade impact for existing installs: an accepted download activates at the next catalog check instead of the next restart. ## Why This Change Was Made - `prepared-model-runtime.configured-refresh.ts` builds a complete candidate generation of the configured owners under the new catalog. One serialized commit then publishes rows, the accepted bundle, the pricing context and the reply-dispatch projection together. - Adoption re-reads the stored catalog until the config it read under is still current, so a stale caller can't cancel a current adoption. - Each preparation attempt has its own abort signal. A config advance restarts only the attempt; a newer catalog or shutdown ends the whole adoption, including pricing preparation. - Between attempts, adoption waits only on publication gates: a pending replacement or an owner's pending publication. - Adopted owners install the same plugin-retirement recovery as configured publication (#161267). After commit, a lost Gateway plugin loan republishes them through the normal recovery. Before commit, it restarts the adoption attempt, and the commit refuses any candidate whose plugin generation retired. ### Why downloads were restart-only, and what this keeps Restart-only activation was a mechanism, not the goal. #140086 chose it to stop rows and prices from different catalog versions mixing, and #157838 was merged as "the prerequisite for applying new remote catalogs without a Gateway restart (rows and prices must switch together)". This PR is that follow-up. Every requirement those PRs set still holds: | Original requirement | Source | How it holds here | |---|---|---| | Rows and prices from one catalog version; never mixed across reloads or new requests | #140086 | One serialized commit publishes owners, bundle, pricing context and dispatch; pricing contexts are keyed by the exact accepted catalog. Integration test: new rows appear only with new prices | | Admitted work keeps its pair | #140086, #157838 | Runs carry their plugin generation's catalog; usage operations capture one pricing context. Integration test and live proof: the in-flight turn keeps the old price | | Startup absence is a real state (no downloaded rows without prices) | #140086 | Absence → catalog goes through the same atomic commit; overlay absence tests unchanged | | Worker replacement inherits the host's accepted pair, not a later download | #140086 | The commit updates the inherited pair; later workers and a worker-exit recovery keep it (overlay and integration tests) | | Current enablement and source URL still gate eligibility | #140086, #156535 | Checked on every read and before adoption, including the default-install v1 fallback; disablement withdraws rows and prices together (integration test) | | Bad or superseded downloads never replace the active pair | #140086, #141885 | Compatibility, `minVersion`, revision and `generatedAt` checks; stale reads can't cancel a current adoption (regression test) | | Failed catalog checks retry at the remaining fresh interval, not a full TTL | #141885 | Unchanged scheduler behavior; the deleted notice test's retry case is restored for failed adoption (fails if the retry falls back to the full TTL) | | Operators learn when a downloaded catalog is not yet active | #141885 | No longer needed: downloads activate at the next check. The restart notice and its tests are removed; `models refresh` says when a running Gateway applies the update | | Billing-route prices switch with their rows | #156535 | `upstreamPricing` and `providerPricing` are part of the accepted catalog pair | ## Evidence **Regressions.** Each fails with its fix reverted and passes with it: - *Retries a scheduled adoption when its pending auth owner settles.* Runs through the real Gateway update scheduler. Reverted, it logs `remote model catalog check superseded; deferred to the next check`. - *Does not let a read under a superseded config cancel the current adoption.* Reverted, both calls end `superseded`. - *Ends adoption instead of joining a timed-out owner build.* Reverted, adoption never settles. - *Does not hold Gateway shutdown on an adoption's pricing preparation.* Reverted, shutdown waits on the held preparation until the test times out. - *Recovers adopted owners when their borrowed Gateway plugin retires after commit / before commit.* Without the recovery, both fail: `Prepared model runtime plugin generation retired` and `prepared reply dispatch runtime owner was not published`. - *Uses the remaining stored TTL after a fresh startup check when adoption fails.* With the retry reverted to the full TTL, the second check doesn't run. **Suites:** | Suite | Result | |---|---| | `prepared-model-runtime.remote-publication.test.ts` | 10/10 | | Gateway integration (`models-list.remote-catalog`) | v1 and v2 pass. Config and auth churn during preparation end `published` on the settled owners. Also covers retained admitted runs, rejected and stale bundles, worker replacement and disablement | | `prepared-model-runtime*`, `server-plugin-reload*`, `update-startup`, and all PR-touched test files | pass | | `tsgo:core`, all `tsgo:test:src` shards | pass | | oxlint and oxfmt on changed files; `config:docs:check`, `config:schema:check`; max-lines, assertion-safety and test-timeout-race ratchets | pass | Tests wait on owned completion signals (`withinTest`), not wall-clock deadlines. **Live proof** on an isolated Gateway built from `cb8c9197fdc` (no provider mocks). Later commits add plugin-retirement recovery for adopted owners, covered by the regression tests above, and rebases onto `main`. It used a real OpenAI key through `openai/gpt-4.1-mini`, and the build stamp was set before the real catalog's publication date. A client polled `models.list` back to back over one WebSocket for the whole run (1023 polls, no errors). One Gateway process (PID unchanged) and no restart: 1. The stored catalog was seeded with an older revision of the real `catalog.openclaw.ai` v2 catalog: generated 2 days earlier, `gpt-4.1-mini` priced ×10, plus one extra kimi row. `models.list` listed the extra row, and a turn priced **$4.00 / $16.00 per M** input/output. 2. `openclaw models refresh` downloaded the real catalog (`updated`, 1039 models). The listed rows didn't change for the next 7.1 s, and a turn in that window still priced **$4.00 / $16.00 per M**: a download stays inactive until the Gateway adopts it. 3. A long turn was admitted on the older catalog, then `models.list {refresh:true}` returned the older rows (extra kimi row still listed) and started adoption. The new catalog was visible 0.9 s later, while the long turn was still running: the extra kimi row was gone. 4. The in-flight turn finished at **$4.00 / $16.00 per M** (older rows and prices). The next turn priced **$0.40 / $1.60 per M** (real catalog). 5. `models.catalogRefresh.url` was moved to a local mirror of the real catalog through `config.patch`, and the mirror's catalog was adopted without a restart. The mirror then served malformed JSON: `models refresh` failed with `SyntaxError`, the model list was unchanged, and the next turn still priced $0.40 / $1.60 per M. **Model picker during republication (also on `main`).** Right after the new generation commits, `models.list` shows the new generation's configured and static rows until its full catalog loads, then the full list. In the live run this lasted 109 ms. The same poller against a `main` build shows the same window after a `models.*` config reload (20 → 6 → 16 rows for about 350 ms), so this PR adds a new trigger for an existing behavior. It doesn't change it. The short list comes from the new generation, so rows and prices stay paired. **Published-driver upgrade cells.** Candidate tarball built from a fresh clone at `6f682c7944e` with the canonical Docker packaging script and no build-time overrides. sha256 `46d881a0…ef0ad`; embedded commit `6f682c7944e2`, version 2026.9.7. `6f682c7944e` already includes the shutdown-cancellation and pricing-deadline commits. The current head the current head differs from it only by rebases onto `main`: `main` had moved the scheduled catalog check into `update-startup-catalog.ts`, and this PR's adoption call moved there unchanged (`git range-diff` shows no other production change; a `remoteCatalog: null` test-fixture field moved to main's relocated `cli-compaction.test-support.ts`). | Driver → candidate | Scenario | Result | |---|---|---| | `[email protected]` | base | passed (930 s); updater outcome success, no recovery | | `[email protected]` | plugin-deps-cleanup | passed (923 s); updater outcome success, no recovery | | `[email protected]` (latest) | base | passed (813 s); updater outcome success, no recovery | In every cell: - Migration, post-Doctor config validation, survival, plugin-dependency cleanup and runtime-deps repair checks passed. - The candidate Gateway logged ready, then its catalog check fetched and saved the hosted catalog about 0.2 s after starting. The hosted catalog is older than the candidate's build stamp, so adoption ends `unchanged`, which isn't logged. After a 300 s settlement window, `/readyz` (`ready:true`, nothing failing) and a Gateway `status` RPC passed, and the Gateway shut down cleanly. - To show a logged terminal outcome, each cell was repeated with a loopback mirror serving a newer copy of the same catalog. Each check logged `remote model catalog applied` about 0.26 s after it started, followed by `/readyz` and `status` passing. Not run: `[email protected]` plugin-deps-cleanup. At the previous head it failed inside the 2026.9.7 driver's retained-runtime verification (`Retained runtime entry does not reference its inventoried file: dist/a2ui-…mjs`), identically for a merge-base control package with none of this PR's commits. Harness note for the 2026.9.7 cell: unchanged, the upgrade harness can't run against 2026.9.7. It seeds the retired `tools.toolSearch {mode:"code"}` setting, which 2026.9.7 rejects. The 2026.9.7 cell used the harness's existing Tool Search "absent" mode, a one-line local change that skips only that seed and its check. The 2026.9.6 cells used the unchanged harness. **CI:** fully green on the final head ([run 36818367970](https://github.com/openclaw/openclaw/actions/runs/36818367970)). Earlier heads hit failures that reproduce on `main` in code this PR doesn't touch: `update-cli.target-schema` (main reproduction: #158000 (comment)), the type-suppression inventory, the Windows partition owner test and the Windows backup-rename test. Main has since fixed the last three. Config compatibility confirmation: #158000 (comment). No overlap with Pash/Sarah changes. Co-authored-by: Ayaan Zaidi <[email protected]>
…nclaw#158000) Related: openclaw#140086, openclaw#141885, openclaw#156535, openclaw#157838 ## What Problem This Solves A running Gateway doesn't see a newly downloaded hosted model catalog until it restarts. This PR publishes each accepted catalog through the existing prepared-runtime owner, without a restart. Model rows and their prices switch together as one generation, which keeps the invariant from openclaw#140086. ## User Impact - Compatible downloads are adopted at the Gateway's background catalog check, or after an explicit `models.list` refresh. That refresh returns the currently accepted rows right away and runs adoption afterward. - A turn admitted on catalog N keeps N's rows and prices until it finishes. New turns use N+1. Rows and prices are never mixed. - A concurrent auth or config publication no longer postpones adoption to the next scheduled check (up to 6 h). Adoption waits for that publication to settle, then retries, up to 3 attempts. - An owner whose build failed or timed out ends the adoption instead of waiting on unbounded work. Gateway shutdown cancels an adoption that is still preparing. - Malformed, schema-invalid, too-new (`minVersion`) and older catalogs are rejected, and the previously accepted catalog stays in use. - Changing `models.catalogRefresh.url` no longer needs a restart: the previous source's catalog stops applying, and the mirror's catalog is adopted at the next catalog check. **Bad-catalog exposure:** with live apply, a *valid but wrong* published catalog reaches running Gateways at their next catalog check (at most every 6 h) or on the next explicit `models.list` refresh. It no longer waits for a restart. Recovery uses existing mechanisms only: - Republish a corrected catalog with a newer `generatedAt`; Gateways adopt it the same way. - Operators can set `models.catalogRefresh.enabled: false`, which withdraws remote rows and prices without a restart (covered by the Gateway integration test). This PR adds no new kill switch, config option or env knob. ### Compatibility No config keys, defaults, types, validation, stored rows, protocol or SDK contracts change. The only config-surface change is the `models.catalogRefresh.url` help text, which drops the stale "Changes apply after a Gateway restart" sentence, and its regenerated config-doc baseline hash. Existing configs validate unchanged and need no Doctor migration (maintainer confirmation: openclaw#158000 (comment)). Startup behavior is unchanged. Upgrade impact for existing installs: an accepted download activates at the next catalog check instead of the next restart. ## Why This Change Was Made - `prepared-model-runtime.configured-refresh.ts` builds a complete candidate generation of the configured owners under the new catalog. One serialized commit then publishes rows, the accepted bundle, the pricing context and the reply-dispatch projection together. - Adoption re-reads the stored catalog until the config it read under is still current, so a stale caller can't cancel a current adoption. - Each preparation attempt has its own abort signal. A config advance restarts only the attempt; a newer catalog or shutdown ends the whole adoption, including pricing preparation. - Between attempts, adoption waits only on publication gates: a pending replacement or an owner's pending publication. - Adopted owners install the same plugin-retirement recovery as configured publication (openclaw#161267). After commit, a lost Gateway plugin loan republishes them through the normal recovery. Before commit, it restarts the adoption attempt, and the commit refuses any candidate whose plugin generation retired. ### Why downloads were restart-only, and what this keeps Restart-only activation was a mechanism, not the goal. openclaw#140086 chose it to stop rows and prices from different catalog versions mixing, and openclaw#157838 was merged as "the prerequisite for applying new remote catalogs without a Gateway restart (rows and prices must switch together)". This PR is that follow-up. Every requirement those PRs set still holds: | Original requirement | Source | How it holds here | |---|---|---| | Rows and prices from one catalog version; never mixed across reloads or new requests | openclaw#140086 | One serialized commit publishes owners, bundle, pricing context and dispatch; pricing contexts are keyed by the exact accepted catalog. Integration test: new rows appear only with new prices | | Admitted work keeps its pair | openclaw#140086, openclaw#157838 | Runs carry their plugin generation's catalog; usage operations capture one pricing context. Integration test and live proof: the in-flight turn keeps the old price | | Startup absence is a real state (no downloaded rows without prices) | openclaw#140086 | Absence → catalog goes through the same atomic commit; overlay absence tests unchanged | | Worker replacement inherits the host's accepted pair, not a later download | openclaw#140086 | The commit updates the inherited pair; later workers and a worker-exit recovery keep it (overlay and integration tests) | | Current enablement and source URL still gate eligibility | openclaw#140086, openclaw#156535 | Checked on every read and before adoption, including the default-install v1 fallback; disablement withdraws rows and prices together (integration test) | | Bad or superseded downloads never replace the active pair | openclaw#140086, openclaw#141885 | Compatibility, `minVersion`, revision and `generatedAt` checks; stale reads can't cancel a current adoption (regression test) | | Failed catalog checks retry at the remaining fresh interval, not a full TTL | openclaw#141885 | Unchanged scheduler behavior; the deleted notice test's retry case is restored for failed adoption (fails if the retry falls back to the full TTL) | | Operators learn when a downloaded catalog is not yet active | openclaw#141885 | No longer needed: downloads activate at the next check. The restart notice and its tests are removed; `models refresh` says when a running Gateway applies the update | | Billing-route prices switch with their rows | openclaw#156535 | `upstreamPricing` and `providerPricing` are part of the accepted catalog pair | ## Evidence **Regressions.** Each fails with its fix reverted and passes with it: - *Retries a scheduled adoption when its pending auth owner settles.* Runs through the real Gateway update scheduler. Reverted, it logs `remote model catalog check superseded; deferred to the next check`. - *Does not let a read under a superseded config cancel the current adoption.* Reverted, both calls end `superseded`. - *Ends adoption instead of joining a timed-out owner build.* Reverted, adoption never settles. - *Does not hold Gateway shutdown on an adoption's pricing preparation.* Reverted, shutdown waits on the held preparation until the test times out. - *Recovers adopted owners when their borrowed Gateway plugin retires after commit / before commit.* Without the recovery, both fail: `Prepared model runtime plugin generation retired` and `prepared reply dispatch runtime owner was not published`. - *Uses the remaining stored TTL after a fresh startup check when adoption fails.* With the retry reverted to the full TTL, the second check doesn't run. **Suites:** | Suite | Result | |---|---| | `prepared-model-runtime.remote-publication.test.ts` | 10/10 | | Gateway integration (`models-list.remote-catalog`) | v1 and v2 pass. Config and auth churn during preparation end `published` on the settled owners. Also covers retained admitted runs, rejected and stale bundles, worker replacement and disablement | | `prepared-model-runtime*`, `server-plugin-reload*`, `update-startup`, and all PR-touched test files | pass | | `tsgo:core`, all `tsgo:test:src` shards | pass | | oxlint and oxfmt on changed files; `config:docs:check`, `config:schema:check`; max-lines, assertion-safety and test-timeout-race ratchets | pass | Tests wait on owned completion signals (`withinTest`), not wall-clock deadlines. **Live proof** on an isolated Gateway built from `cb8c9197fdc` (no provider mocks). Later commits add plugin-retirement recovery for adopted owners, covered by the regression tests above, and rebases onto `main`. It used a real OpenAI key through `openai/gpt-4.1-mini`, and the build stamp was set before the real catalog's publication date. A client polled `models.list` back to back over one WebSocket for the whole run (1023 polls, no errors). One Gateway process (PID unchanged) and no restart: 1. The stored catalog was seeded with an older revision of the real `catalog.openclaw.ai` v2 catalog: generated 2 days earlier, `gpt-4.1-mini` priced ×10, plus one extra kimi row. `models.list` listed the extra row, and a turn priced **$4.00 / $16.00 per M** input/output. 2. `openclaw models refresh` downloaded the real catalog (`updated`, 1039 models). The listed rows didn't change for the next 7.1 s, and a turn in that window still priced **$4.00 / $16.00 per M**: a download stays inactive until the Gateway adopts it. 3. A long turn was admitted on the older catalog, then `models.list {refresh:true}` returned the older rows (extra kimi row still listed) and started adoption. The new catalog was visible 0.9 s later, while the long turn was still running: the extra kimi row was gone. 4. The in-flight turn finished at **$4.00 / $16.00 per M** (older rows and prices). The next turn priced **$0.40 / $1.60 per M** (real catalog). 5. `models.catalogRefresh.url` was moved to a local mirror of the real catalog through `config.patch`, and the mirror's catalog was adopted without a restart. The mirror then served malformed JSON: `models refresh` failed with `SyntaxError`, the model list was unchanged, and the next turn still priced $0.40 / $1.60 per M. **Model picker during republication (also on `main`).** Right after the new generation commits, `models.list` shows the new generation's configured and static rows until its full catalog loads, then the full list. In the live run this lasted 109 ms. The same poller against a `main` build shows the same window after a `models.*` config reload (20 → 6 → 16 rows for about 350 ms), so this PR adds a new trigger for an existing behavior. It doesn't change it. The short list comes from the new generation, so rows and prices stay paired. **Published-driver upgrade cells.** Candidate tarball built from a fresh clone at `6f682c7944e` with the canonical Docker packaging script and no build-time overrides. sha256 `46d881a0…ef0ad`; embedded commit `6f682c7944e2`, version 2026.9.7. `6f682c7944e` already includes the shutdown-cancellation and pricing-deadline commits. The current head the current head differs from it only by rebases onto `main`: `main` had moved the scheduled catalog check into `update-startup-catalog.ts`, and this PR's adoption call moved there unchanged (`git range-diff` shows no other production change; a `remoteCatalog: null` test-fixture field moved to main's relocated `cli-compaction.test-support.ts`). | Driver → candidate | Scenario | Result | |---|---|---| | `[email protected]` | base | passed (930 s); updater outcome success, no recovery | | `[email protected]` | plugin-deps-cleanup | passed (923 s); updater outcome success, no recovery | | `[email protected]` (latest) | base | passed (813 s); updater outcome success, no recovery | In every cell: - Migration, post-Doctor config validation, survival, plugin-dependency cleanup and runtime-deps repair checks passed. - The candidate Gateway logged ready, then its catalog check fetched and saved the hosted catalog about 0.2 s after starting. The hosted catalog is older than the candidate's build stamp, so adoption ends `unchanged`, which isn't logged. After a 300 s settlement window, `/readyz` (`ready:true`, nothing failing) and a Gateway `status` RPC passed, and the Gateway shut down cleanly. - To show a logged terminal outcome, each cell was repeated with a loopback mirror serving a newer copy of the same catalog. Each check logged `remote model catalog applied` about 0.26 s after it started, followed by `/readyz` and `status` passing. Not run: `[email protected]` plugin-deps-cleanup. At the previous head it failed inside the 2026.9.7 driver's retained-runtime verification (`Retained runtime entry does not reference its inventoried file: dist/a2ui-…mjs`), identically for a merge-base control package with none of this PR's commits. Harness note for the 2026.9.7 cell: unchanged, the upgrade harness can't run against 2026.9.7. It seeds the retired `tools.toolSearch {mode:"code"}` setting, which 2026.9.7 rejects. The 2026.9.7 cell used the harness's existing Tool Search "absent" mode, a one-line local change that skips only that seed and its check. The 2026.9.6 cells used the unchanged harness. **CI:** fully green on the final head ([run 36818367970](https://github.com/openclaw/openclaw/actions/runs/36818367970)). Earlier heads hit failures that reproduce on `main` in code this PR doesn't touch: `update-cli.target-schema` (main reproduction: openclaw#158000 (comment)), the type-suppression inventory, the Windows partition owner test and the Windows backup-rename test. Main has since fixed the last three. Config compatibility confirmation: openclaw#158000 (comment). No overlap with Pash/Sarah changes. Co-authored-by: Ayaan Zaidi <[email protected]>
…173792) ## What Problem This Solves Fixes: usage reports show Claude CLI traffic (for example `claude-cli/claude-opus-5-5`, the default CLI model) as "Unpriced", because the CLI reports no cost and the `claude-cli` catalog has no priced rows. ## User Impact Usage views now estimate Claude CLI usage at Anthropic's API rates, as subscription routes such as Kimi Code already do. The figures are estimates of what the API would cost, not plan charges. Prices apply right away, offline included, from the bundled Anthropic catalog rows, with no catalog publish needed. A Claude CLI turn that used 1h prompt caching is now priced like the CLI's own cost figure. ## Why This Change Was Made Since #168728, Claude CLI models come from the CLI's own menu with zero placeholder costs. Since #156535, estimates use the provider that handles the request, so `claude-cli/*` never picks up the `anthropic/*` rows. - **`priceAs`:** a new `modelPricing` provider field names the provider whose catalog rows price this provider's models when it has no price of its own. `resolveModelPricing` tries that provider's row for the same model, one hop only. A provider's own catalog or hosted price still wins. - Plugin manifests already let `cliBackends` own `modelCatalog` rows. `modelPricing` now accepts them too. - The anthropic manifest declares `claude-cli: { priceAs: "anthropic" }`. - Each model has one price fact, and nothing extra is published to the hosted catalog. - **1h cache writes:** Claude Code splits cache writes by TTL (`cache_creation.ephemeral_1h_input_tokens`). `normalizeUsage` read only the camelCase `cacheWrite1h`, so CLI turns lost the 1h subset and would have been priced at the 5m rate. `normalizeUsage` now reads the split, and CLI usage records and persisted transcript usage carry it to the existing calculator. ## Evidence - **End to end through the shipped Gateway (`openclaw gateway usage-cost`).** - Setup: - an isolated state and a build of this branch; - one real `openclaw agent --local` turn on `anthropic/claude-opus-5-5` through the `claude-cli` runtime; - a synthetic `claude` executable that answered with the repo's spawn-proof protocol and reported 1,000,000 input and 100,000 output tokens with no cost. No provider request was made. | Catalog state | `usage-cost` | |---|---| | Today's live hosted catalog (0 `claude-cli/*` keys), loaded with `openclaw models refresh` | `Total: $6.00 · 1.1m tokens` | | Catalog refresh disabled (bundled manifest rows only) | `Total: $6.00 · 1.1m tokens` | | Earlier revision's baseline, with no CLI pricing | `$0.0000`, `Missing cost: 1 (claude-cli/claude-opus-5-5 1)` | - **1h cache writes against the CLI's own cost:** - **Recorded Claude 2.1 turn** (`test/fixtures/cli/claude-2.1-thinking-progress.jsonl`): it now prices at $0.40499, equal to the CLI's `costUSD`. Before the fix it priced at $0.26641. - **35 real Claude Code sessions on one install:** catalog rates with the 1h split reproduce the CLI's total `costUSD` exactly ($2.5640). Pricing every write at the 5m rate gives $1.763. - **Tests:** - Resolver: `claude-cli/claude-opus-5-5` resolves to the `anthropic` row, and a `claude-cli` hosted price wins over the mapping. The mapping test fails without the fallback. - Manifest: `priceAs` is normalized for a CLI backend and dropped for an unowned id. - CLI usage: parsing and transcript persistence keep `cacheWrite1h`. The transcript test fails without the carry-through. - Pricing, manifest, bundled-manifest contract, session-cost and CLI output suites pass (114 tests). - The catalog publisher is unchanged. Its two local `second rename failure` cases also fail on main on this machine. - **Gap (by design):** for tiered models such as `claude-haiku-5-5`, a multi-call turn whose summed prompt passes the 100k tier boundary stays unpriced. Whole-turn counters cannot show each call's tier. - **Gap:** a per-agent `models.json` written by older versions can still hold frozen `claude-cli` rows, including zero costs. Those rows outrank the catalog. #174641 removes them. **Merge risk:** - A two-way door: a revert removes the field and the mapping. No state is written. - It adds an optional `priceAs` field to the published `modelPricing` manifest contract and lets `cliBackends` declare pricing policies. Only the Anthropic plugin uses either. - Blast radius: cost estimates for Claude CLI sessions. Routing and billing do not change. Co-authored-by: Ayaan Zaidi <[email protected]>
…penclaw#173792) ## What Problem This Solves Fixes: usage reports show Claude CLI traffic (for example `claude-cli/claude-opus-5-5`, the default CLI model) as "Unpriced", because the CLI reports no cost and the `claude-cli` catalog has no priced rows. ## User Impact Usage views now estimate Claude CLI usage at Anthropic's API rates, as subscription routes such as Kimi Code already do. The figures are estimates of what the API would cost, not plan charges. Prices apply right away, offline included, from the bundled Anthropic catalog rows, with no catalog publish needed. A Claude CLI turn that used 1h prompt caching is now priced like the CLI's own cost figure. ## Why This Change Was Made Since openclaw#168728, Claude CLI models come from the CLI's own menu with zero placeholder costs. Since openclaw#156535, estimates use the provider that handles the request, so `claude-cli/*` never picks up the `anthropic/*` rows. - **`priceAs`:** a new `modelPricing` provider field names the provider whose catalog rows price this provider's models when it has no price of its own. `resolveModelPricing` tries that provider's row for the same model, one hop only. A provider's own catalog or hosted price still wins. - Plugin manifests already let `cliBackends` own `modelCatalog` rows. `modelPricing` now accepts them too. - The anthropic manifest declares `claude-cli: { priceAs: "anthropic" }`. - Each model has one price fact, and nothing extra is published to the hosted catalog. - **1h cache writes:** Claude Code splits cache writes by TTL (`cache_creation.ephemeral_1h_input_tokens`). `normalizeUsage` read only the camelCase `cacheWrite1h`, so CLI turns lost the 1h subset and would have been priced at the 5m rate. `normalizeUsage` now reads the split, and CLI usage records and persisted transcript usage carry it to the existing calculator. ## Evidence - **End to end through the shipped Gateway (`openclaw gateway usage-cost`).** - Setup: - an isolated state and a build of this branch; - one real `openclaw agent --local` turn on `anthropic/claude-opus-5-5` through the `claude-cli` runtime; - a synthetic `claude` executable that answered with the repo's spawn-proof protocol and reported 1,000,000 input and 100,000 output tokens with no cost. No provider request was made. | Catalog state | `usage-cost` | |---|---| | Today's live hosted catalog (0 `claude-cli/*` keys), loaded with `openclaw models refresh` | `Total: $6.00 · 1.1m tokens` | | Catalog refresh disabled (bundled manifest rows only) | `Total: $6.00 · 1.1m tokens` | | Earlier revision's baseline, with no CLI pricing | `$0.0000`, `Missing cost: 1 (claude-cli/claude-opus-5-5 1)` | - **1h cache writes against the CLI's own cost:** - **Recorded Claude 2.1 turn** (`test/fixtures/cli/claude-2.1-thinking-progress.jsonl`): it now prices at $0.40499, equal to the CLI's `costUSD`. Before the fix it priced at $0.26641. - **35 real Claude Code sessions on one install:** catalog rates with the 1h split reproduce the CLI's total `costUSD` exactly ($2.5640). Pricing every write at the 5m rate gives $1.763. - **Tests:** - Resolver: `claude-cli/claude-opus-5-5` resolves to the `anthropic` row, and a `claude-cli` hosted price wins over the mapping. The mapping test fails without the fallback. - Manifest: `priceAs` is normalized for a CLI backend and dropped for an unowned id. - CLI usage: parsing and transcript persistence keep `cacheWrite1h`. The transcript test fails without the carry-through. - Pricing, manifest, bundled-manifest contract, session-cost and CLI output suites pass (114 tests). - The catalog publisher is unchanged. Its two local `second rename failure` cases also fail on main on this machine. - **Gap (by design):** for tiered models such as `claude-haiku-5-5`, a multi-call turn whose summed prompt passes the 100k tier boundary stays unpriced. Whole-turn counters cannot show each call's tier. - **Gap:** a per-agent `models.json` written by older versions can still hold frozen `claude-cli` rows, including zero costs. Those rows outrank the catalog. openclaw#174641 removes them. **Merge risk:** - A two-way door: a revert removes the field and the mapping. No state is written. - It adds an optional `priceAs` field to the published `modelPricing` manifest contract and lets `cliBackends` declare pricing policies. Only the Anthropic plugin uses either. - Blast radius: cost estimates for Claude CLI sessions. Routing and billing do not change. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #156507
What Problem This Solves
Fixes wrong cost estimates when OpenRouter runs a promotion: OpenRouter's price list was treated as every vendor's price list, so OpenAI direct and the Vercel, Kilo and Cloudflare gateways all showed OpenRouter's discounted rate. It also moves clients to the smaller v2 hosted catalog.
User Impact
Cost estimates now use the price of whoever bills the request. During OpenRouter's current 50% promotion on
openai/gpt-5.6-sol, OpenAI direct, Vercel, Kilo and Cloudflare show $4/$20 per million tokens instead of $2/$10, while OpenRouter keeps $2/$10.Clients download
/models/v2/catalog.jsonby default: 1.6 MB instead of v1's 3.0 MB. Prices for models outside the catalog, such as gateway routes and older model IDs, still resolve. Released clients keep reading v1, which the same publisher run keeps in step.Existing installs keep their downloaded catalog across the upgrade, including offline default installs whose stored catalog came from the v1 default URL. Subscription routes such as Kimi Code keep showing pay-as-you-go estimates.
After merge, the catalog repository's publish run regenerates both feeds from
main, so released clients also receive the corrected prices through v1. 762 keys stop resolving; the route audit below shows none is a supported route with a vendor or gateway price.Rollout (maintainer decision: land as one PR): the hosted v2 file gains
upstreamPricing/providerPricingon the first publish after merge (every 4 hours). Released clients read v1 and are unaffected. Onlymain/nightly builds that download v2 before that publish briefly lack estimates for routes outside catalog rows; the next publish restores them.Why This Change Was Made
upstreamPricingholds each vendor's rate once, with its source, instead of v1's per-gateway copies.providerPricingholds a provider's own rate.modelsDevsource prices each provider from its own models.dev entry, reusing the models.dev download the publisher already makes. The entry is chosen by the plugin's existingmodelCatalog.modelsDevmapping or itsmodelsDev.providerpolicy.openrouter/*keys.304adopts the older client's row only when that row, read inside the same write transaction, matches the revalidated one; otherwise the v2 slot stays empty. The older slot is never written.Evidence
Pricing, through
resolveModelCostConfig:openai/gpt-5.6-sol, OpenAI, Vercel, Kilo and Cloudflare now resolve $4/$20, and OpenRouter keeps $2/$10. The references are OpenRouter's endpoint list (discount: 0.5), models.dev, Vercel's and Kilo's live model lists, and Cloudflare's Unified Billing docs.google/gemini-3.5-flashnow matches Kilo's live $0.75/$4.5, and Qwen routes use Alibaba's pay-as-you-go rate), 120 newly priced, 762 no longer priced.:batch), which no OpenClaw route sends.~vendor/…-latestaliases, dotted Anthropic IDs (claude-opus-4.5; Anthropic's API uses dashes), and OpenRouter variants such asopenai/gpt-5.6-sol-prothat neither the vendor's own list nor the catalog contains (OpenAI direct already had no price for them). None is a vendor catalog row. One (inclusionai/ling-3.0-flash-fin) is in Vercel's live model list and is priced by Vercel's runtime discovery.kimi-k2*,claude-opus-4-1,claude-sonnet-4, Gemma, image variants), OpenRouter-style IDs,zai/glm-4.7-flash(free on Z.ai; the old number was OpenRouter's), andqwen/qwen3-coder-next(only Coding Plan at $0 and resellers list it).moonshotai) are also keyed by that slug, so gateway pass-through finds them.Real clients against a local mirror of the new feeds:
304, and its built Gateway started with v2 stored.schemaVersion: expected 1, exit 1). A rejected v2 fetch left their stored v1 intact.Upgrade:
304, with no full download, and copied it into the v2 slot. The older client's slot was unchanged.catalog.openclaw.ai/models/v1catalog into fresh state. This PR's code then served that row under the default config, refused it for a configured mirror, and on a mismatched check left the v2 slot empty and the v1 slot byte-identical.openclaw update --tag <candidate tarball> --yes --no-restartonto the package built from2582b9dd; the final head adds only a price-projection fix inremote-bundle.tsand its test, with no update, Doctor or storage changes. All 11 steps exited 0: global update, candidate migration rehearsal, Doctor lint, config validation, plugin resolution, migration continuation, Gateway canary, install swap,openclaw doctor, service reconciliation, and post-plugin Doctor lint. The candidate Gateway then stored the live v2 feed (schema 2, same generation) in its own slot. The v1 slot's bytes were identical (same SHA3) before the update, after it, and after the Gateway ran.Tests: regressions cover:
304(both fail on the previous head)Publisher, catalog, pricing, session-cost, usage-format, Gateway startup and state-database suites pass.
Cost,
pnpm test <file> --maxWorkers=1(new or changed files; mostly transform time on a cold cache):packages/model-catalog-core/src/remote-catalog-bundle.test.tstest/scripts/publish-model-catalog-v2.test.tssrc/model-catalog/pricing.routing.test.tssrc/model-catalog/pricing.v2.test.tssrc/model-catalog/remote-overlay.test.tssrc/model-catalog/pricing.v2-standalone.test.tssrc/model-catalog/remote-store.test.tssrc/model-catalog/remote-refresh.test.tssrc/infra/session-cost-usage.test.tstest/scripts/publish-model-catalog.test.tssrc/model-catalog/pricing.test.tssrc/gateway/server.catalog-startup.test.tsserver.catalog-startup.test.tsis over 30 s because it boots a real Gateway, which it already did before this PR; this PR only updates its fixture URL and expected prices.Checks:
Review: an independent pricing audit and code reviews. Their findings were fixed, except the follow-ups below.
Follow-ups, not in this PR:
_above_Nk_tokens) are dropped.