Skip to content

fix(process): prevent one-shot agents exiting while polling - #144268

Merged
vincentkoc merged 3 commits into
mainfrom
openclaw/fix-process-poll-liveness-144248
Sep 13, 2026
Merged

vincentkoc merged 3 commits into
mainfrom
openclaw/fix-process-poll-liveness-144248

Conversation

@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Closes #144248

What Problem This Solves

Fixes an issue where users running one-shot agents would lose the final result and exit with code 13 when a background command completed during a waiting process poll. The command could finish successfully while the agent returned no JSON envelope.

Why This Change Was Made

Keep the timer referenced only while an active poll is awaiting its next state check. This preserves abort handling, timer/listener cleanup, the 30-second wait cap, and terminal process-registry readback without adding a CLI-wide keepalive or changing background retention timers.

User Impact

One-shot callers can receive the completed background process result instead of exiting with an unsettled top-level await. Gateway callers retain the same bounded, interruptible polling behavior.

Evidence

  • Added a real standalone Node regression that imports this checkout’s exec runtime, supervisor/registry, and process tool. It runs a finite Node command with isolated state and a minimal environment; no IPC, provider server, or dummy keepalive masks process exit.
  • Before the fix on 93f424ebe327af1ff9f19c380c6a7577fea2e4f9: the command wrote background-complete to its output artifact, but the one-shot process exited with code 13 at the awaited process-tool call.
  • After the fix: the same regression exits naturally with code 0, returns parseable complete tool-result JSON with status: completed and exitCode: 0, and retains the command artifact.
  • 46 focused tests pass across liveness, poll-timeout, and supervisor-cancellation tests, including abort, timeout clamping, output delivery, and terminal retention. Tested on Linux x64 with Node 26.7.0.
  • Changed-scope checks pass: formatting, core and core-test typechecks, lint (0 warnings/errors), and all selected guards.
  • Independent autoreview: scoped-clean, P0–P2, no actionable findings.

This is real process-tool/runtime boundary proof, not a full scripted-provider CLI replay. The issue’s benchmark results are reporter observations; no paid benchmark campaign was rerun.

Thanks to @osolmaz for the detailed reproduction and diagnosis.


View the OpenClaw team session

roboclaw-bot and others added 2 commits September 10, 2026 18:11
Keep an actively awaited process poll timer referenced so child completion
cannot strand the one-shot caller before it receives the terminal result.
Preserve bounded waits and abort cleanup. Add a real standalone runtime
regression that fails with exit 13 before the fix and exits 0 afterward.

Closes #144248

Co-authored-by: steipete <[email protected]>
Co-authored-by: Kimiyu-186 <[email protected]>
OpenClaw-Publication: 68ef9a40-23c3-493d-8ca5-0ff28e2f59fa
@clawsweeper

clawsweeper Bot commented Sep 10, 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 app: android App: android agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 10, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review September 10, 2026 18:21
@openclaw-barnacle openclaw-barnacle Bot added size: S and removed app: android App: android size: M labels Sep 10, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 10, 2026, 2:30 PM ET / 18:30 UTC.

ClawSweeper review

What this changes

Keeps an active process poll alive until its next state check and adds a standalone regression verifying successful background completion and returned JSON.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary: current main and v2026.9.3 retain the premature-exit mechanism. The focused patch addresses it without changing polling limits or cancellation behavior, and no blocking defect was found.

Priority: P1
Reviewed head: a06133497e7df8820984cc82612ddd70bd4a2e5d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A narrow owner-level correction with meaningful standalone process proof and complementary timeout and cancellation coverage.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured PR evidence records standalone Linux Node execution through the real exec runtime and process-tool boundary: background completion previously stranded the poll with exit 13; afterward it returned completed JSON and exited zero. This covers the changed liveness contract, without claiming a full provider-backed CLI replay.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured PR evidence records standalone Linux Node execution through the real exec runtime and process-tool boundary: background completion previously stranded the poll with exit 13; afterward it returned completed JSON and exited zero. This covers the changed liveness contract, without claiming a full provider-backed CLI replay.
Evidence reviewed 7 items Introduced change and lifecycle: The pinned merge-base-to-head patch removes only the poll timer's unref call from production code. The complete process-tool module retains timer/listener cleanup, abort rejection, the 30-second cap, and terminal-state readback.
Current main still needs the fix: The fetched main revision still calls timer.unref inside sleepPollInterval.
Latest release remains affected: The v2026.9.3 source also retains the unreferenced poll timer; this is not an already-shipped fix.
Findings None None.
Security None None.

How this fits together

OpenClaw's exec runtime registers background commands, and the process tool reads their output and completion state. A waiting poll must keep a one-shot agent alive long enough to receive that result.

