Skip to content

test(cli): gate agent --local cold-start processes and workers - #206466

Merged
obviyus merged 4 commits into
mainfrom
perf/cold-start-gate
Nov 27, 2026
Merged

obviyus merged 4 commits into
mainfrom
perf/cold-start-gate

Conversation

@obviyus

@obviyus obviyus commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Cold time-to-first-request of the one-shot openclaw agent --local turn (the path benchmark boards run) has no regression gate. A measured turn on b0a6e8cd took 6.05 s median to the first provider request (warm Gateway: 0.69 s). Most of it is fan-out: every Node process and worker thread boots its own module graph before the first request. Nothing stops a change from adding another one.

Change

Add src/cli/agent-local-cold-start.process.test.ts: one real agent --local turn from source, run on Node (the default install's runtime, also when Vitest runs on Bun), against the local fake OpenAI Responses server (test/helpers/openai-responses-model-fixture.ts). A ledger preload, carried by NODE_OPTIONS into every descendant process that inherits the environment and into every worker thread, counts up to the moment the fake provider receives the first request:

  • nodeProcesses: Node processes that started (CLI, respawns, inheriting children),
  • nodeSpawns: Node spawn calls from any process or thread (covers children that start with a clean environment),
  • workerThreads: worker threads constructed in any process or thread.

The test asserts ceilings { nodeProcesses: 4, nodeSpawns: 5, workerThreads: 19 }, measured on the Linux CI runner (macOS starts 18 workers). Counts, not wall time: they do not move with host load. A PR that removes work lowers the budget in the same change.

The fixture keeps the default startup (OPENCLAW_NO_RESPAWN unset) and marks host CA discovery done (OPENCLAW_NODE_EXTRA_CA_CERTS_READY=1), because that respawn depends on the host's Node install. Windows is skipped: it always respawns for its stack size, so its topology differs by design.

Evidence

  • Red on the merge base before perf(cli): stop respawning the CLI to hide a warning Node no longer emits #206448 (b0a6e8cd, first version of this test): the warning-only respawn adds a CLI process. Green on main with perf(cli): stop respawning the CLI to hide a warning Node no longer emits #206448.
  • Counts: Linux CI (Node CLI under the Bun Vitest lane) 4 / 5 / 19; macOS arm64 Node 24.22.1, 3 runs, 4 / 5 / 18 each.
  • Review round 1 findings fixed: Windows topology (skipped, documented) and descendant work (ledger now propagates through NODE_OPTIONS and counts in every thread; process starts and spawn calls are separate counters).
  • Cost: one CLI turn from source, about 16-31 s test time locally (88 s once under host load 40); same 120 s timeout as agent-local-rpc-cleanup.process.test.ts. No cheaper layer proves the processes and workers a real turn starts before its first request.

- Counts CLI Node processes, Node children and worker threads started before the first provider request of a real one-shot turn against the fake Responses server.
- Exact budget; lower it in the PR that removes work.
@clawsweeper

clawsweeper Bot commented Nov 27, 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 cli CLI command changes size: S labels Nov 27, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 27, 2026
- Carry the ledger through NODE_OPTIONS into descendants and every worker thread; count process starts and spawn calls separately.
- Run the CLI on Node even when Vitest runs on Bun; skip Windows, which always respawns for its stack size.
- Linux CI starts 19 worker threads before the first request, macOS 18; assert ceilings and report the counts.
@obviyus
obviyus merged commit b885f61 into main Nov 27, 2026
121 checks passed
@obviyus
obviyus deleted the perf/cold-start-gate branch November 27, 2026 08:00
@clawsweeper clawsweeper Bot added 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. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

Adds a real CLI process test that caps Node processes, Node spawn calls, and worker threads before the first local-agent provider request.

Example: A Linux local-agent turn starts 20 worker threads before its first provider request.

  • Before: No dedicated startup worker-count gate rejects the increase.
  • After: The new test fails because the worker ceiling is 19.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused test-only coverage with reported cross-platform runs, successful exact-head CI, and no definite correctness finding.
Proof confidence 🐚 platinum hermit (4/6) Only test coverage and test routing change; no user-visible production behavior requires separate shipped-entry-point proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Additional startup fan-out can make one-shot local-agent turns slower without a dedicated regression signal.
Reason: The maintainer-authored direction adds distinct work-count coverage through existing fixtures and routing, with the test cost and platform exclusions explained.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it adds a focused startup regression gate, has no definite introduced defects, and the reviewed head passes the CI gate.

Reviewed head: ad0ea6d701dfd2c6f17ac4d216110f4ac4f7de50

Before merge

None.

Findings

None.

Agent review details

How this fits together

The CLI process test launches an isolated Node agent turn against a loopback Responses server, records startup activity through a preload, and compares activity before the first request with fixed ceilings.

flowchart TD
  A[CLI process test] --> B[Node CLI with ledger preload]
  B --> C[Descendant processes and workers]
  B --> D[Loopback Responses server]
  C --> E[Startup ledger]
  D --> F[First request timestamp]
  E --> G[Budget assertions]
  F --> G
Loading

Technical review

Best possible solution:

Retain the single startup-budget test under the existing CLI process project.

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

This is test-only coverage; the body reports Linux and macOS startup counts and an earlier red control, but this read-only review did not execute them.

Is this the best way to solve the issue?

A real CLI turn with shared process fixtures is an appropriate boundary for startup fan-out; its source-runtime ceilings do not claim packaged-runtime latency coverage.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • CLI process-test ownership keeps the original intent (258cc84: Isolate source-launching CLI tests from shared shards so contention does not obscure startup and exit behavior.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 258cc84 adds test/vitest/vitest.cli-process-paths.mjs:3 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 258cc8496571; files: test/vitest/vitest.cli-process-paths.mjs)

PR surface

Tests +153. Total +153 across 2 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 153 0 +153
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 153 0 +153

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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.

Reviewed November 27, 2026, 2:59 AM ET / 07:59 UTC.

vincentkoc added a commit that referenced this pull request Nov 27, 2026
…restoration-ci-189390-20261127

* commit '6feeb50a3f14fbf0aa5167d342f186dc4d67fc18': (9846 commits)
  fix: stop 2026-11-17 main Git checkouts from half-switching on a schema update (#206341)
  refactor(codex): centralize native completion delivery (#206447)
  fix(subagents): finish claimed stops after session rotation (#206405)
  fix: let owners fork a chat with exec after a subagent or exec completion (#206483)
  test(cli): gate agent --local cold-start processes and workers (#206466)
  perf(ci): skip baseline inventory when line-cap debt is empty (#189909)
  refactor(test): share core process-result fixtures (#174149)
  refactor(ci): reuse canonical budget flag parsing (#189480)
  fix: recover Codex chats after oversized requests (#206475)
  fix(agents): skip the bootstrap ritual in one-shot runs (#206477)
  fix(test): preserve stack coordinates in redacted failure reports (#152384)
  fix(gateway): return consistent unavailable response guidance (#191933)
  fix: preserve emphasis in Markdown table row labels (#205349)
  fix(nextcloud-talk): keep webhook spool helpers private (#206470)
  perf(plugins): overlay native receipts once per visible root (#206464)
  fix: keep GitHub comment approvals alive and skip repeat approval on the session PR (#206129)
  perf(config): retain one snapshot for unchanged validation results (#206465)
  refactor(test): reuse canonical secret fixture cleanup (#189492)
  refactor(subagents): own descendant Stop cancellation (#206444)
  refactor(subagents): keep announce cleanup action type private (#206407)
  ...
vincentkoc added a commit that referenced this pull request Nov 27, 2026
* commit 'fd681ab8786e062045fa5ec6261b1b06f60832eb': (2115 commits)
  fix: keep doctor --fix pending checks from creating SQLite sidecars (#206485)
  fix(ci): update iOS screenshot reducer gate (#206497)
  fix: keep chat photo previews sharp within their byte limits (#206461)
  fix: let agents use short Workboard card IDs
  fix(tui): run provider sign-in in the local TUI (#200605)
  improve(config): reduce repeated directory checks for larger agent rosters (#206494)
  perf(test): reuse the Periphery producer workflow snapshot (#189681)
  fix(ci): keep locale assets within the installed package budget (#206492)
  fix: preserve failed Apple chat messages across partial history pages (#205404)
  improve: avoid merging unrelated settings for agent directory lookups (#206489)
  fix: show typing while a queued follow-up turn runs (#201920)
  fix: stop 2026-11-17 main Git checkouts from half-switching on a schema update (#206341)
  refactor(codex): centralize native completion delivery (#206447)
  fix(subagents): finish claimed stops after session rotation (#206405)
  fix: let owners fork a chat with exec after a subagent or exec completion (#206483)
  test(cli): gate agent --local cold-start processes and workers (#206466)
  perf(ci): skip baseline inventory when line-cap debt is empty (#189909)
  refactor(test): share core process-result fixtures (#174149)
  refactor(ci): reuse canonical budget flag parsing (#189480)
  fix: recover Codex chats after oversized requests (#206475)
  ...
vincentkoc added a commit that referenced this pull request Nov 27, 2026
* commit 'fd681ab8786e062045fa5ec6261b1b06f60832eb': (923 commits)
  fix: keep doctor --fix pending checks from creating SQLite sidecars (#206485)
  fix(ci): update iOS screenshot reducer gate (#206497)
  fix: keep chat photo previews sharp within their byte limits (#206461)
  fix: let agents use short Workboard card IDs
  fix(tui): run provider sign-in in the local TUI (#200605)
  improve(config): reduce repeated directory checks for larger agent rosters (#206494)
  perf(test): reuse the Periphery producer workflow snapshot (#189681)
  fix(ci): keep locale assets within the installed package budget (#206492)
  fix: preserve failed Apple chat messages across partial history pages (#205404)
  improve: avoid merging unrelated settings for agent directory lookups (#206489)
  fix: show typing while a queued follow-up turn runs (#201920)
  fix: stop 2026-11-17 main Git checkouts from half-switching on a schema update (#206341)
  refactor(codex): centralize native completion delivery (#206447)
  fix(subagents): finish claimed stops after session rotation (#206405)
  fix: let owners fork a chat with exec after a subagent or exec completion (#206483)
  test(cli): gate agent --local cold-start processes and workers (#206466)
  perf(ci): skip baseline inventory when line-cap debt is empty (#189909)
  refactor(test): share core process-result fixtures (#174149)
  refactor(ci): reuse canonical budget flag parsing (#189480)
  fix: recover Codex chats after oversized requests (#206475)
  ...
obviyus added a commit that referenced this pull request Nov 27, 2026
## Problem

A one-shot CLI (`openclaw agent --local`) boots a fresh shared-state reader worker for every state read: since #204868, each successful one-shot read retires its worker so that no SQLite handle outlives the read (Windows `EPERM` on a release switch). The handle release is required; the worker exit is not. Each boot re-imports the reader's module graph (~90-880 modules, ~140 ms CPU per boot measured with per-thread `--cpu-prof`).

## Change

`src/state/openclaw-state-read-worker.ts`: in the `cli-oneshot` role, a successful read no longer retires its reader. It closes the task, then joins `closeReadResources(pool)` before the result returns:

- Node (`explicitSqliteCloseReleasesNativeResources`): native handles close in place and the isolate stays for the next read.
- Runtimes without explicit native close: `closeReadResources` rotates the pool, which joins worker exit, as before.

The kept reader exits when the command closes shared state at CLI cleanup (`withCliCommandCleanup` resets the state-database lifecycle, which closes the read pools). Other roles are unchanged.

The #206466 gate budget drops from 19 to 17 worker threads before the first request.

## Guarantee kept

No SQLite handle outlives a successful one-shot read: the result still settles only after the native release completes. `src/state/openclaw-state-read-source.test.ts`:
- `releases CLI reader handles before a successful read returns and keeps the reader`: replaces the per-read exit assertion. The read result stays pending until the handle release settles, the task closes without retiring, one pool is created for four reads, and `closeOpenClawStateDatabaseAsync()` (the CLI cleanup path) closes that pool.
- `uses the cli-oneshot process lifetime for early awaited reads`: tasks close without retirement in `cli-oneshot`.

## Evidence

- Worker threads started before the first provider request, `src/cli/agent-local-cold-start.process.test.ts` (Node, macOS arm64): 18 -> 16. Linux CI was 19 before; the budget is 17.
- Per-thread CPU profile of one fake-provider turn (3 runs, median): 4 state-read worker boots per turn at 137 ms boot CPU each; this change removes 2 of them in the measured turn (one stays, admission reads keep their worker).
- Tests: the 26 test files under `src/state/openclaw-state-read*` plus every importer of `openclaw-state-read-worker.js`, `src/cli/agent-local-cold-start.process.test.ts`, `src/cli/agent-local-rpc-cleanup.process.test.ts`, `src/cli/one-shot-exit.cleanup.process.test.ts` pass locally.
- Wall-time ABAB is owed: host load stayed above 20 during this work; it will be appended to the W4 status at load < 10.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 27, 2026
…6565)

## Problem

`getPluginRuntimeGenerationRegistry` lives in `src/plugins/runtime/generation-state.ts`, but `generation-scope.ts` re-exports it, and callers imported it from there. `generation-scope` also loads metadata snapshots, invocation frames and registry creation. `src/agents/harness/registry-lifecycle.ts` needs only the getter, yet it pulls that graph into the agent SQLite store worker of every one-shot `openclaw agent --local` turn.

## Change

- Every caller of `getPluginRuntimeGenerationRegistry` (6 production modules, 22 tests/test-support files) imports it from `generation-state.js`. Mocks that supplied the getter through a `generation-scope` mock now mock `generation-state`, so they still reach the code under test.
- Delete the re-export from `generation-scope.ts`. Other `generation-scope` symbols are unchanged.

No behavior change: the getter is the same function.

## Evidence

- Module loads per thread before the first provider request, one fake-provider `agent --local` turn with a resolve/load trace in every thread, same base (main 238c6da vs 238c6da + this change), 2 runs each with identical counts: agent SQLite store worker 1,999 -> 1,915; all threads 14,870 -> 14,792.
- `rg getPluginRuntimeGenerationRegistry` over src/extensions/packages/test: every reference resolves to `generation-state`.
- Tests: one `ocx test` call over the 211 changed and importer test files: 2,819 passed, 1 skipped. Format and type-aware oxlint clean on all 29 changed files.
- The #206466 gate counts processes, spawns and worker threads; none change here, so its budget is unchanged.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 27, 2026
…med send (#206594)

## Problem

`src/sessions/confirmed-visible-message.ts` statically imports `commitBackgroundPayloadsToSession` from `sessions/background-result-payloads.ts`, which pulls in gateway chat media helpers (`gateway/server-methods/chat-reply-media` and its graph). `confirmed-visible-message` sits under the outbound delivery modules (`deliver-core`, `delivery-queue-transcript`, `outbound-send-service`) that `agent-command` imports. So every one-shot `openclaw agent --local` turn loads that graph before its first model request, although the commit runs only after a channel confirms an external send.

## Change

Load `background-result-payloads.js` at the one place it is used, after the destination entry is read and right before the commit. The type import stays static. No behavior change: the same function runs with the same arguments inside the same `runWithoutOwnedSessionTranscriptWrites` scope.

## Evidence

Main-thread import graph before the first provider request, one fake-provider `agent --local` turn on main `28dbf478` with a resolve/load trace (cut at the first `POST /v1/responses`), dominator tree from the entry:

| | base | this PR |
|---|---:|---:|
| `background-result-payloads` dominated modules (loaded only through it) | 124 (823 KB) | not loaded |
| main-thread modules before the request | 5,973 (39.4 MB) | 5,851 (38.5 MB) |
| all-thread module loads before the request | 14,770 | 14,648 |

Head counts are identical in 2 runs. The #206466 gate counts processes and workers; neither changes, so its budget is unchanged.

Tests: the 8 test files that import `confirmed-visible-message` or `background-result-payloads` pass locally; format and type-aware oxlint clean.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
…law#206466)

## Problem

Cold time-to-first-request of the one-shot `openclaw agent --local` turn (the path benchmark boards run) has no regression gate. A measured turn on `69bb5929` took 6.05 s median to the first provider request (warm Gateway: 0.69 s). Most of it is fan-out: every Node process and worker thread boots its own module graph before the first request. Nothing stops a change from adding another one.

## Change

Add `src/cli/agent-local-cold-start.process.test.ts`: one real `agent --local` turn from source, run on Node (the default install's runtime, also when Vitest runs on Bun), against the local fake OpenAI Responses server (`test/helpers/openai-responses-model-fixture.ts`). A ledger preload, carried by `NODE_OPTIONS` into every descendant process that inherits the environment and into every worker thread, counts up to the moment the fake provider receives the first request:

- `nodeProcesses`: Node processes that started (CLI, respawns, inheriting children),
- `nodeSpawns`: Node spawn calls from any process or thread (covers children that start with a clean environment),
- `workerThreads`: worker threads constructed in any process or thread.

The test asserts ceilings `{ nodeProcesses: 4, nodeSpawns: 5, workerThreads: 19 }`, measured on the Linux CI runner (macOS starts 18 workers). Counts, not wall time: they do not move with host load. A PR that removes work lowers the budget in the same change.

The fixture keeps the default startup (`OPENCLAW_NO_RESPAWN` unset) and marks host CA discovery done (`OPENCLAW_NODE_EXTRA_CA_CERTS_READY=1`), because that respawn depends on the host's Node install. Windows is skipped: it always respawns for its stack size, so its topology differs by design.

## Evidence

- Red on the merge base before openclaw#206448 (`69bb5929`, first version of this test): the warning-only respawn adds a CLI process. Green on main with openclaw#206448.
- Counts: Linux CI (Node CLI under the Bun Vitest lane) 4 / 5 / 19; macOS arm64 Node 24.22.1, 3 runs, 4 / 5 / 18 each.
- Review round 1 findings fixed: Windows topology (skipped, documented) and descendant work (ledger now propagates through `NODE_OPTIONS` and counts in every thread; process starts and spawn calls are separate counters).
- Cost: one CLI turn from source, about 16-31 s test time locally (88 s once under host load 40); same 120 s timeout as `agent-local-rpc-cleanup.process.test.ts`. No cheaper layer proves the processes and workers a real turn starts before its first request.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
…206504)

## Problem

A one-shot CLI (`openclaw agent --local`) boots a fresh shared-state reader worker for every state read: since openclaw#204868, each successful one-shot read retires its worker so that no SQLite handle outlives the read (Windows `EPERM` on a release switch). The handle release is required; the worker exit is not. Each boot re-imports the reader's module graph (~90-880 modules, ~140 ms CPU per boot measured with per-thread `--cpu-prof`).

## Change

`src/state/openclaw-state-read-worker.ts`: in the `cli-oneshot` role, a successful read no longer retires its reader. It closes the task, then joins `closeReadResources(pool)` before the result returns:

- Node (`explicitSqliteCloseReleasesNativeResources`): native handles close in place and the isolate stays for the next read.
- Runtimes without explicit native close: `closeReadResources` rotates the pool, which joins worker exit, as before.

The kept reader exits when the command closes shared state at CLI cleanup (`withCliCommandCleanup` resets the state-database lifecycle, which closes the read pools). Other roles are unchanged.

The openclaw#206466 gate budget drops from 19 to 17 worker threads before the first request.

## Guarantee kept

No SQLite handle outlives a successful one-shot read: the result still settles only after the native release completes. `src/state/openclaw-state-read-source.test.ts`:
- `releases CLI reader handles before a successful read returns and keeps the reader`: replaces the per-read exit assertion. The read result stays pending until the handle release settles, the task closes without retiring, one pool is created for four reads, and `closeOpenClawStateDatabaseAsync()` (the CLI cleanup path) closes that pool.
- `uses the cli-oneshot process lifetime for early awaited reads`: tasks close without retirement in `cli-oneshot`.

## Evidence

- Worker threads started before the first provider request, `src/cli/agent-local-cold-start.process.test.ts` (Node, macOS arm64): 18 -> 16. Linux CI was 19 before; the budget is 17.
- Per-thread CPU profile of one fake-provider turn (3 runs, median): 4 state-read worker boots per turn at 137 ms boot CPU each; this change removes 2 of them in the measured turn (one stays, admission reads keep their worker).
- Tests: the 26 test files under `src/state/openclaw-state-read*` plus every importer of `openclaw-state-read-worker.js`, `src/cli/agent-local-cold-start.process.test.ts`, `src/cli/agent-local-rpc-cleanup.process.test.ts`, `src/cli/one-shot-exit.cleanup.process.test.ts` pass locally.
- Wall-time ABAB is owed: host load stayed above 20 during this work; it will be appended to the W4 status at load < 10.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
…nclaw#206565)

## Problem

`getPluginRuntimeGenerationRegistry` lives in `src/plugins/runtime/generation-state.ts`, but `generation-scope.ts` re-exports it, and callers imported it from there. `generation-scope` also loads metadata snapshots, invocation frames and registry creation. `src/agents/harness/registry-lifecycle.ts` needs only the getter, yet it pulls that graph into the agent SQLite store worker of every one-shot `openclaw agent --local` turn.

## Change

- Every caller of `getPluginRuntimeGenerationRegistry` (6 production modules, 22 tests/test-support files) imports it from `generation-state.js`. Mocks that supplied the getter through a `generation-scope` mock now mock `generation-state`, so they still reach the code under test.
- Delete the re-export from `generation-scope.ts`. Other `generation-scope` symbols are unchanged.

No behavior change: the getter is the same function.

## Evidence

- Module loads per thread before the first provider request, one fake-provider `agent --local` turn with a resolve/load trace in every thread, same base (main f353fd8 vs f353fd8 + this change), 2 runs each with identical counts: agent SQLite store worker 1,999 -> 1,915; all threads 14,870 -> 14,792.
- `rg getPluginRuntimeGenerationRegistry` over src/extensions/packages/test: every reference resolves to `generation-state`.
- Tests: one `ocx test` call over the 211 changed and importer test files: 2,819 passed, 1 skipped. Format and type-aware oxlint clean on all 29 changed files.
- The openclaw#206466 gate counts processes, spawns and worker threads; none change here, so its budget is unchanged.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
…med send (openclaw#206594)

## Problem

`src/sessions/confirmed-visible-message.ts` statically imports `commitBackgroundPayloadsToSession` from `sessions/background-result-payloads.ts`, which pulls in gateway chat media helpers (`gateway/server-methods/chat-reply-media` and its graph). `confirmed-visible-message` sits under the outbound delivery modules (`deliver-core`, `delivery-queue-transcript`, `outbound-send-service`) that `agent-command` imports. So every one-shot `openclaw agent --local` turn loads that graph before its first model request, although the commit runs only after a channel confirms an external send.

## Change

Load `background-result-payloads.js` at the one place it is used, after the destination entry is read and right before the commit. The type import stays static. No behavior change: the same function runs with the same arguments inside the same `runWithoutOwnedSessionTranscriptWrites` scope.

## Evidence

Main-thread import graph before the first provider request, one fake-provider `agent --local` turn on main `bb97b857` with a resolve/load trace (cut at the first `POST /v1/responses`), dominator tree from the entry:

| | base | this PR |
|---|---:|---:|
| `background-result-payloads` dominated modules (loaded only through it) | 124 (823 KB) | not loaded |
| main-thread modules before the request | 5,973 (39.4 MB) | 5,851 (38.5 MB) |
| all-thread module loads before the request | 14,770 | 14,648 |

Head counts are identical in 2 runs. The openclaw#206466 gate counts processes and workers; neither changes, so its budget is unchanged.

Tests: the 8 test files that import `confirmed-visible-message` or `background-result-payloads` pass locally; format and type-aware oxlint clean.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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