Repository navigation
fix(subagents): settle terminal non-success requester wakes durably - #137344
Conversation
|
🦞👀 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: needs real behavior proof before merge. Reviewed September 6, 2026, 3:26 AM ET / 07:26 UTC. ClawSweeper reviewWhat this changesSettles failed requester notifications for cancelled, failed, and timed-out subagents in SQLite while preserving their original task outcomes, with regression coverage for ownership, rollback, and mixed batches. Merge readiness⛔ Blocked before merge - 2 items remain This remains a useful repair absent from current main and the latest release. The revised patch resolves the earlier owner-mismatch finding; no additional correctness defect was found. Real-behavior proof remains incomplete. Priority: P1 Review scores
Verification
How this fits togetherSubagents report completed work to their requesting agent through a durable notification lifecycle. The completion store coordinates subagent delivery state and task records so rejected notifications can finish bookkeeping without replaying indefinitely. flowchart TD
A[Terminal child task] --> B[Requester notification]
B --> C[Notification rejected]
C --> D[Check persisted task and run ownership]
D --> E[Reject stale or missing owner]
D --> F[Settle matching delivery in SQLite]
F --> G[Preserve child outcome and clear pending wake]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +16, Tests +307. Total +323 across 3 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. Technical reviewBest possible solution: Keep settlement in the existing atomic owner store, preserve original terminal outcomes, and leave genuinely missing or superseded owners to separately scoped reconciliation. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the path: an undelivered wake for a matching terminal non-success child reaches the successful-only blocker and throws. The PR reports baseline failures, but this read-only review did not execute a reproduction. Is this the best way to solve the issue? Yes, the revised repair uses the canonical transaction and existing terminal classifier without bypassing stale-owner checks or changing schema, retention, or successful-completion policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ba3a6cb5f690. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
A requester-settle batch whose child already ended failed, timed_out, or cancelled (or whose owner row is gone/stale) could never settle its undelivered wake: completeRequesterSettleWakeBatch applied the successful-task-only blockSubagentCompletionDelivery unconditionally and threw when it returned false, rolling requesterSettleWake back to pending so the registry sweeper re-ran the same terminal batch forever. Split on the blocker's authoritative result: a still-owned successful completion is still closed atomically by the blocker and kept out of batch rollback, while an already-terminal/non-success child is settled locally (delivery failed + suppressed) without throwing, so requesterSettleWake clears durably and later sweeps stop. Preserves the atomic owner gate for genuine successes and never reinterprets or force-retires a terminal task. Ref openclaw#137332
dbdf62c to
5a3141e
Compare
|
Merged via squash.
|
…penclaw#137344) * fix(subagents): settle terminal non-success requester wakes durably A requester-settle batch whose child already ended failed, timed_out, or cancelled (or whose owner row is gone/stale) could never settle its undelivered wake: completeRequesterSettleWakeBatch applied the successful-task-only blockSubagentCompletionDelivery unconditionally and threw when it returned false, rolling requesterSettleWake back to pending so the registry sweeper re-ran the same terminal batch forever. Split on the blocker's authoritative result: a still-owned successful completion is still closed atomically by the blocker and kept out of batch rollback, while an already-terminal/non-success child is settled locally (delivery failed + suppressed) without throwing, so requesterSettleWake clears durably and later sweeps stop. Preserves the atomic owner gate for genuine successes and never reinterprets or force-retires a terminal task. Ref openclaw#137332 * fix(subagents): stop terminal failure completion wake replays * test: keep completion admission fixtures below lint limit --------- Co-authored-by: Jason (Json) <[email protected]>
What Problem This Solves
Fixes an issue where users with a cancelled, failed, or timed-out child task could see the main chat repeatedly fail while replaying that child's undelivered completion, including after a Gateway restart.
Related: #137332
Why This Change Was Made
The completion blocker previously accepted only successful tasks. The initial PR handled every rejection as a locally failed completion, which also admitted stale owners and left the task's delivery projection queued.
The repair now settles matching terminal non-success run/task delivery in the existing transaction. It preserves the original child outcome, error, and retention; successful-completion behavior is unchanged. Missing or changed owners remain rejected, and an already-delivered receipt cannot be downgraded. No schema, config, dependency, or protocol change.
User Impact
Cancelled and failed completions can finish their delivery bookkeeping without permanently retrying the same requester wake. Newer completion ownership and existing successful siblings remain protected.
Evidence
93792c8fa6c9: real controller and SQLite reproduction failed for cancelled, failed, and timed-out tasks withsubagent completion owner changed before settlement.5a3141e4b98d: 11 new real-store cases exposed stale-owner acceptance, incomplete queue/task settlement, and rollback/mixed-batch failures.0a6f27b1a6e2: all 214 focused tests pass (27 atomic-store tests and 187 lifecycle tests). Coverage includes killed/ok races, timeout and unknown outcomes, SQLite close/reopen, stale generation/task/receipt rejection, transaction abort, suspension rejection, and mixed batches in both orders.node scripts/run-vitest.mjs src/agents/subagents/completion/subagent-completion-admission.store.test.tsandnode scripts/run-vitest.mjs src/agents/subagents/registry/subagent-registry-lifecycle.test.ts.b63272dadac1: 27 store tests and focused type-aware lint pass after extracting two unchanged setup functions to fix the CI file-length limit. Production source and lifecycle tests are unchanged.b63272dadac1found the patch correct and the earlier ownership finding resolved. It requests a real requester-transport trace. That remains an explicitly unrun proof extension: no transport behavior changes here, and the changed atomic store, lifecycle continuation, queue recovery, rollback, and database reopen all execute for real. The failure injection supplies the unchanged transport outcome; it does not mock the owner or persistence decision. This is the chosen regression boundary for this internal state repair.Original contribution by @xydt-juyaohui; issue reported by @laurenceputra. This update preserves the contributor's commit ancestry and replaces the mocked local-fallback coverage with real-store tests.