flowchart TD
  A[Agent starts command] --> B[Exec runtime and supervisor]
  B --> C[Process registry]
  D[Agent requests waiting poll] --> E[Referenced poll timer]
  E --> C
  C --> F{Command finished?}
  F -->|No and time remains| E
  F -->|Yes or wait expires| G[Return process result]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source 0, Tests +83. Total +83 across 2 files.

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

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #144248
Summary: This PR is the explicit candidate fix for the reported one-shot poll exit.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep liveness ownership in the active poll, preserving bounded cancellation and independently expiring background-result retention.

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

Yes: the reported background-exec-then-poll sequence and current-main unreferenced timer establish a concrete reproduction path; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes: retaining the existing awaited timer repairs the owning lifecycle directly, without a CLI-wide keepalive or a competing polling mechanism.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The linked report demonstrates one-shot agent runs exiting with code 13 and losing their final response after a successful background command.
  • 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. Sufficient (live_output): The captured PR evidence records standalone Linux Node execution through the real exec runtime and process-tool boundary: background completion previously stranded the poll with exit 13; afterward it returned completed JSON and exited zero. This covers the changed liveness contract, without claiming a full provider-backed CLI replay.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured PR evidence records standalone Linux Node execution through the real exec runtime and process-tool boundary: background completion previously stranded the poll with exit 13; afterward it returned completed JSON and exited zero. This covers the changed liveness contract, without claiming a full provider-backed CLI replay.

Evidence

What I checked:

  • Introduced change and lifecycle: The pinned merge-base-to-head patch removes only the poll timer's unref call from production code. The complete process-tool module retains timer/listener cleanup, abort rejection, the 30-second cap, and terminal-state readback. (src/agents/bash-tools.process.ts:231, a06133497e7d)
  • Current main still needs the fix: The fetched main revision still calls timer.unref inside sleepPollInterval. (src/agents/bash-tools.process.ts:253, 4742db869720)
  • Latest release remains affected: The v2026.9.3 source also retains the unreferenced poll timer; this is not an already-shipped fix. (src/agents/bash-tools.process.ts, 1391f7cd2d40)
  • Production-boundary regression and recorded result: The complete added test launches standalone Node with isolated state, invokes the real exec runtime, supervisor, registry, and process tool, and checks the command artifact, completed tool-result JSON, and natural exit zero. The captured PR body reports exit 13 before the fix and exit zero afterward on Linux x64 with Node 26.7.0, plus 46 focused passing tests. This review inspected the source and recorded results without executing tests. (src/agents/bash-tools.process.liveness.test.ts:10, a06133497e7d)
  • Existing owner and supported behavior: The lazy process-tool adapter delegates to createProcessTool, and the documented background-command workflow explicitly supports polling for quiet successful completion. Exec runtime finalization records completion in the registry; its retention sweeper remains unreferenced. The changed behavior is owned by OpenClaw and has no affirmative Codex dependency signal. (src/agents/lazy-process-tool.ts:16, a06133497e7d)
  • Feature-history routing: Current-main file history shows repeated process-tool maintenance by Peter Steinberger. GitHub commit metadata identifies steipete for the earlier poll-clamping change and provides its helper patch. Some local historical blobs were unavailable, so local blame could not complete; no causal authorship conclusion depends on that incomplete blame. (src/agents/bash-tools.process.ts:231, d674225d88cf)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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.

