Skip to content

perf(llm-task): load task runtime on first execution - #157233

Merged
vincentkoc merged 1 commit into
mainfrom
perf/plugin-import-boundaries-20260924
Sep 24, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
perf/plugin-import-boundaries-20260924

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

LLM Task loads its execution runtime when the plugin is imported, although registration only needs the tool's static definition.

User Impact

Keep tool registration synchronous and defer the execution runtime until the first invocation. Tool metadata, arguments, configuration reads, results, and errors retain their existing behavior. Three paired cold-import runs showed lower CPU use and peak RSS for the plugin entry.

Why This Change Was Made

Separate the unchanged static tool definition from execution and use the existing lazy-tool helper. Concurrent first use shares loading while each registration retains its API-bound tool.

Production: +49/-33 lines, net +16 for the static-definition/execution boundary. Tests: +108 lines. Total: 190 changed lines across four files.

Evidence

Validated signed source f48195c08fc94e647fc742f4b6b623e59206935a against frozen base 88d8a4c20e1387f08d59e62e2d26513650973868:

  • The real-entry regression fails on the original eager-loading implementation and passes on this head.
  • 40 focused tests passed: the new entry test plus 39 existing tool/helper tests. Coverage includes concurrent first use, independent registrations, results, cancellation, and validation errors.
  • New test cost (one worker): pnpm test extensions/llm-task/index.test.ts --maxWorkers=1 passed on Linux x64 / Node 24.19.0. Vitest reported 16.74 s for the file and 16.045 s for its single case; the repository wrapper reported 18.20 s wall time, and the outer proof stage recorded 19 s at whole-second resolution. This observed run includes native worker preparation; it is not a steady-state or incremental CI-cost estimate.
  • Hosted CI cost: the exact-head changed-extension job passed. The new single case took 40.559 s; its shard passed 29 tests across two files with 46.50 s repository-wrapper wall time. The whole job took 85 s, including setup and other work. The test intentionally imports the real source execution runtime on first use and stubs model completion. The log does not isolate import/transform time, and there is no matched CI run without this test, so these observations do not establish its steady-state or incremental recurring CI cost.
  • Required checks for all four changed paths passed, including typechecks, guards, and lint. Targeted formatting, git diff --check, and independent source review passed.
  • OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build sourcePerformance passed and emitted the canonical LLM Task entry. A subsequent full canonical package build passed, including declarations, the tarball checker, and import-graph checks. All four package stages exited successfully; the latest package phase took 1,310 s. Signed source, runtime, and the five recorded dependency-metadata files remained unchanged. The package used a synthetic carrier with the same source tree. This was package validation, with no release or deployment.
  • The full build reported nonfatal UI bundle warnings: startup 363.0 KiB against 362.6 KiB, and Mermaid 1,555.8 KiB against 960 KiB. These warnings were not attributed to this change; the package and tarball checks passed.
  • Plain Node imported the emitted entry, registered the tool synchronously, created it synchronously, and resolved the lazy runtime on first execution. The unchanged prompt required validation error confirmed that execution reached the runtime. This probe did not execute a provider request.
  • Published-driver × candidate installed proof passed: installed integrity-verified published 2026.9.6, then used its real updater to install the candidate package in an exclusive temporary prefix outside the source checkout. The released dry-run and actual update selected the same npm installation. All 10,928 installed dist files matched the candidate, with no update-transaction residue. Plain Node imported the installed LLM Task entry, registered the tool synchronously, and its first lazy execution reached the unchanged prompt required validation error. This proves installed first-use reachability; it does not claim a valid-prompt provider completion. Install, target preview, update, callback, and cell all exited 0. Source, runtime, five dependency-metadata files, and candidate tarball remained unchanged; fixture and exact worker closure were verified. The expected non-default-HOME service-management warning was retained.
  • Earlier update attempts remain failed evidence: one had an incomplete transport artifact protocol; another exposed a private fixture placement error that selected the enclosing source Git checkout. The successful isolated-prefix proof above used the corrected fixture and does not relabel those attempts as successes.

Three paired fresh-process imports of the canonical built entry, on the same Linux x64 worker with Node 24.19.0 and alternating baseline/candidate order:

Median measurement Baseline This change
Import-process CPU, user + system 1,490.287 ms 206.374 ms
Process peak RSS 327.555 MiB 98.387 MiB

Paired candidate-minus-baseline CPU: median -1,250.505 ms, range -1,306.352 to -1,207.736 ms. Peak RSS: median -229.547 MiB, range -230.535 to -224.555 MiB. Paired medians are calculated from each repetition, rather than subtracting the two medians above.

All six raw reports passed source/build/runtime, CPU/RSS arithmetic, child-process, and temporary-HOME cleanup checks; the worker was closed. These results cover cold import only. They do not measure provider execution, activation/workload cost, retained memory, or leaks. Source dependency inputs and runtime were matched; full installed dependency closure was not attested.

