Repository navigation
fix: extension api.exec leaves child processes after timeout - #98340
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 30, 2026, 10:56 PM ET / 02:56 UTC. Summary PR surface: Source +10, Tests +30. Total +40 across 2 files. Reproducibility: yes. at source level: current main and Review metrics: none identified. Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Pick one canonical implementation for the linked issue, ideally preserving this PR's direct ExtensionAPI.exec proof and the sibling branch's broader focused test coverage. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main and Is this the best way to solve the issue? Yes for the implementation shape: reusing AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4ac5cf863673. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +10, Tests +30. Total +40 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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
|
|
I ran the missing real behavior proof against this PR head ( Setup: local checkout of the PR head, using Observed result: {"prHead":"54f1410d992812a11cddc13a85e21cb3e3ee894c","surface":"ExtensionAPI.exec","killed":true,"code":0,"grandchildAlive":false}Focused test also passed on the same PR checkout: No secrets or external services were involved. This directly exercises the |
|
@clawsweeper re-review |
|
One follow-up: the PR body still says no live descendant-process proof was run. The proof is now available in #98340 (comment), but ClawSweeper may keep the Suggested body update: add the {"prHead":"54f1410d992812a11cddc13a85e21cb3e3ee894c","surface":"ExtensionAPI.exec","killed":true,"code":0,"grandchildAlive":false}That should make the proof state match the current PR reality. |
|
Added live Windows proof through the ExtensionAPI.exec boundary: a registered extension command spawned a long-lived descendant, api.exec timed out, and the descendant PID was no longer alive after cleanup. @clawsweeper re-review |
Fixes #98335
What Problem This Solves
Fixes an issue where session extensions using
api.exec()could leave descendant processes running when a command timed out, was aborted, or exceeded the default output cap. The API reported the command as killed, but the old termination path only signaled the direct child process.Why This Change Was Made
api.exec()now uses the shared OpenClaw process-tree termination helper for timeout, abort, and output-limit cleanup, with the same detached Unix process-group setup used by the built-in shell execution paths. The directproc.kill()fallback is retained only for the rare case where Node does not expose a child PID.The runtime entry point is
ExtensionAPI.execinsrc/agents/sessions/extensions/loader.ts, which delegates extension commands toexecCommand(). This PR keeps theapi.exec()result shape unchanged and only changes how cleanup is performed after the command must be stopped.User Impact
Extension authors and operators can expect
api.exec()cleanup to stop wrapper commands and their descendants instead of leaving background child processes behind after cancellation or timeout. The command output/result contract is unchanged.Evidence
main:src/agents/sessions/exec.tspreviously calledproc.kill(SIGTERM)and laterproc.kill(SIGKILL)inkillProcess(), so timeout/abort/output-limit cleanup targeted only the direct child process.execCommand()now spawns withdetached: process.platform !== "win32"and callskillProcessTree(proc.pid, { detached: process.platform !== "win32", graceMs: 5000 })when cleanup is required.loadExtensionFromFactory(), registered a command whose handler callsapi.exec(process.execPath, ["-e", parentScript], { timeout: 500 }), and made that parent spawn a 30-second descendant Node process before idling. After the timeout, the descendant PID was no longer alive:node scripts/run-vitest.mjs src/agents/sessions/exec.test.tspassed, 1 file / 5 tests..\node_modules\.bin\oxlint.cmd src/agents/sessions/exec.ts src/agents/sessions/exec.test.tspassed.git diff --checkpassed.python .agents\skills\autoreview\scripts\autoreview --mode localreturnedautoreview clean: no accepted/actionable findings reported.ExtensionAPI.execmethod that loaded extensions receive and the same backend cleanup path this PR changes.