@vincentkoc
vincentkoc merged commit 4abc888 into main Sep 13, 2026
253 of 254 checks passed
@vincentkoc
vincentkoc deleted the openclaw/fix-process-poll-liveness-144248 branch September 13, 2026 12:10
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '4aff70f27016f9acf62d0acc19c8bd3592993e4c': (1537 commits)
  test: align plugin fixtures with current runtime contracts (#147000)
  refactor(browser): separate session tab tracking from cleanup (#146973)
  fix(tests): make systemd clock fixtures private (#146990)
  fix(linux): retire sleep guards when logind disconnects (#146046)
  refactor(matrix): share draft fallback delivery (#144840)
  fix(sessions): preserve cross-agent replies after reload (#146799)
  test(models): cover quota recovery during catalog discovery (#146708)
  fix(macos): recover browser sign-in when no browser opens (#146787)
  fix(process): prevent one-shot agents exiting while polling (#144268)
  fix(status): label the session inventory as stored (#146979)
  fix: avoid repeated background reads while loading chat (#146953)
  refactor(ui): narrow Skill Workshop proposal context (#146977)
  perf(sessions): keep cleanup responsive and reuse workers (#140897)
  fix(sessions): prevent stranded writers after abort and restart (#146792)
  refactor: reuse deferred owners in Gateway and infra fixtures (#146809)
  fix: prevent queued conversation replies from switching storage (#146984)
  test(ui): preserve nested failure summaries in CI logs (#146864)
  fix(test): respect process memory limits in local scheduling (#146298)
  fix: validate large media data URLs without regexp stack exhaustion (#146972)
  fix(ui): label model usage contributions as messages (#146735)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* temp/pr-145950: (101 commits)
  refactor(memory-wiki): share freshness result construction (#146935)
  improve(gateway): use metadata projection for presence (#146817)
  test(agents): reuse complete Responses model fixtures (#147015)
  fix(sessions): align the reclamation-memory test with the archive session owner (#147028)
  refactor(terminal): simplify copy-sensitive token checks (#146934)
  refactor(media): remove duplicate spaced path fallback (#146933)
  refactor(cli): reuse command-group names (#146893)
  improve(plugins): reduce JavaScript generation capture work (#146993)
  test: align plugin fixtures with current runtime contracts (#147000)
  refactor(browser): separate session tab tracking from cleanup (#146973)
  fix(tests): make systemd clock fixtures private (#146990)
  fix(linux): retire sleep guards when logind disconnects (#146046)
  refactor(matrix): share draft fallback delivery (#144840)
  fix(sessions): preserve cross-agent replies after reload (#146799)
  test(models): cover quota recovery during catalog discovery (#146708)
  fix(macos): recover browser sign-in when no browser opens (#146787)
  fix(process): prevent one-shot agents exiting while polling (#144268)
  fix(status): label the session inventory as stored (#146979)
  fix: avoid repeated background reads while loading chat (#146953)
  refactor(ui): narrow Skill Workshop proposal context (#146977)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '060e856e5f9df245d63c98990fcb47e18108c6b9': (97 commits)
  refactor(memory-wiki): share freshness result construction (#146935)
  improve(gateway): use metadata projection for presence (#146817)
  test(agents): reuse complete Responses model fixtures (#147015)
  fix(sessions): align the reclamation-memory test with the archive session owner (#147028)
  refactor(terminal): simplify copy-sensitive token checks (#146934)
  refactor(media): remove duplicate spaced path fallback (#146933)
  refactor(cli): reuse command-group names (#146893)
  improve(plugins): reduce JavaScript generation capture work (#146993)
  test: align plugin fixtures with current runtime contracts (#147000)
  refactor(browser): separate session tab tracking from cleanup (#146973)
  fix(tests): make systemd clock fixtures private (#146990)
  fix(linux): retire sleep guards when logind disconnects (#146046)
  refactor(matrix): share draft fallback delivery (#144840)
  fix(sessions): preserve cross-agent replies after reload (#146799)
  test(models): cover quota recovery during catalog discovery (#146708)
  fix(macos): recover browser sign-in when no browser opens (#146787)
  fix(process): prevent one-shot agents exiting while polling (#144268)
  fix(status): label the session inventory as stored (#146979)
  fix: avoid repeated background reads while loading chat (#146953)
  refactor(ui): narrow Skill Workshop proposal context (#146977)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '4aff70f27016f9acf62d0acc19c8bd3592993e4c': (30 commits)
  test: align plugin fixtures with current runtime contracts (#147000)
  refactor(browser): separate session tab tracking from cleanup (#146973)
  fix(tests): make systemd clock fixtures private (#146990)
  fix(linux): retire sleep guards when logind disconnects (#146046)
  refactor(matrix): share draft fallback delivery (#144840)
  fix(sessions): preserve cross-agent replies after reload (#146799)
  test(models): cover quota recovery during catalog discovery (#146708)
  fix(macos): recover browser sign-in when no browser opens (#146787)
  fix(process): prevent one-shot agents exiting while polling (#144268)
  fix(status): label the session inventory as stored (#146979)
  fix: avoid repeated background reads while loading chat (#146953)
  refactor(ui): narrow Skill Workshop proposal context (#146977)
  perf(sessions): keep cleanup responsive and reuse workers (#140897)
  fix(sessions): prevent stranded writers after abort and restart (#146792)
  refactor: reuse deferred owners in Gateway and infra fixtures (#146809)
  fix: prevent queued conversation replies from switching storage (#146984)
  test(ui): preserve nested failure summaries in CI logs (#146864)
  fix(test): respect process memory limits in local scheduling (#146298)
  fix: validate large media data URLs without regexp stack exhaustion (#146972)
  fix(ui): label model usage contributions as messages (#146735)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
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 P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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.

[Bug]: process poll can exit one-shot agents with code 13

2 participants