Skip to content

fix(cli): reduce startup delay for model inference probes - #169354

Merged
steipete merged 1 commit into
mainfrom
fix/local-triage-a
Oct 11, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/local-triage-a

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Related: #88201. Thanks @adamdksaad-ops for the latency report.

What Problem This Solves

infer model run eagerly imports the prepared-model catalog even when the user selects the configured default or a lowercase provider/model ref, delaying the request before inference starts.

User Impact

Ordinary probes skip this unused catalog import. Case correction, agent selection, auth, and completion outcomes remain unchanged. This removes one avoidable startup cost; substantial local CLI startup overhead remains.

Why This Change Was Made

The model-ref owner already calls its catalog callback only when case correction needs it. Reuse the existing lazy inspection loader inside that callback instead of importing its execution graph up front. Production: +1/-2 lines (net -1); tests: +5/-0; docs: +1/-0.

Evidence

Real native Ollama llama3.2:latest, warm model, isolated state and Gateway on port 19564; prompt Hi, respond with just OK. Every successful call returned OK. Commands used pnpm openclaw --profile triage-a infer model run --local|--gateway --prompt 'Hi, respond with just OK' --json.

  • Direct /api/chat: 0.083–0.113 s warm; initial cold load 4.065 s.
  • Main d220cac2b74433fdb189ac381b9fca2bfcaf7e07: local 12.06 s first / 8.28 s warm (profiled 8.97 s); Gateway 15.94 s first / 10.50 s profiled warm.
  • Candidate: Gateway 6.32 s first / 6.48 s profiled warm. Local 7.06–11.19 s: host-load variance prevents a reliable local speedup claim. Build-contaminated samples were excluded.
  • Local baseline profile: development launcher about 3 s, application process about 5.1 s, native Ollama request 59 ms, config preparation 835 ms, repeated plugin metadata scans about 0.8 s; synchronous module reads/compilation dominate CPU samples. Gateway client config preparation was only 20 ms. Measurements include the development launcher and shared-host contention; they are not an installed-package or original VPS benchmark.
  • Regression: the existing 15 outcome tests reject unnecessary catalog imports and all fail on unmodified main. After the fix, 99 focused command tests pass, including mixed-case selected-agent catalog lookup: node scripts/run-vitest.mjs src/cli/capability-cli/model.run-outcomes.test.ts src/cli/capability-cli.test.ts --maxWorkers=1, 47.23 s wall (38.25 s Vitest including cold compilation, about 13.8 s test execution). No new test cases, timers, or process boots; zero additional CI test invocations.
  • pnpm build, focused oxlint, pnpm tsgo:core, formatting, docs MDX, and git diff --check pass. Assertion-safety, max-lines, line-cap, test-timeout-race, test-mock-exports, config-docs, and plugin-inventory ratchets pass.
  • Changed-check planner source scan crashed with SIGILL; the affected checks were run directly. Gateway-only setup omitted the pinned lint workspace dependency; installing that workspace made lint pass.
  • Independent Codex autoreview: scoped-clean, no accepted/actionable P0–P2 findings.
  • Exact-head CI passed: run 38173859443; openclaw/ci-gate is green on 860b91f33c9b0d9fb05488a354e3bdffa80de1aa.
  • ClawSweeper reviewed that same head: no findings and no Before merge items; ready for maintainer review, explicitly rated a partial latency improvement.

Keep case-correction catalog loading inside the existing lazy catalog callback. Ordinary model runs no longer import that runtime solely to construct an unused callback. Related: #88201.
@clawsweeper

clawsweeper Bot commented Oct 11, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: XS labels Oct 11, 2026
@steipete steipete added the ci:no-fail-fast Keep all selected CI matrix jobs running after failures on the next PR run. label Oct 11, 2026
@steipete
steipete marked this pull request as ready for review October 11, 2026 20:50
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR defers model-catalog imports until an explicit mixed-case model override needs case correction.

Example: Run openclaw infer model run --gateway --prompt 'Hi, respond with just OK' --json with configured Ollama llama3.2:latest.

  • Before: The CLI imports the prepared-model catalog even though no model override needs correction.
  • After: The CLI skips that unused import and retains the successful OK response.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A correct, focused optimization with real CLI evidence; overall scope remains a partial solution to the linked latency report.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied native Ollama observations exercise the changed inference CLI through local and Gateway commands with isolated state and successful OK output; paired measurements support a partial startup improvement while explicitly leaving local speedup inconclusive.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Partial
User problem: Ordinary inference probes wait for catalog code that their model selection never uses.
Reason: The maintainer-authored change removes demonstrated unnecessary work with minimal complexity and correctly avoids claiming full resolution of the linked latency report.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR provides a focused, useful startup optimization that current main still lacks, with no actionable correctness or security findings.

Priority: P2
Reviewed head: 860b91f33c9b0d9fb05488a354e3bdffa80de1aa

Before merge

None.

Findings

None.

Agent review details

How this fits together

The inference CLI resolves agent configuration and model overrides, then sends the supplied prompt through local completion or Gateway inference and emits a result envelope.

flowchart TD
A[Inference CLI] --> B[Resolve config and agent]
B --> C[Canonicalize model override]
C -->|Mixed case| D[Lazy catalog inspection]
D --> E[Local or Gateway inference]
C -->|Default or lowercase| E
E --> F[Result envelope]
Loading

Technical review

Best possible solution:

Land the focused lazy-import optimization and retain the broader latency report for separately measured remaining bottlenecks.

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

Current-main source establishes the unused eager import for default and lowercase model runs, supported by the supplied native CLI measurements; this review performed no runtime reproduction.

Is this the best way to solve the issue?

Reusing the existing lazy catalog loader fixes the import boundary directly while preserving agent selection, read-only catalog acquisition, authentication, and completion handling.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against aef528ff45ef.

Provenance checked

  • Inference execution import placement keeps the original intent (c425798: Defer provider execution runtimes until command execution so help and completion remain lightweight.)
  • Model-reference canonicalization callback keeps the original intent (22fbcfc: Inline redundant command plumbing while preserving model selection and output contracts.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit c425798 adds src/cli/capability-cli/model.ts:41 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c4257984ae19; files: src/cli/capability-cli/model.ts)
  • Ayaan Zaidi: Raw commit 8cb08ae adds src/cli/capability-cli/model.ts:62 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8cb08aef85a8; files: src/cli/capability-cli/model.ts)

PR surface

Source -1, Tests +5, Docs +1. Total +5 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 1 2 -1
Tests 1 5 0 +5
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 7 2 +5

Review metrics

Metric Value Why it matters
Production versus test growth Production +1/-2; tests +5/-0 The production path shrinks while an existing command fixture gains a guard against the demonstrated eager import without adding test cases.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The change removes avoidable inference-probe startup work without changing command defaults or affecting core availability.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-11T20:55:50.348Z sha 860b91f :: needs maintainer review before merge. :: none

Reviewed October 11, 2026, 5:22 PM ET / 21:22 UTC (Revision 2).

@steipete
steipete merged commit d26d076 into main Oct 11, 2026
199 of 201 checks passed
@steipete
steipete deleted the fix/local-triage-a branch October 11, 2026 21:32
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
…69354)

Keep case-correction catalog loading inside the existing lazy catalog callback. Ordinary model runs no longer import that runtime solely to construct an unused callback. Related: openclaw#88201.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:no-fail-fast Keep all selected CI matrix jobs running after failures on the next PR run. cli CLI command changes docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS 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