Skip to content

refactor(models): prepare model-list context once - #130600

Merged
steipete merged 2 commits into
mainfrom
codex/model-list-prepared-context
Aug 27, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/model-list-prepared-context

Conversation

@steipete

@steipete steipete commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

models list rebuilt manifest provider-alias maps during row construction, routed full registry loading through a forwarding module, and wrapped every availability failure in a private error code only to catch that same code and choose one fallback. The command already owns the metadata snapshot and the shared configured-model projection already accepts its canonicalizer.

Why This Change Was Made

Prepare the alias canonicalizer once in the command and carry it into configured refs and row builders. Consolidate full and targeted registry access under list.registry.ts; remove the forwarding module, unused CLI availability options, redundant lazy-loader functions, and the private error-code stack. Share row input projection and make synchronous row assembly synchronous.

Production: +110/-306 (net -196). Tests: +138/-119 (net +19). Assertion baseline: +1/-2, shrinking the allowance for two deleted casts. No config keys/defaults, public flags, plugin SDK contracts, provider policy, credentials, network discovery, or persistence changes.

User Impact

No intended output change. Default listing remains lazy; --local keeps targeted configured lookups, while full/provider-filtered lists use the prepared registry. Discovery and configured lookup errors remain fatal. Failed/malformed availability yields one visible warning and auth heuristics; an empty availability result remains authoritative. Display aliases never replace the source provider used for auth. Provider/model ordering, suppression modes and metadata stay unchanged.

