Skip to content

fix(agents): run tool code child with Node under Bun - #145688

Merged
steipete merged 1 commit into
mainfrom
codex/bun-tool-search-node-sidecar
Sep 12, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/bun-tool-search-node-sidecar

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Bun cannot run tool_search_code because the sandboxed code child requires Node's --permission flag. The runtime checked Bun's own flags and launched process.execPath, so a direct-Bun MCP recovery test failed before the code child started.

Why This Change Was Made

OpenClaw now resolves a real Node executable for runtime-specific sidecars. The resolver walks PATH plus stable system locations, skips Bun's optional node shim, verifies the requested Node flag in a sterile probe process, and caches the result by runtime and executable-search inputs. Tool Search uses that verified Node for its isolated child and advertises code mode under Bun only when a compatible Node is available. The existing test Node resolver now shares the same owner.

User Impact

Bun-hosted OpenClaw can use the full sandboxed Tool Search code mode while Node behavior stays unchanged. This adds no dependency and does not alter Node installation or package-manager behavior; it only locates an already-installed compatible Node for the child process. Electron keeps its existing structured-tool fallback.

Evidence

  • Direct custom Bun: Tool Search MCP recovery 8/8 passed; before the fix the code-mode case failed with the Node --permission runtime error.
  • Direct custom Bun: full focused Tool Search and child lifecycle set 204/204 passed, plus the Node resolver regression 1/1.
  • Node: the same focused matrix passed 213/213.
  • Bun config smoke resolves code mode in about 47 ms on the first probe and 0.02 ms from cache.
  • node scripts/check-changed.mjs: passed.
  • Test-audit: the existing shim regression protects runtime identity, the credible regression is a Bun shim being selected as Node, and the refactor adds no test-only production seam or duplicate test.
  • Independent P0-P2 autoreview: scoped clean at 0.89 confidence.

@clawsweeper

clawsweeper Bot commented Sep 12, 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 agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 12, 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 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 12, 2026, 2:24 AM ET / 06:24 UTC.

ClawSweeper review

What this changes

The PR lets Bun-hosted Tool Search run its isolated JavaScript child with an installed compatible Node executable and shares that discovery logic with test helpers.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: current main still launches the code child through the host runtime. No blocking introduced defect was found, and the maintainer-protected PR should remain open.

Priority: P2
Reviewed head: 4f6cd753158b0b4ab5446f83d665cb43cdfa2779

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with shared ownership, relevant reported validation, and no blocking correctness findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied review context identifies maintainer-authored work, so the external-contributor proof gate does not apply. Reported Bun recovery coverage exercises the registered tool and Node child with a mocked MCP backend; no new authority boundary requires additional final-effect proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied review context identifies maintainer-authored work, so the external-contributor proof gate does not apply. Reported Bun recovery coverage exercises the registered tool and Node child with a mocked MCP backend; no new authority boundary requires additional final-effect proof.
Evidence reviewed 7 items Current main still has the reported runtime coupling: The fetched main revision checks the host process’s permission flag support and spawns process.execPath for the code child; it does not discover an installed Node when hosted by Bun.
Latest-release comparison: The supplied latest release, v2026.9.4, also checks the host runtime’s allowedNodeEnvironmentFlags in its code-mode capability gate.
Shared executable discovery preserves isolation: The resolver skips Bun identities, requires the requested Node flag, strips inherited preload settings from probes, and caches results. The code child retains --permission, its empty environment, IPC bridge, and existing timeout handling.
Findings None None.
Security None None.

How this fits together

Tool Search lets agents discover and call tools through a compact JavaScript bridge. Model code runs in an isolated Node child, while actual tool execution returns to OpenClaw’s existing policy-controlled runtime.

flowchart TD
  A[Tool Search configuration] --> B{Compatible Node available?}
  C[Host runtime and executable paths] --> B
  B -->|Yes| D[Isolated Node code child]
  B -->|No| E[Structured tool fallback]
  D --> F[OpenClaw tool execution]
  E --> F
  F --> G[Tool results]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +111, Tests -33. Total +78 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 117 6 +111
Tests 1 4 37 -33
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 121 43 +78

Review metrics

Metric Value Why it matters
Runtime ownership consolidation Production +111 net lines; tests and test support −33 net lines Production growth supplies shared capability discovery and caching while removing the separate test-only implementation.

Technical review

Best possible solution:

Use one capability-checked Node resolver for the isolated child, retaining structured fallback when unavailable and existing execution safeguards.

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

Yes, from source: invoking the code tool under Bun reaches a host-runtime permission check and process.execPath launch on current main. The PR reports that failure before the fix; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes. Selecting an installed Node with the required capability fixes the child-runtime mismatch without changing stored settings, installing dependencies, or replacing tool policy enforcement.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs a bounded Tool Search failure under Bun while preserving the existing structured fallback.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied review context identifies maintainer-authored work, so the external-contributor proof gate does not apply. Reported Bun recovery coverage exercises the registered tool and Node child with a mocked MCP backend; no new authority boundary requires additional final-effect proof.

Label justifications:

  • P2: This repairs a bounded Tool Search failure under Bun while preserving the existing structured fallback.
  • 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 review context identifies maintainer-authored work, so the external-contributor proof gate does not apply. Reported Bun recovery coverage exercises the registered tool and Node child with a mocked MCP backend; no new authority boundary requires additional final-effect proof.

Evidence

What I checked:

  • Current main still has the reported runtime coupling: The fetched main revision checks the host process’s permission flag support and spawns process.execPath for the code child; it does not discover an installed Node when hosted by Bun. (src/agents/tool-search-code-mode.ts:50, ae43ac760877)
  • Latest-release comparison: The supplied latest release, v2026.9.4, also checks the host runtime’s allowedNodeEnvironmentFlags in its code-mode capability gate. (src/agents/tool-search-config.ts:44, 3a9d69db306c)
  • Shared executable discovery preserves isolation: The resolver skips Bun identities, requires the requested Node flag, strips inherited preload settings from probes, and caches results. The code child retains --permission, its empty environment, IPC bridge, and existing timeout handling. (src/infra/node-runtime-executable.ts:47, 4f6cd753158b)
  • OpenClaw implementation boundary: The Tool Search documentation explicitly distinguishes this implementation from Codex-native tool search. The changed owner launches OpenClaw’s own inline Node child; no Codex dependency contract is implicated. Public docs: docs/tools/tool-search.md. (docs/tools/tool-search.md:14, 4f6cd753158b)
  • Validation claims mapped to the production entry point: The captured PR body reports Bun MCP recovery 8/8, focused Bun coverage 204/204 plus the resolver regression, and Node coverage 213/213. The inspected recovery test calls the registered code tool and expects recovered:true through the actual child path, while supplying a mocked MCP backend. These are reported focused results, not reviewer-executed tests or live MCP-service proof. (src/agents/tool-search.mcp-error.test.ts, 4f6cd753158b)
  • Prior merged-area contribution: GitHub commit metadata identifies steipete on the earlier Bun-compatible test resolver change. Current-main history also identifies Alix-007’s Electron fallback work. Some deeper local historical blobs were unavailable, so routing does not assert verified source-line introduction. (src/test-utils/node-process.ts, 2f5822abb67e)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Alix-007: 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.

@steipete
steipete merged commit 21db4e9 into main Sep 12, 2026
189 checks passed
@steipete
steipete deleted the codex/bun-tool-search-node-sidecar branch September 12, 2026 06:58
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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