Skip to content

fix(runtime): use runtime-owned Worker loaders - #148272

Merged
steipete merged 2 commits into
mainfrom
codex/bun-agent-core-compat
Sep 14, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/bun-agent-core-compat

Conversation

@steipete

@steipete steipete commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Source-mode Worker pools always attached Node's tsx/esm preload to TypeScript entries. Bun can execute those entries natively, while the Node preload depends on node:module hooks that Bun does not yet implement. Direct-Bun agent-core runs therefore failed before Code Mode source workers could start.

The same run exposed test contracts that depended on Node-specific default abort text, V8 GC hooks, module-loader interception, transformed Fetch cancellation, partial secret-mask presentation, Bun's incomplete built-in undici error classes, or the missing Request.keepalive getter. Two source-probe fixtures also launched the host executable even though their contract explicitly installs Node module hooks.

Why This Change Was Made

The runtime Worker owner now selects its preload from both the source extension and the current executable: Node keeps the resolved tsx/esm preload, Bun uses its native TypeScript loader, and non-file Worker URLs receive no file preload.

The tests keep their observable contracts while removing engine-specific presentation assumptions. Probes that require APIs Bun does not currently provide are narrowly skipped or adapted under Bun with removal conditions beside them: node:module loader interception (oven-sh/bun#35690), synchronous worker-local V8 GC, transformed Fetch cancellation, and Request.keepalive reflection. Source fixtures that deliberately install Node module hooks resolve Node through the existing child-process helper. The installed npm undici package supplies real timeout errors until the AI-assisted upstream fix in oven-sh/bun#42716 ships.

User Impact

OpenClaw source workers and the direct agent-core suite run under Bun without feeding a Node-only TypeScript loader to Bun. Node behavior and built JavaScript workers are unchanged. This adds no dependency, configuration option, or public API.

Evidence

  • Before the fix, direct Bun agent-core runs failed on the Node preload, default abort text, built-in Undici timeout metadata, V8-only GC probe, cancellation-tail probe, source fixtures that install Node module hooks, Request.keepalive reflection, and redaction presentation.
  • Focused Node proof for the new source-probe, cancellation, and MCP HTTP changes: 35/35 passed.
  • Focused custom-Bun proof for the same files: 34/34 passed with one documented cancellation skip.
  • Earlier focused Node proof: 77/77 passed across the runtime-worker and neighboring agent-core files.
  • Earlier focused custom-Bun proof: 69/69 passed with 8 documented runtime-specific skips.
  • The exact 132-file neighboring agent-core chunk passed 2,308 tests before the final redaction assertion repair; the sole failure was that stronger configured redaction produced ***, which the repaired test now accepts by asserting only that the secret is absent.
  • node scripts/check-changed.mjs: passed on the exact rebased head, including core/test types, lint, formatting, boundaries, and import-cycle guards.
  • Fresh P0-P2 autoreview of the complete committed and uncommitted candidate: scoped clean.
  • git diff --check: clean.

@clawsweeper

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

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 14, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 14, 2026, 1:32 PM ET / 17:32 UTC (Revision 3).

ClawSweeper review

What this changes

Selects TypeScript worker loaders for Node and Bun and adapts agent tests that depend on runtime-specific APIs or error presentation.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: current main and v2026.9.4 still apply the Node preload to Bun source workers. No actionable introduced defect was found.

Priority: P2
Reviewed head: 0326db5e2d4724e13a8cdc558da55b72c03b3443

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with retained behavioral coverage and reported cross-runtime validation; no blocking defect was found.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies this as maintainer-authored, so the external-contributor proof gate does not apply. Reported Node and custom-Bun runs exercise source-worker and agent paths; they are supplemental validation, not an independently observed live run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies this as maintainer-authored, so the external-contributor proof gate does not apply. Reported Node and custom-Bun runs exercise source-worker and agent paths; they are supplemental validation, not an independently observed live run.
Evidence reviewed 10 items Introduced production behavior: The helper selects a resolved tsx/esm preload only for Node file URLs ending in .ts, .mts, or .cts. WorkerTaskPool consumes that helper while preserving caller and prepared-worker option precedence.
Current-main necessity: The fetched main revision still sets tsx/esm for every .ts worker without checking the executable; its runtime-worker helper has no worker-thread loader selector.
Latest-release comparison: The v2026.9.4 source also unconditionally supplies tsx/esm for .ts workers, so the latest supplied release does not contain this repair.
Findings None None.
Security None None.

How this fits together

OpenClaw's worker pool runs background tasks, including Code Mode's isolated JavaScript execution. It receives worker entry URLs and task inputs, starts workers with the appropriate loader, and returns results or failures.

flowchart TD
  A[Background task] --> B[Worker pool]
  C[Worker entry URL] --> D[Runtime and extension selection]
  D --> E[Node TypeScript preload]
  D --> F[Bun native or JavaScript loading]
  E --> B
  F --> B
  B --> G[Task result or failure]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +14, Tests +46. Total +60 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 2 15 1 +14
Tests 12 65 19 +46
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 80 20 +60

Review metrics

None.

Technical review

Best possible solution:

Keep loader selection in the runtime owner, preserving Node's ESM behavior while allowing Bun to load TypeScript natively.

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

Yes, from source: running a TypeScript WorkerTaskPool entry under Bun on current main supplies the Node-only preload. The PR reports this failure; this review did not execute it.

Is this the best way to solve the issue?

Yes. The patch extends the existing runtime selection owner, retains option overrides, and preserves the Node loader contract without introducing configuration or a parallel execution path.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Repairs source-worker startup under Bun with a bounded runtime change and no demonstrated urgent production outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies this as maintainer-authored, so the external-contributor proof gate does not apply. Reported Node and custom-Bun runs exercise source-worker and agent paths; they are supplemental validation, not an independently observed live run.

Evidence

What I checked:

  • Introduced production behavior: The helper selects a resolved tsx/esm preload only for Node file URLs ending in .ts, .mts, or .cts. WorkerTaskPool consumes that helper while preserving caller and prepared-worker option precedence. (src/infra/runtime-worker-url.ts:56, 0326db5e2d47)
  • Current-main necessity: The fetched main revision still sets tsx/esm for every .ts worker without checking the executable; its runtime-worker helper has no worker-thread loader selector. (src/infra/worker-task-pool.ts:286, 89029af97dc1)
  • Latest-release comparison: The v2026.9.4 source also unconditionally supplies tsx/esm for .ts workers, so the latest supplied release does not contain this repair. (src/infra/worker-task-pool.ts:190, 3a9d69db306c)
  • Retained behavioral coverage: Existing worker-pool tests exercise import-only dependency exports, CommonJS TypeScript, compiled CommonJS, and compiled ESM. Code Mode retains ordinary execution, cancellation, isolation, and timeout coverage; Bun-only exclusions target V8 GC and module-hook instrumentation. (src/infra/worker-task-pool.source-loader.test.ts:25, 0326db5e2d47)
  • Implementation boundary: The documentation explicitly separates OpenClaw's QuickJS-WASI Code Mode from Codex Code Mode. The changed worker-loader behavior has no affirmative dependency on the Codex harness, runtime, or protocol. Public docs: docs/tools/code-mode/internals.md. (docs/tools/code-mode/internals.md:17, 0326db5e2d47)
  • Timeout-error dependency contract: The changed network-error fixture explicitly loads installed Undici. The verified v8.10.2 package identifies nodejs/undici as its repository, and ConnectTimeoutError supplies name and UND_ERR_CONNECT_TIMEOUT metadata, supporting the fixture's classification assertion. (lib/core/errors.js:21)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (2 earlier review cycles)
  • reviewed 2026-09-14T14:09:15.751Z sha ebd5cf2 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-14T14:25:21.355Z sha ebd5cf2 :: blocked before merge. :: none

@steipete
steipete force-pushed the codex/bun-agent-core-compat branch from ebd5cf2 to 0326db5 Compare September 14, 2026 16:47
@steipete
steipete requested a review from a team as a code owner September 14, 2026 16:47
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete merged commit 8430fcf into main Sep 14, 2026
193 of 194 checks passed
@steipete
steipete deleted the codex/bun-agent-core-compat branch September 14, 2026 17:56
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 15, 2026
* fix(runtime): use runtime-owned Worker loaders

* test: preserve Node-owned agent source probes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. 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