Evidence

  • Read the complete command, row builders/projection, alias preparation, both registry adapters, configured-model owner, auth index, prepared registry, scoped/manifest/persisted catalog readers, adjacent tests and relevant history. fix(models): reduce default model-list memory use #117323 explains the lazy default-list boundary; it is preserved.
  • Before edits: 79 unit/command tests across five files and 22 command E2E tests passed. Added four command-output cases, then ran all 26 against the old implementation successfully. These establish retained behavior, not a claimed bug-fix regression.
  • Existing source-provider auth, replace-mode, aliases, agent-specific metadata, dynamic catalog, suppression, and local filtering tests are retained. The new table covers thrown availability, malformed results, invalid entries and authoritative empty results using fixture auth only.
  • Consolidate repeated row-test context setup into a fresh-per-call fixture with explicit auth inputs; every assertion remains. This keeps the suite below the existing line limit without a suppression. Typechecking also caught and removed the now-unused provider normalizer import.
  • After refactor: all 105 tests across six files passed. Independent Codex autoreview passed, including a final pass after shrinking the assertion baseline.
  • The complete local changed gate passed on final head 6b019aa1f7462bccf6ea775150f6ad84bffee226: production and core-test typechecks, full core type-aware lint, formatting, unused-export scans, assertion ratchets, import cycles and architecture guards. Earlier checks exposed a stale assertion allowance, an unused import and a test-file line-limit violation; all were fixed and the full gate rerun successfully.
  • The CLI-startup build passed all seven phases, including the CLI import guard and 48 built plugin control-plane modules. Actual rebuilt CLI output matches the pre-refactor JSON exactly for all four views: default (2 rows), --all (224), --local (1), and --provider fixture-local (1). The all-model view retains GLM 5.3 Flash's text+image and 1,048,576 context metadata. The earlier full 15-phase build passed on the parent catalog batch. No authenticated inference is claimed for this internal command refactor.
  • A further actual CLI probe with --all --provider Z.AI --json returns six canonical zai/* rows, including zai/glm-5.3-flash with text+image, a 1,048,576 context window and missing: false. Availability is intentionally unknown without credentials.
  • Exact-head CI completed successfully for 6b019aa1f7462bccf6ea775150f6ad84bffee226, including all 65 selected plugin shards. The superseded first-head CI was replaced after the local type/lint fixes described above.
  • After merge, the combined catalog/model-list proof passed all 233 tests across 25 files on updated main 9a86f34e07db385ffd4366e8c15cf1340b8ad3fd. The final PR build's four actual CLI views still match baseline; the relevant model-list/provider source files are unchanged between that build head and the post-merge checkout.
  • Local archive search and live file inspection found perf(gateway): skip provider catalog rewarm on rate limits #125906 targets auth cooldown/session startup surfaces, not these model-list modules; this batch does not overlap that work.

Follow-ups identified by the broader audit: prepared static catalogs still repeat per-row provider setup, and Gateway thinking-profile projection repeats cached/uncached assembly. Those are separate owners with their own lazy-resolution and lifecycle invariants, not part of this command refactor.

@steipete steipete self-assigned this Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: L maintainer Maintainer-authored PR labels Aug 27, 2026
@steipete
steipete marked this pull request as ready for review August 27, 2026 02:17
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 10:32 PM ET / August 27, 2026, 02:32 UTC.

ClawSweeper review

What this changes

The PR prepares provider-alias context once for openclaw models list, consolidates registry access, and removes redundant wrappers while retaining the command’s row-building behavior.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for normal maintainer review: no blocking defect surfaced, but this maintainer-owned, maintainer-labeled refactor must not be auto-closed; merge awaits exact-head checks and confirmation of the latest ClawSweeper rank-up guidance.

Priority: P3
Reviewed head: 6b019aa1f7462bccf6ea775150f6ad84bffee226
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The refactor is coherent and focused with retained-behavior coverage; normal exact-head merge gates remain pending.
Proof confidence 🌊 off-meta tidepool Not applicable: This repository-member PR is exempt from the external-contributor proof gate; its body nevertheless records command-output and focused-test evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This repository-member PR is exempt from the external-contributor proof gate; its body nevertheless records command-output and focused-test evidence.
Evidence reviewed 6 items Command-bound canonicalizer: The command creates the manifest-backed provider canonicalizer once, uses it for configured references, and passes it into every row-builder context.
Registry failure boundary: Full registry loading still treats discovery failure as fatal, while availability failures retain discovered rows and record a fallback warning; targeted configured lookups remain credential-aware.
Row-source invariant: The all-model path still emits registry rows first, then the committed catalog generation, then configured rows; configured/default output still takes the dedicated source path.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw models list --json

Result: PASS (completed)

$ node scripts/run-node.mjs models list --json
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 92.00 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.5s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 10.7s
[plugin-control-plane-loads] verified 36 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 2647ms (slowest: built plugin control-plane loads 2185ms)
{
  "count": 1,
  "models": [
    {
      "key": "openai/gpt-5.6-sol",
      "name": "GPT-5.6 Sol",
      "input": "-",
      "contextWindow": null,
      "local": false,
      "available": false,
      "tags": [
        "default"
      ],
      "missing": false
    }
  ]
}
$ node scripts/run-node.mjs models list --json
{
  "count": 1,
  "models": [
    {
      "key": "openai/gpt-5.6-sol",
      "name": "GPT-5.6 Sol",
      "input": "-",
      "contextWindow": null,
      "local": false,
      "available": false,
      "tags": [
        "default"
      ],
      "missing": false
    }
  ]
}

Assertions:

  • PASS expect_output: models

How this fits together

openclaw models list combines configuration, plugin manifest metadata, credential-aware registry data, and prepared catalogs into terminal table or JSON rows. This refactor carries one prepared provider canonicalizer through those row sources before output is rendered.

flowchart LR
  A[CLI model-list options] --> B[Configuration and target agent]
  B --> C[Manifest metadata snapshot]
  C --> D[Prepared provider alias context]
  D --> E[Registry and catalog rows]
  E --> F[Configured and discovered row projection]
  F --> G[Table or JSON output]
Loading

Decision needed

Question Recommendation
Should this maintainer-owned model-list refactor merge once exact-head checks and the latest ClawSweeper rank-up requirements are satisfied? Merge after review gates: Retain the behavior-neutral consolidation and merge after exact-head checks are green and all current rank-up items are addressed.

Why: The PR is authored by a repository member and carries the protected maintainer label, so automated cleanup must leave the final merge judgment to a maintainer.

Before merge

  • Resolve merge risk (P1) - Exact-head CI is still running, and the latest ClawSweeper comment’s rank-up guidance must be confirmed before landing.
  • Complete next step (P2) - No discrete mechanical repair is needed; this maintainer-owned PR should proceed through ordinary exact-head review and merge gates.
Agent review details

Security

None.

PR surface

Source -196, Tests +19, Other -1. Total -178 across 15 files.

View PR surface stats
Area Files Added Removed Net
Source 9 110 306 -196
Tests 5 138 119 +19
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 2 -1
Total 15 249 427 -178

Review metrics

Metric Value Why it matters
Production versus test delta production +110/-306 (net -196); tests +138/-119 (net +19); guard baseline +1/-2 The refactor materially reduces production code while adding focused retained-behavior coverage rather than expanding a public surface.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep one command-owned alias canonicalizer and the consolidated registry adapter, then merge only after exact-head validation and the current review guidance are satisfied.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep one command-owned alias canonicalizer and the consolidated registry adapter, then merge only after exact-head validation and the current review guidance are satisfied.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this is a refactor rather than a report of broken behavior, and the changed command paths are covered by focused command tests.

Is this the best way to solve the issue?

Yes: preparing immutable alias context at the command boundary and passing it to row builders removes repeated setup without creating a parallel behavior path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c35b18309329.

Labels

Label changes:

  • add P3: This is a behavior-neutral internal cleanup with no reported user-facing regression or new product surface.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This repository-member PR is exempt from the external-contributor proof gate; its body nevertheless records command-output and focused-test evidence.

Label justifications:

  • P3: This is a behavior-neutral internal cleanup with no reported user-facing regression or new product surface.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This repository-member PR is exempt from the external-contributor proof gate; its body nevertheless records command-output and focused-test evidence.

Evidence

What I checked:

Likely related people:

  • steipete: Peter Steinberger authored the current main model-catalog batch refactor and is attributed by blame around the command setup now being simplified. (role: recent model-list refactor author; confidence: high; commits: 89d6ce457ca5, 162e8d139404; files: src/commands/models/list.list-command.ts, src/commands/models/list.registry.ts, src/commands/models/list.rows.ts)
  • vincentkoc: Vincent Koc authored merged PR fix(models): reduce default model-list memory use #117323, which introduced the scoped, lazy model-list behavior this refactor preserves. (role: lazy default-list boundary author; confidence: high; commits: 5ae401d9084f; files: src/commands/models/list.row-sources.ts, src/commands/models/list.list-command.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Confirm the latest ClawSweeper rank-up list and wait for exact-head required checks to complete successfully.

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.

@steipete
steipete merged commit f05a7dd into main Aug 27, 2026
215 of 217 checks passed
@steipete
steipete deleted the codex/model-list-prepared-context branch August 27, 2026 02:48
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
* refactor(models): prepare model-list context once

* test(models): consolidate model-list row contexts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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