Repository navigation
improve: reduce worker tool startup imports - #119644
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 11:17 AM ET / 15:17 UTC. ClawSweeper reviewWhat this changesThe PR extracts shared core coding-tool construction and finalization so restricted workers avoid importing the broader generic agent tool assembly path at startup. Merge readinessKeep open for normal maintainer review. The refactor preserves the Gateway-authorized worker surface while moving common construction and finalization into shared owners; no concrete correctness or security regression surfaced, but the performance claim still needs an exact-head before/after startup or RSS measurement. Priority: P2 Review scores
Verification
How this fits togetherGateway worker turns receive an authorized subset of local coding tools, which the embedded worker exposes to model inference. The generic agent factory and restricted worker both need the same file, shell, schema, hook, and abort behavior. flowchart LR
A[Gateway worker request] --> B[Authorized six-tool policy]
B --> C[Embedded worker runtime]
C --> D[Core coding tool materializer]
D --> E[Schema and hook finalization]
E --> F[Model inference and local execution]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +112, Tests +2. Total +114 across 8 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land one shared materializer and finalizer while preserving the Gateway's six-tool authority, supported by an exact-head before/after startup or RSS/import measurement. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR is a startup-import refactor rather than a report of broken behavior; current worker integration tests cover the authorized tool surface and Gateway turn flow. Is this the best way to solve the issue? Yes, the shared materializer and finalizer are a better owner boundary than a worker-only copy because both generic agents and workers retain the same wrappers; the remaining gap is measurement of the intended performance outcome. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ce06e7924e88. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Exact-head follow-up proof for
The old-head exact-check failures and prior rank-up moves are therefore resolved. @clawsweeper re-review |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
Merged via squash.
|
* perf(worker): narrow core tool imports * fix(worker): preserve generic tool factories --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Restricted workers currently cold-load the generic agent tool assembly graph before their first inference even though the Gateway has already authorized a fixed six-tool surface:
read,write,edit,apply_patch,exec, andprocess. That generic graph reaches channel, plugin, message, system-agent, TUI, and other runtime families the worker cannot expose, making the worker integration test and real worker startup unnecessarily import-bound.Why This Change Was Made
This extracts one canonical core coding/shell materializer and one canonical tool-finalization pipeline from the generic agent factory. Both normal agents and workers now use those same owners. The worker supplies its Gateway-authorized six-tool policy directly, while retaining OpenClaw read/write/edit behavior, workspace-contained apply-patch, lazy scoped exec/process tools, schema normalization, before-tool hooks, abort wrapping, and deferred follow-up descriptions.
No worker authority, tool names, test declarations, shard topology, worker counts, scheduling, concurrency, or timeout settings change.
User Impact
Worker turns start with a substantially smaller eager module graph. Normal agent tool construction keeps the same policy and wrapper pipeline.
Production delta is +112 lines: the positive delta creates the shared owner boundary used by both generic agents and restricted workers, replacing a worker dependency on the much broader policy/materialization graph while preserving the generic factory's existing constructor seams.
Evidence
cbx_abb114186b2c, runrun_553b7ac6714b: all 28 worker runtime integration tests and 118 representative generic tool-construction tests passed (146 total).run_81a913e2023c: alternating baseline → candidate → candidate → baseline with separate cold compile/module caches. Worker-file duration averaged 18.415s → 15.295s (16.9% faster); the cold full embedded turn averaged 13.282s → 8.550s (35.6% faster); maximum RSS averaged 2,288,830 KiB → 2,176,298 KiB (4.9%, about 110 MiB lower).run_5d694621081d: the corrected follow-up passed all 159 focused cases, including the two filesystem-constructor suites that CI had caught.run_592d9b6c8abb:pnpm tsgo:prodpassed after the follow-up.run_523a08a4b914: fullpnpm buildpassed in 4m36.951s, including CLI bootstrap import, plugin SDK export, runtime postbuild, and Control UI performance gates.oxlint,oxfmt --check, andgit diff --checkpassed for all eight changed files.gpt-5.6-sol, high reasoning).This is an incremental step toward the frozen raw full-suite target; it does not claim normalized or final 30% success.