@vincentkoc vincentkoc self-assigned this Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 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.

@vincentkoc
vincentkoc marked this pull request as ready for review September 24, 2026 11:11
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 24, 2026, 11:09 AM ET / 15:09 UTC (Revision 4).

ClawSweeper review

What this changes

The LLM Task plugin registers its tool from static metadata, loads execution code on the first call, and adds an entry-point regression test.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: this improvement is absent from current main, and the code review found no blocking defect. The required installed-upgrade verification remains incomplete.

Priority: P2
Reviewed head: f48195c08fc94e647fc742f4b6b623e59206935a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused patch has strong source and runtime evidence, with installed-upgrade qualification still outstanding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The captured evidence ties the changed plugin entry to a built-entry Node probe that registers synchronously and reaches the deferred runtime on first execution, with paired cold-import improvements. It does not qualify the separate published-updater upgrade requirement. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The captured evidence ties the changed plugin entry to a built-entry Node probe that registers synchronously and reaches the deferred runtime on first execution, with paired cold-import improvements. It does not qualify the separate published-updater upgrade requirement. No stored-data contract changes.
Evidence reviewed 10 items Introduced change: The pinned PR delta moves tool metadata into a static module and defers the execution-module import until execute is called.
Current main still needs the change: The current-main entry still imports the execution module during plugin import.
Latest release boundary: The latest supplied release commit also uses the eager import, so the proposed optimization is not already shipped there.
Findings None None.
Security None None.

How this fits together

LLM Task is an optional plugin tool for structured, JSON-only model calls. Plugin loading supplies tool metadata to OpenClaw; invoking the tool then reaches the model completion runtime and returns validated JSON.

flowchart LR
  A[Plugin loading] --> B[Static tool metadata]
  B --> C[Tool registration]
  C --> D[First tool call]
  D --> E[Load execution runtime]
  E --> F[Model completion]
  F --> G[Validated JSON result]
Loading

Before merge

  • Resolve merge risk (P1) - An existing installation could register LLM Task after updating but fail on its first invocation if the deferred execution module is unavailable or cannot load; the published-updater attempt did not observe installation or first use.
  • Complete next step (P2) - Complete and review a published-2026.9.6 updater × candidate run on an existing installation, including the first LLM Task invocation.
Agent review details

Security

None.

PR surface

Source +16, Tests +108. Total +124 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 49 33 +16
Tests 1 108 0 +108
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 157 33 +124

Review metrics

Metric Value Why it matters
Cold plugin import median CPU 1,490.287→206.374 ms; peak RSS 327.555→98.387 MiB Three paired fresh-process runs support the claimed import benefit, without measuring provider execution.
Production versus test growth production +16 net lines; tests +108 lines The production growth is explained by separating static metadata from execution, while the new test guards the entry boundary.
New test cost 18.20 s local wall; 40.559 s hosted case The PR records the recurring cost of exercising the real source runtime on first use.

Merge-risk options

Maintainer options:

  1. Verify the installed upgrade (recommended)
    Complete a published-2026.9.6 updater × candidate run on an existing installation and record registration plus the first LLM Task result.

Technical review

Best possible solution:

Qualify the candidate through the published updater on an existing installation, including a successful first LLM Task invocation, before landing the lazy-loading improvement.

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

Yes. Current main visibly imports the runtime at plugin load, and the captured PR evidence describes paired cold-import measurements; I did not run the benchmark in this read-only review.

Is this the best way to solve the issue?

Yes. Splitting static metadata from execution uses an existing SDK helper and preserves the plugin contract in source; installed-upgrade behavior still needs qualification.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded performance improvement to an optional plugin with a limited user-facing blast radius.
  • merge-risk: 🚨 compatibility: Deferred loading changes when an installed plugin needs its execution module, and first use after upgrade remains unverified.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The captured evidence ties the changed plugin entry to a built-entry Node probe that registers synchronously and reaches the deferred runtime on first execution, with paired cold-import improvements. It does not qualify the separate published-updater upgrade requirement. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured evidence ties the changed plugin entry to a built-entry Node probe that registers synchronously and reaches the deferred runtime on first execution, with paired cold-import improvements. It does not qualify the separate published-updater upgrade requirement. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • Josh Avant: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Record the published-updater × candidate outcome on an existing installation through its first LLM Task invocation.

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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-24T11:20:53.452Z sha f48195c :: needs changes before merge. :: [P3] Record the new test file's measured runtime
  • reviewed 2026-09-24T11:33:23.518Z sha f48195c :: needs maintainer review before merge. :: none
  • reviewed 2026-09-24T11:40:52.812Z sha f48195c :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Sep 24, 2026
@vincentkoc
vincentkoc merged commit 23f14bb into main Sep 24, 2026
209 of 211 checks passed
@vincentkoc
vincentkoc deleted the perf/plugin-import-boundaries-20260924 branch September 24, 2026 18:20
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: llm-task Extension: llm-task merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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