Repository navigation
fix: clear stale subagent activity after restart cleanup - #146248
Conversation
Settle orphaned native runs through canonical completion before cleanup, keep task-write failures retriable, and reconcile previously stranded registry-backed tasks without hiding live work. Closes #146224 Co-authored-by: VACInc <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 12, 2026, 4:39 PM ET / 20:39 UTC (Revision 6). ClawSweeper reviewWhat this changesThe PR settles orphaned subagent tasks before cleanup, retries failed task updates, and reconciles previously stranded activity through Gateway maintenance. Merge readiness⛔ Blocked before merge - 3 items remain This repair remains necessary on current main, and no blocking code defect was found. The protected PR has sufficient real behavior evidence, but acceptance of its durable recovery behavior remains explicitly pending. Priority: P2 Review scores
Verification
How this fits togetherThe subagent registry tracks delegated work and records its outcomes in the persistent task ledger. Gateway maintenance reconciles abandoned work, and Control UI displays the resulting task activity. flowchart TD
A[Gateway restart] --> B[Restore subagent runs]
B --> C{Surviving owner?}
C -->|Yes| D[Preserve or recover work]
C -->|No| E[Complete orphaned work]
F[Stranded task maintenance] --> G[Persistent task ledger]
E --> G
G --> H[Control UI activity]
Decision needed
Why: The repository requires acceptance of material durable recovery changes, and the linked proposal explicitly remains pending. Before merge
Agent review detailsSecurityNone. PR surfaceSource -7, Tests +153, Docs +2, Other 0. Total +148 across 21 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep completion and maintenance as the canonical owners of truthful task activity, with explicit acceptance of bounded automatic recovery and its retention consequences. Do we have a high-confidence way to reproduce the issue? Yes: current-main source still permits orphan deletion without task settlement and accepts retained sessions as liveness. The recorded before/after Gateway run corroborates this mechanism; this review did not execute target code. Is this the best way to solve the issue? Yes: repairing canonical completion and maintenance avoids a competing UI interpretation of liveness and preserves existing recovery owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0f367f2e199d. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
Keep the exact failed-task write fault active until cancellation publishes its result, then release it without weakening generation, cascade, or successor assertions. Co-authored-by: VACInc <[email protected]>
Include the upstream diagnostics scenario selector correction from #146323. Preserve the existing subagent repair without changing its implementation. Co-authored-by: VACInc <[email protected]>
|
Added source-bound live before/after acceptance to the PR body: real Gateway processes, native spawn/read, SQLite persistence, cold restarts, and Chromium. Before the fix, the native owner disappears while the task/UI remains running; with the fix, recovery completes the original task and the ghost row disappears. Synthetic local model endpoint and accelerated stale-time window are explicitly documented. The CI fixture repair is in place, and head @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Proposed bounded recovery design — acceptance pendingClawSweeper’s current storage-review question is a maintainer decision, not a code finding. This comment proposes the scope; it does not assert that a human has accepted it. The implementation remains unmerged and undeployed.
Decision requested from @VACInc: accept this bounded automatic-recovery behavior for PR #146248? This is design acceptance only, not permission to merge or deploy. Reference: |
…6248) * fix: clear stale subagent activity after restart cleanup Settle orphaned native runs through canonical completion before cleanup, keep task-write failures retriable, and reconcile previously stranded registry-backed tasks without hiding live work. Closes openclaw#146224 Co-authored-by: VACInc <[email protected]> * test: retain the cancellation race during task settlement retries Keep the exact failed-task write fault active until cancellation publishes its result, then release it without weakening generation, cascade, or successor assertions. Co-authored-by: VACInc <[email protected]> --------- Co-authored-by: roboclaw-bot <[email protected]> Co-authored-by: VACInc <[email protected]>
…nts_wait forever - Reject sessions_yield from a Swarm collector turn before any claim source runs, so no durable yield intent is recorded against a child row, and return a diagnostic telling the model to finish the turn so its collected result is recorded for whoever waits on the run. This admission layer only sees turns whose tool factory is given collector context. - Settle a yielded terminal for a run with collect === true as an ordinary ok terminal on both the lifecycle-event path and the agent.wait observer path. A collector is read by an explicit wait and never receives a requester continuation, so a parked collector row has no wake source at all and its waiter blocks until the operator gives up. - Keep a result the collector already captured through structured_output; a collector that captured nothing keeps the existing "structured_output was not called" diagnostic instead of having a valid result overwritten. - Settle as ok rather than a cancellation: a yielded terminal can also look aborted, and any other settlement would reintroduce the false cancellation notice from openclaw#92448. - Leave every non-collector yielded terminal on the shipped markSubagentRunPausedAfterYield path. The documented sub-agent self-yield-for-external-work contract preserved in openclaw#125850 is unchanged; openclaw#141474 carries clawsweeper:needs-product-decision for that arm. - Write no pauseReason on the settle path, so downstream pauseReason === "sessions_yield" guards, openclaw#146248 retention, and the paused-run adoption added by openclaw#146667 are untouched: they select paused rows, which a settled collector never becomes. - Document the collector rule in the sessions_yield and Swarm docs, qualified to demonstrated behavior rather than universal tool hiding: the tool is withheld where collector context reaches the tool factory, such as the embedded runner; a CLI-backed collector turn through the Gateway tool resolver can still be offered it and receive a successful yielded result; and in every case the terminal settle is what resolves the waiter. - Repoint the yielded-continuation reset case added by openclaw#146565 at an ordinary announcing sub-agent fixture, with every assertion unchanged, because a yielded collector is now settled at its terminal and is no longer a continuation to preserve. Add a sibling case pinning that contract: a yielded collector completes with no pauseReason and a frozen collectorCompletion, and sessions.reset then revokes its cleanup as a completed run. - Await the durable cleanup mark of the settled collector in that reset case, not the residual-roots deadline. Its cleanup: "delete" work is dispatched detached and takes 0.5 s to 3.9 s locally depending on whether the SQLite reclamation worker starts cold, so the one-second vi.waitFor inside settleSubagentRegistryPersistenceWork could observe a live registry root under CI load. The guard and every assertion are unchanged. Related: openclaw#141474
Closes #146224
Additional instructions
Maintainers can edit this branch in the main repository.
What Problem This Solves
Fixes an issue where users viewing Control UI could see subagent activity remain running after restart cleanup removed its native run owner. The task kept its last tool name, such as
processorsessions_yield, even though the retained chat session was not proof of active work.Why This Change Was Made
Orphan handling now uses the existing completion lifecycle rather than deleting registry entries through a separate cleanup path. Known linked-task write failures keep completion retriable before cleanup, and Gateway maintenance reconciles tasks stranded by earlier pruning only when their live and durable owners are absent.
Actual live runs, queued/yielded work, replacement generations, restart recovery, and pending completion delivery retain ownership. No UI-only hiding, schema/config changes, or changes to execution timeouts.
User Impact
Orphaned work reaches an honest terminal state instead of appearing to run indefinitely. Existing stranded task records can also converge through normal Gateway maintenance. Genuine detached work stays visible after its parent turn ends.
Reported by @VACInc.
Evidence
autoreview --mode localreturnedscoped-cleanat the workflow default P0 threshold, including the split regression groups and test fixtures.node scripts/check-changed.mjspassed, including formatting, core/core-test typechecks, changed-file lint, import-cycle and dead-export checks, and repository guards.Focused command:
Live before/after acceptance — September 12, 2026
Both cases ran real built Gateway processes, native
chat.send→sessions_spawn→ childread, real SQLite persistence, cold process restarts, and Chromium UI. The model endpoint was a deterministic local HTTP/SSE fixture. Only the initial Gateway clock was shifted three hours behind, then returned to normal on restart, to exercise stale-run handling without a three-hour wait. No expected task status or UI fields were seeded and no Gateway requests were mocked.bec4d2172b8c4aa58e847dfcrunningcompletedthrough the original task IDThis live case verifies that eligible work is recovered and genuinely completed, not merely hidden. The already-stranded-row maintenance repair remains covered by the isolated persistence regression.
The same driver and Node 24.18.1 ran in distinct rootless, network-none containers using image
fee853fafa59550d162cef52bca02d907694b44ebf6ef9fb075bcc0c65d8dedb. Each case crossed container PID 50 → 143, with the original process confirmed gone; these are separate container PID namespaces, not host PIDs. Source/dependencies were read-only and host credentials were not forwarded. Gateway/provider processes were stopped, temporary SUT state removed, and the proof containers removed. The operator Gateway was not changed or deployed.The captures below are the original inspected 1280×900 screenshots. The GitHub-hosted SVG assets embed the PNG bytes unchanged; Chromium verified pixel-for-pixel equivalence.
Before fix — orphaned task still shown as running
After fix — original task recovered and completed
CI follow-through
checks-node-compact-large-5then passed in hosted run34711854134.6b92ac80b5ab; 20 QA runner tests passed locally on the corrected baseline.6615cff9bd2dae48deef9b23c14cb7f8c4f7b012. This is a main refresh with an identical repair patch (stable patch ID118ac1d2e736d7fd7016c5ca534e456038863adb); the live proof above names the revisions actually executed.Final CI result and remaining decision
6615cff9bd2dae48deef9b23c14cb7f8c4f7b012at September 12, 2026, 19:55:25 UTC. The aggregateopenclaw/ci-gatepassed. One failed-job rerun cleared anETXTBSYnative-compiler launch failure in an unchanged fixture; no assertion or product code was weakened.Worked on by
View the OpenClaw team session