Repository navigation
feat: refresh ClawRouter models through shared Model Core - #413
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
⛔ Files ignored due to path filters (6)
📒 Files selected for processing (5)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk | ⚪ Minimal · up to
|
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 72.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 12 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
-
Check name Status Explanation Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request. Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled. Title check ✅ Passed The title clearly summarizes the main change: refreshing ClawRouter models through the shared Model Core catalog.
- Fix all pre-merge checks with AI
✨ Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Autopilot is currently an internal CodeRabbit preview.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
VickyXAI
left a comment
There was a problem hiding this comment.
Thanks. Almost all of the diff is dist/ chunk renumbering (the source change is about 670 lines). The design holds up: prices come only from the active gateway's listing, aliases and FREE_MODELS order are untouched, models the gateway adds are never Auto candidates, and the API key is scoped to apiBase with redirect:"error". I checked the projection against live Base and Sol data today. Prices match the gateway exactly, and nothing throws. Two things block the merge.
Blocking
- A gateway listing can switch off the strict cost cap.
model-catalog.ts:82adds anybilling_mode === "free"row tofreeIds. Only free → paid is guarded (L47–49); paid → free, and new free rows, are not. Once rebased onto v0.12.283,isFreeModel = catalog.freeIds.has(modelId)sends the request to non-strictSessionSpend.track. The signing hook then returns early (if (!spend?.isStrict) return;), so the 402 quote is never checked againstmaxCostPerRun. The balance preflight is skipped too. The listing and the 402 quote are produced separately and have disagreed before (blockrun-sol#406). Please keep cap and balance gating on the product-ownedfree/*ids, or keep the strict quote check active for "free" models. Add a test where a model the catalog lists as free gets a non-zero 402 quote. - Rebase onto v0.12.283.
src/proxy.tsconflicts at the three success-path sites, which are nowsessionSpend.recordSuccess(...). Usecatalog.freeIdsand the catalogestimate()there. Main'sFREE_MODELS/estimateAmountwould record no spend for models the catalog added. Then rebuilddist/and re-run your paid end-to-end test.
Follow-ups
- Please drop the GitHub policy fetch, or pin it to a commit SHA. Right now it fetches
raw.githubusercontent.com/.../mainevery 5 minutes from every install. That is a mutable trust input and it shows GitHub every running proxy, while in ClawRouter it only reorders models that would be visible anyway. refreshhas an emptycatch {}, so a failed refresh (for example the free → paid throw) freezes the catalog with no log. Also, the timer interval equals the TTL and expiry is set after the fetch completes, so every other tick is a cache hit that still rebuilds the view and re-syncsopenclaw.json.- On every gateway start,
injectModelsConfigandonCatalogUpdatedwrite two different model lists toopenclaw.json, one after the other.
VickyXAI
left a comment
There was a problem hiding this comment.
Thanks. A few things need to change before this can merge:
- The model list is fetched every 5 minutes from a file on the
mainbranch of a public GitHub repo. Anyone with push access there controls what models ClawRouter users see. Please pin to a signed or content-hashed release (or a commit SHA) and fall back to the bundled list if verification fails. - Prices from that feed override ClawRouter's built-in prices, and the spending caps are computed from them. A remote feed must not be able to lower or raise a cap. Keep prices local, or only accept remote prices within a bounded range of the built-in ones.
- The compiled
dist/diff is about 54k lines and was built from code as of Oct 3, so it can't be reviewed and doesn't match current main. Please dropdist/from the PR; we'll build it in release.
…alog # Conflicts: # dist/cli.js # dist/cli.js.map # dist/index.d.ts # dist/index.js # dist/index.js.map # src/proxy.ts
… policy fetch; visible refresh failures Review of #413, finished in-house: - A gateway listing could switch off the strict maxCostPerRun cap: any row with billing_mode "free" joined freeIds, and free skips cap admission, the signing-time quote check and the balance preflight. The listing and the 402 quote come from different code paths and have disagreed before. freeIds is now ClawRouter's own free/* products only; a gateway-free model is priced at 0, so its estimates are 0 and the signing hooks check its real quote. proxy.catalog-free-cap.test.ts pins it (fails with the old line back). - The policy file is no longer fetched from a mutable GitHub branch every few minutes by every install; the bundled snapshot orders new models. BLOCKRUN_MODEL_CATALOG_URL still opts in. - Refresh failures are logged once per distinct error instead of swallowed, so a frozen catalog is visible. - A refresh whose content did not change keeps the same view object, so the proxy no longer rebuilds routing and rewrites openclaw.json every tick; the cache TTL is now shorter than the refresh interval.
|
Thanks for this. Rather than send it back to you, we finished the review items in-house and merged it with your commits kept as they are:
Full suite passes (1205 tests) and CI is green. It ships in the next release, with you credited in the changelog. |
ClawRouter currently requires a catalog release to expose each upstream chat model. This change bundles the shared
@blockrun/model-catalogruntime and refreshes metadata from the active gateway at startup and every five minutes. New chat models appear in/v1/models, the OpenClaw provider/allowlist, and per-agent model caches; updated prices feed routing estimates and spend-cap checks.The runtime is pinned to immutable commit
465c45941fb8ea9d6858fe8402abc8ba8934be90(BlockRunAI/model-catalog#2). That Core fix is now merged, so this dependency is satisfied. The package version remains unchanged; this PR does not publish a release.Behavior and boundaries
Validation
0c1d1ba027fe9fd85ae10fe7ca525c3422012e70: Build & Test, Lint & Typecheck, Desktop, and scanner all passed. The initial run exposed a random-port collision in the existing proxy-reuse fixture; it now reserves its listener through the OS and avoids public gateway requests, and the rerun passed.0c1d1ba027fe9fd85ae10fe7ca525c3422012e70: 6/6 paid requests passed. On both Base and Solana, a live-discovered model absent from the static registry (poolside/laguna-s-2.1) returned the exact test marker; GPT-6 Luna completed a two-request streaming tool-call/result round trip. Every request returned a successful payment receipt and had a successful transaction independently checked via chain RPC. Wallet deltas matched signed quotes exactly: Base $0.006, Solana $0.003; total $0.009. Per-payment cap $0.05; total test cap $0.50. No credentials, wallets, signatures or transaction identifiers are published.Review status and known limits
Independent preliminary source review covered the initial source diff and supporting credential/payment boundaries; its cache-sync and reasoning-metadata observations were fixed and retested. The managed security scan could not generate its inventory (
could not read committed diff blob ...:package.json, despite the blob resolving locally). It remains incomplete: this PR does not claim a completed security scan or zero vulnerabilities.The 2026-10-02 npm audit snapshot reported 26 affected-package entries (4 high, 5 moderate, 17 low, 0 critical). Every advisory-affected lockfile entry is identical to the base revision. The only new package is the shared catalog, which has no runtime dependencies. Existing dependency remediation remains separate from this catalog integration.
Summary by CodeRabbit
2026-10-03 main sync
Merged current main
14d20acinto this branch as3944cfa2f58326103c99506359d317580df1acfc, resolving the new proxy/bundle conflicts while preserving upstream outcome-memory behavior and the catalog-based free-model fallback check. Full local regression (1,139 tests plus 5 lifecycle tests), typecheck, lint, formatting, build and distribution smoke checks passed. GitHub now reports the PR mergeable; CI is rerunning on this commit. The real paid evidence above remains explicitly tied to the previously tested0c1d1barevision.