Repository navigation
feat(nodes): derive worker capacity from CPU cores and make it configurable - #128352
Conversation
…urable Node session hosting was capped at a hardcoded 2 concurrent worker sessions. The default is now one worker slot per available CPU core (clamped to 1..1024), and nodeHost.workerRuns.capacity overrides it explicitly. The capacity option was already plumbed through the supervisor; this wires it from config and deletes the hardcoded constant. Docs and config baselines regenerated.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 23, 2026, 4:32 PM ET / 20:32 UTC. ClawSweeper reviewWhat this changesThis PR adds Merge readinessKeep open for maintainer product review. The wiring is coherent, but it replaces the documented two-worker upgrade default for every existing enabled node without a capacity setting; an update and restart can instead advertise one slot per available CPU core. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherA paired node creates a local worker supervisor and publishes its free worker slots to the Gateway. The Gateway uses that inventory to decide whether it can dispatch another supervised session to the node. flowchart LR
A[Node configuration] --> B[Node-host runtime]
C[Available CPU cores] --> D[Capacity resolver]
B --> E[Worker supervisor]
D --> E
E --> F[Runner inventory]
F --> G[Gateway session dispatch]
Decision needed
Why: This is an intentional default and admission-policy change for existing operators, not a mechanical correctness choice; source and tests establish the behavior but cannot determine the supported rollout policy. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +14, Tests +55, Docs +2, Generated 0. Total +71 across 14 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the two-slot default and offer the new field as the explicit scaling control unless a maintainer deliberately approves the CPU-derived upgrade behavior with fresh-install and upgrade proof. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR changes configuration and default policy rather than reporting a current broken behavior. Is this the best way to solve the issue? No: the config wiring is clean, but changing the established two-slot default is not the safest solution until maintainers choose its upgrade policy. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against eb0118b417c4. 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
|
|
Maintainer decision (recorded, re: the P1 "preserve the two-slot upgrade default"): The CPU-derived default is intentional and approved. The repository owner explicitly specified this rollout: default = number of available CPU cores, with Why the compat concern does not block: per the review's own release-position evidence, the latest stable tag predates the node worker-capacity feature entirely — the two-slot ceiling has never been reachable from a stable release, so under the repo's compatibility doctrine ("shipped" = reachable from a stable release Git tag) it is not a shipped contract. Pre-release node hosts follow Rank-up moves:
|
|
Merged via squash.
|
…urable (openclaw#128352) Node session hosting was capped at a hardcoded 2 concurrent worker sessions. The default is now one worker slot per available CPU core (clamped to 1..1024), and nodeHost.workerRuns.capacity overrides it explicitly. The capacity option was already plumbed through the supervisor; this wires it from config and deletes the hardcoded constant. Docs and config baselines regenerated.
What Problem This Solves
Node session hosting caps every paired node at 2 concurrent worker sessions, hardcoded in
src/node-host/node-worker-capacity.ts(DEFAULT_WORKER_CAPACITY = 2). Thecapacityoption was already plumbed throughNodeWorkerSupervisorOptionsintoNodeWorkerCapacity, but the only production construction site (prepareNodeHostRuntime) never passed it, so a 32-core Mac Studio hosts exactly two sessions and there is no knob to change that.Why This Change Was Made
Operators distributing session load across their own machines need per-node concurrency to reflect the hardware. This change:
os.availableParallelism()(falling back toos.cpus().length, mirroring the existingsrc/config/agent-limits.tspattern), clamped to[1, NODE_WORKER_CAPACITY_MAX](1024).nodeHost.workerRuns.capacity(strict integer, 1..1024) as the explicit override, wired from config throughcreateNodeWorkerSupervisor. Node-local enforcement is unchanged — the Gateway still cannot set this remotely.{ total, available }inventory publication, and 10-second admission wait are untouched; only the ceiling changes.Config baseline note: regenerating
docs/.generated/config-baseline.*records +4 core fields — 1 from this PR and 3 pre-existing unrecorded fields already onmain(cleanmainregenerates 2335 → 2338); this PR absorbs that drift.User Impact
Nodes now host one worker session per available CPU core by default instead of two total, and
nodeHost.workerRuns.capacitybounds it explicitly. Existing nodes pick up the new default on update + node restart. Docs updated (docs/nodes/index.md,docs/plan/runners.md).Evidence
src/node-host/runner.test.ts— confignodeHost.workerRuns.capacity: 5must publishworkerHost.capacity {total: 5, available: 5}in the atomic runner inventory; pre-fix the runtime ignored the option and published{total: 2}.src/node-host/node-worker-supervisor.test.ts— mockedos.availableParallelismof 0 / 7 / 1025 publishes 1 / 7 / 1024; explicitcapacitynever consults the CPU count.src/config/config.node-agent-runs.test.ts— accepts 1/5/1024, rejects 0/-1/1.5/1025 with the exact issue path.pnpm test src/node-host src/config: 3,846 passed, 2 skipped (289 files).pnpm check:changed,pnpm check:import-cycles,pnpm config:docs:gen && pnpm config:docs:check,pnpm config:schema:check,pnpm docs:check-mdx(777 files),git diff --check: all green.