Skip to content

fix(cli): defer inference runtimes until command execution - #158624

Merged
steipete merged 2 commits into
mainfrom
tcr/land-p007-1790387341
Sep 26, 2026
Merged

steipete merged 2 commits into
mainfrom
tcr/land-p007-1790387341

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Inference help and shell completion load provider execution, authentication, configuration, and Gateway runtimes while building the command tree. That makes discovery depend on code needed only when an inference command actually runs.

User Impact

Parent help, detailed subcommand help, the capability alias, and shell completion retain their command and option inventory without initializing inference execution runtimes. Existing command execution and provider-selection behavior is preserved.

Why This Change Was Made

Move execution imports into their owning command actions and runners. Extract the existing provider-command registration into a lightweight module so listing the command tree does not import provider configuration. Keep the current main branch's consolidated image registrations, model-provider helper, model catalog handling, account-secret preparation, asynchronous resource disposal, and web exit behavior.

This replays campaign batch p007 (bb21ea50e874af2246183bc5948c5f5420bc1590) onto current main. The related lazy-domain selection change in #140327 does not address eager imports inside domain registrars. Conflicts in audio, image, model, shared, video, and web were resolved toward current main's implementation, then the equivalent import deferral was applied. The retired model-reference wrapper and duplicated image registrations were not restored; current provider-environment APIs were retained. The regression guard also covers the newer account-secret, configuration, and prepared-catalog imports.

The initial changed-file gate caught one counted line of growth in the oversized execution test. Its existing invocation helpers and collection-time subprocess setup now live in a small test harness; helper bodies and all assertions are preserved, and the original file shrinks.

No changed paths match .github/CODEOWNERS.

Evidence

  • Campaign proof: 202 tests passed. Reversing only the production fix made all 10 help/import guards fail for forbidden runtime loads; restoring it made all 10 pass.
  • Fresh Blacksmith Testbox proof at 7fc19c549b8040f8e1416fe3467bb84d234637e4: 320 tests passed across 10 owner and sibling files, covering command execution, help/completion, account-secret preparation, and resource cleanup. The wrapper verified the source SHA and tree before execution. Vitest wall time: 45.38 seconds across three shards with one worker.
  • Current-base negative control: restoring the eight original production modules from da49c7e45c4cbc65642911ebaf05b4b46b0371ae made all 10 guards fail for forbidden runtime imports. Restoring the candidate made all 10 pass; the standalone passing invocation took 1.57 seconds wall time (748 ms in Vitest).
  • pnpm build passed in 8m 14.6s. Its non-fatal UI size report listed startup JS at 363.0 KiB against 362.6 KiB; this batch does not change UI source.
  • The complete changed-file gate passed, including line-growth, formatting, core and five test-type graphs, dead exports, lint, and structural guards. Formatting and git diff --check also passed locally.

Production: +228/-192 lines (net +36). Tests and test support: +154/-30 lines (net +124). Documentation: +4/-0 lines. The production growth comes from moving imports into the execution scopes that own them; no additional execution path is introduced.

Validation commands

Run on Blacksmith Testbox through the repository wrapper:

pnpm install --frozen-lockfile --prefer-offline
pnpm test src/cli/capability-cli.help.test.ts src/cli/capability-cli.test.ts src/cli/capability-cli.lazy.test.ts src/cli/capability-cli/shared.test.ts src/cli/capability-cli/local-account-secrets.test.ts src/cli/capability-cli/local-runners.account-secrets.test.ts src/cli/capability-cli/model.account-secrets.provenance.test.ts src/cli/capability-cli/model.account-secrets.runtime.test.ts src/cli/capability-cli/model.resources.test.ts src/cli/completion-command-tree.test.ts --maxWorkers=1
OPENCLAW_TESTBOX=1 OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 node scripts/check-changed.mjs -- docs/cli/infer.md src/cli/capability-cli.help.test.ts src/cli/capability-cli.test.ts src/cli/capability-cli.test-harness.ts src/cli/capability-cli/audio.ts src/cli/capability-cli/embedding.ts src/cli/capability-cli/image.ts src/cli/capability-cli/model.ts src/cli/capability-cli/providers-command.ts src/cli/capability-cli/shared.ts src/cli/capability-cli/tts.ts src/cli/capability-cli/video.ts src/cli/capability-cli/web.ts
pnpm build

The remote-child flag keeps the already remote changed-file check on its owning Testbox.

@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

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

View the workflow run.

@steipete
steipete enabled auto-merge (squash) September 26, 2026 03:39
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: L labels Sep 26, 2026
@steipete
steipete merged commit c425798 into main Sep 26, 2026
112 of 113 checks passed
@steipete
steipete deleted the tcr/land-p007-1790387341 branch September 26, 2026 03:50
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 26, 2026
…158624)

* fix(cli): defer inference runtimes until command execution

* test(cli): extract inference command test harness
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant