Skip to content

fix(acp): attach error listener to spawned ACP agent process - #109529

Merged
steipete merged 2 commits into
openclaw:mainfrom
krissding:fix/acp-agent-error-listener
Jul 29, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
krissding:fix/acp-agent-error-listener

Conversation

@krissding

@krissding krissding commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

createAcpClient() spawns an agent child process but never attaches an error listener. If the agent binary is missing or fails to start, the unhandled 'error' event on the ChildProcess can crash the process.

Why This Change Was Made

The spawned agent already has an agent.on("exit", ...) handler in runAcpClientInteractive, but no corresponding error listener. An error listener prevents unhandled-error crashes when the agent process fails to start (ENOENT, permission denied, etc.).

Evidence

All 57 ACP client tests pass, no regressions:

Test Files  1 passed (1)
     Tests  57 passed (57)

Merge Risk

Low — single-file, +4 lines. The error listener logs via the existing log function (verbose-only) and lets the existing client.initialize() failure path handle the dead agent naturally.

Maintainer-verified real subprocess proof (2026-07-29)

Verified on Blacksmith Testbox tbx_01kypmr7vw2mtjbnjjsqkbh07c against both immutable revisions: original contributor commit f5b1be371d40c439b527c9f397d9ef3e4619bd83 with the actually installed ACP SDK 1.1.0, and the current-main integration commit 41b9d27042c5d85c6b093d5d13f58632a83b05d8 with the actually installed ACP SDK 1.3.0. Both runs independently verified the exact unchanged contributor source blob d8e4f731c94b033ab075c41a2a834c5aa61f541b.

Real node --import tsx src/entry.ts acp client --server <command> --verbose subprocess output, observed on both SDK versions:

$ ... acp client --server /definitely/nonexistent/openclaw-acp-s32-proof --verbose
[acp-client] initializing
[acp-client] agent error: Error: spawn /definitely/nonexistent/openclaw-acp-s32-proof ENOENT
ACP connection closed
exit=1; completed in 3s

$ ... acp client --server /dev/null --verbose
[acp-client] initializing
[acp-client] agent error: Error: spawn /dev/null EACCES
ACP connection closed
exit=1; completed in 1–2s

$ ... acp client --server /usr/bin/false --verbose
[acp-client] initializing
ACP connection closed
exit=1; completed in 1–2s

Each invocation was bounded by timeout --kill-after=2s 25s; both exact revision runs asserted the CLI returns 1 promptly, the SDK rejects with ACP connection closed, and output contains no unhandled error event, node:events: fatal stack, or uncaught exception. Real acp client --help also exited successfully on both revisions.

Current-main integration regression proof:

pnpm test src/acp/client.test.ts src/cli/acp-cli-exit.process.test.ts src/cli/acp-cli.option-collisions.test.ts
src/acp/client.test.ts                     57 passed
src/cli/acp-cli-exit.process.test.ts        5 passed
src/cli/acp-cli.option-collisions.test.ts  10 passed
3 Vitest shards passed; 72 tests; exit=0

The CLI process shard additionally exercises real Gateway-backed ACP initialization, buffered initialize delivery, bridge disconnect, and prompt help/process termination. The original SDK 1.1.0 checkout independently passed its two existing ACP/client CLI regression files (67 tests). Both remote commands returned successful provider timing records with exitCode=0.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 17, 2026
@clawsweeper

clawsweeper Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 17, 2026, 8:05 AM ET / 12:05 UTC.

Summary
Attaches an error-event listener to the ACP client’s spawned agent process and reports spawn failures through the existing verbose logger.

PR surface: Source +4. Total +4 across 1 file.

Reproducibility: yes. from source and the Node child-process contract: run the ACP client with a nonexistent agent command to trigger ENOENT, although that path was not executed during this read-only review.

Review metrics: none identified.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add a redacted terminal transcript or runtime log demonstrating the post-fix ENOENT or permission-denied path exits promptly without crashing or hanging.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Only unit-test output is provided; add a redacted terminal or runtime-log transcript showing a missing or non-executable ACP server fails promptly without a crash or hang, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.

Risk before merge

  • [P1] Without real failed-spawn output, it remains unverified that the handled error causes ACP initialization to reject promptly rather than leaving the client waiting on closed process pipes.

Maintainer options:

  1. Decide the mitigation before merge
    Keep the focused listener, then prove a nonexistent or non-executable --server command produces a prompt, readable failure without crashing or hanging the parent process.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] No automated code repair is indicated; the remaining merge gate is contributor-supplied real failed-spawn behavior proof.

Security
Cleared: The single runtime listener adds no dependency, permission, secret, artifact, workflow, or supply-chain surface.

Review details

Best possible solution:

Keep the focused listener, then prove a nonexistent or non-executable --server command produces a prompt, readable failure without crashing or hanging the parent process.

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

Yes, from source and the Node child-process contract: run the ACP client with a nonexistent agent command to trigger ENOENT, although that path was not executed during this read-only review.

Is this the best way to solve the issue?

Yes, attaching a listener at the owned ChildProcess boundary is the narrow standard fix; merge confidence still requires proof that the downstream initialization path terminates promptly.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6745f9a55328.

Label changes

Label justifications:

  • P2: This is a narrow ACP crash-prevention fix with limited surface area and no evidence of a widespread active outage.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Only unit-test output is provided; add a redacted terminal or runtime-log transcript showing a missing or non-executable ACP server fails promptly without a crash or hang, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +4. Total +4 across 1 file.

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

What I checked:

  • Changed process boundary: The PR adds the listener immediately after validating the spawned process pipes and before constructing the ACP NDJSON transport. (src/acp/client.ts:150, f5b1be371d40)
  • Node child-process contract: Node documents that a missing command emits an ENOENT error and that an EventEmitter error without a listener can terminate the parent process, directly supporting the reported failure mode.
  • ACP transport path: The ACP client creates a ClientSideConnection over the spawned process stdin and stdout, so the listener is placed at the correct owner boundary rather than adding a global uncaught-error workaround. (src/acp/client.ts:154, f5b1be371d40)
  • Proof remains synthetic: The PR body reports 57 passing ACP client tests but contains no terminal transcript, runtime log, recording, or linked artifact showing a missing or non-executable agent command after the fix. (src/acp/client.test.ts, f5b1be371d40)
  • Feature provenance: The interactive ACP client was introduced in commit 9809b47, while commit b7615e0 later updated the spawned ACP client environment, connecting Peter Steinberger and Vincent Koc to this lifecycle surface. (src/acp/client.ts, 9809b47d45)
  • Current-main necessity check: No matching error listener or merged replacement was established on current main at 6745f9a, so the PR remains potentially necessary rather than obsolete. (src/acp/client.ts:147, 6745f9a55328)

Likely related people:

  • steipete: The interactive ACP client and its spawned-process lifecycle appear to date to commit 9809b47. (role: introduced behavior; confidence: high; commits: 9809b47d45; files: src/acp/client.ts, src/acp/client.test.ts)
  • vincentkoc: Commit b7615e0 modified the same spawned ACP client boundary to carry the runtime shell environment marker. (role: recent adjacent contributor; confidence: high; commits: b7615e0ce3; files: src/acp/client.ts, src/acp/client.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-17T09:57:33.182Z sha b9b8dfd1f7c2995c6f10a6ef6ce30af8ec7d6325 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T10:12:33.034Z sha 7528da89b365b88b0980dfb2b105094daa97c3e4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T10:21:14.596Z sha 7528da89b365b88b0980dfb2b105094daa97c3e4 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T10:32:07.809Z sha cafdc420168619ab8253cae100e439f0583f05a6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T10:50:54.339Z sha f5b1be3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T11:05:37.617Z sha f5b1be3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T11:13:06.070Z sha f5b1be3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-17T11:24:13.229Z sha f5b1be3 :: needs real behavior proof before merge. :: none

@krissding
krissding force-pushed the fix/acp-agent-error-listener branch from 5108da7 to b9b8dfd Compare July 17, 2026 09:52
@krissding krissding closed this Jul 17, 2026
@krissding krissding reopened this Jul 17, 2026
@krissding
krissding force-pushed the fix/acp-agent-error-listener branch from 7528da8 to cafdc42 Compare July 17, 2026 10:26
@krissding krissding closed this Jul 17, 2026
@krissding krissding reopened this Jul 17, 2026
The spawned agent child process in createAcpClient had no error
listener. If the agent binary failed to start, the error event
would be unhandled and could crash the process.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@krissding
krissding force-pushed the fix/acp-agent-error-listener branch from cafdc42 to f5b1be3 Compare July 17, 2026 10:44
@krissding krissding closed this Jul 17, 2026
@krissding krissding reopened this Jul 17, 2026
@krissding krissding closed this Jul 17, 2026
@krissding krissding reopened this Jul 17, 2026
@krissding krissding closed this Jul 17, 2026
@krissding krissding reopened this Jul 17, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 17, 2026
@krissding krissding closed this Jul 17, 2026
@krissding krissding reopened this Jul 17, 2026
@steipete
steipete merged commit ee820b1 into openclaw:main Jul 29, 2026
197 of 200 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

vincentkoc added a commit to yetval/openclaw that referenced this pull request Jul 29, 2026
* origin/main: (224 commits)
  fix(memory): preserve Windows session ownership (openclaw#115851)
  fix(compaction): drop context-engine fallback on codex ownership skip (openclaw#114155) (openclaw#115666)
  fix(msteams): ignore blank certificate settings (openclaw#109112)
  fix(usage): guard malformed DeepSeek payloads (openclaw#110785)
  docs(agents): reword imported review rules in repo voice
  docs(agents): add context-budget, tool-description, cache-invalidation, and review-premise rules
  docs(agents): mock-gateway proof satisfies gate without discouraging live proof
  docs(agents): add vitest in-flight edit rule and mock-gateway proof recipe
  docs(agents): restructure root AGENTS.md around product doctrine and deduped policy
  fix(codex): keep completed answers over audit gaps (openclaw#115849)
  test(cli): isolate unknown-command process validation (openclaw#115848)
  fix(memory-host-sdk): resolve stable execPath for worker fork to survive Homebrew Node upgrades (openclaw#99318)
  feat(ui): add composer capability menu (openclaw#115800)
  fix(synology-chat): stop fabricating send message ids (openclaw#110770)
  fix(feishu): reply to direct messages by chat id (openclaw#109637)
  fix(acp): attach error listener to spawned ACP agent process (openclaw#109529)
  fix(sessions): deliver agent announcements to direct message sessions (openclaw#115811)
  fix(nextcloud-talk): reject reactions for disabled or unconfigured accounts (openclaw#112675)
  refactor(ui): move Agent Defaults entry from the sidebar into the Agents page (openclaw#115836)
  feat(gateway): push session PR indicators to subscribed clients (openclaw#115643)
  ...

# Conflicts:
#	src/agents/apply-patch.ts
#	src/agents/sandbox/fs-bridge-mutation-helper.ts
pull Bot pushed a commit to yann0001/openclaw that referenced this pull request Jul 29, 2026
* origin/main:
  docs(agents): reword imported review rules in repo voice
  docs(agents): add context-budget, tool-description, cache-invalidation, and review-premise rules
  docs(agents): mock-gateway proof satisfies gate without discouraging live proof
  docs(agents): add vitest in-flight edit rule and mock-gateway proof recipe
  docs(agents): restructure root AGENTS.md around product doctrine and deduped policy
  fix(codex): keep completed answers over audit gaps (openclaw#115849)
  test(cli): isolate unknown-command process validation (openclaw#115848)
  fix(memory-host-sdk): resolve stable execPath for worker fork to survive Homebrew Node upgrades (openclaw#99318)
  feat(ui): add composer capability menu (openclaw#115800)
  fix(synology-chat): stop fabricating send message ids (openclaw#110770)
  fix(feishu): reply to direct messages by chat id (openclaw#109637)
  fix(acp): attach error listener to spawned ACP agent process (openclaw#109529)
  fix(sessions): deliver agent announcements to direct message sessions (openclaw#115811)
  fix(nextcloud-talk): reject reactions for disabled or unconfigured accounts (openclaw#112675)
  refactor(ui): move Agent Defaults entry from the sidebar into the Agents page (openclaw#115836)
  feat(gateway): push session PR indicators to subscribed clients (openclaw#115643)
  fix(setup): make Gemini recovery actionable (openclaw#115835)
  fix(terminal-core): prevent String.replace $ pattern injection in display-string (openclaw#111398)
  refactor(channels): share ingress retention defaults (openclaw#115824)
  fix(nostr): profile imports vary on timestamp ties (openclaw#111798)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 30, 2026
…w#109529)

The spawned agent child process in createAcpClient had no error
listener. If the agent binary failed to start, the error event
would be unhandled and could crash the process.

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 30, 2026
* origin/main:
  docs(agents): reword imported review rules in repo voice
  docs(agents): add context-budget, tool-description, cache-invalidation, and review-premise rules
  docs(agents): mock-gateway proof satisfies gate without discouraging live proof
  docs(agents): add vitest in-flight edit rule and mock-gateway proof recipe
  docs(agents): restructure root AGENTS.md around product doctrine and deduped policy
  fix(codex): keep completed answers over audit gaps (openclaw#115849)
  test(cli): isolate unknown-command process validation (openclaw#115848)
  fix(memory-host-sdk): resolve stable execPath for worker fork to survive Homebrew Node upgrades (openclaw#99318)
  feat(ui): add composer capability menu (openclaw#115800)
  fix(synology-chat): stop fabricating send message ids (openclaw#110770)
  fix(feishu): reply to direct messages by chat id (openclaw#109637)
  fix(acp): attach error listener to spawned ACP agent process (openclaw#109529)
  fix(sessions): deliver agent announcements to direct message sessions (openclaw#115811)
  fix(nextcloud-talk): reject reactions for disabled or unconfigured accounts (openclaw#112675)
  refactor(ui): move Agent Defaults entry from the sidebar into the Agents page (openclaw#115836)
  feat(gateway): push session PR indicators to subscribed clients (openclaw#115643)
  fix(setup): make Gemini recovery actionable (openclaw#115835)
  fix(terminal-core): prevent String.replace $ pattern injection in display-string (openclaw#111398)
  refactor(channels): share ingress retention defaults (openclaw#115824)
  fix(nostr): profile imports vary on timestamp ties (openclaw#111798)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants