Skip to content

fix(subagents): settle terminal non-success requester wakes durably - #137344

Merged
fuller-stack-dev merged 4 commits into
openclaw:mainfrom
xydt-juyaohui:fix/issue-137332-requester-settle-terminal-nonsuccess
Sep 6, 2026
Merged

fuller-stack-dev merged 4 commits into
openclaw:mainfrom
xydt-juyaohui:fix/issue-137332-requester-settle-terminal-nonsuccess

Conversation

@xydt-juyaohui

@xydt-juyaohui xydt-juyaohui commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Current-main baseline 93792c8fa6c9: real controller and SQLite reproduction failed for cancelled, failed, and timed-out tasks with subagent completion owner changed before settlement.
  • Original PR 5a3141e4b98d: 11 new real-store cases exposed stale-owner acceptance, incomplete queue/task settlement, and rollback/mixed-batch failures.
  • Combined current-main head 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.
  • Commands: node scripts/run-vitest.mjs src/agents/subagents/completion/subagent-completion-admission.store.test.ts and node scripts/run-vitest.mjs src/agents/subagents/registry/subagent-registry-lifecycle.test.ts.
  • Autoreview found no blocking/P0 defects in the repair. The later helper extraction and upstream import-conflict resolution were mechanical; the combined branch was retested.
  • Final head 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.
  • Exact-head CI and full local changed checks pass.
  • This is real controller/shared-store boundary proof with injected delivery failure, not a complete live Gateway restart or external-channel test.
  • Latest ClawSweeper review of b63272dadac1 found 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.

@clawsweeper

clawsweeper Bot commented Sep 3, 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 agents Agent runtime and tooling size: M labels Sep 3, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 6, 2026, 3:26 AM ET / 07:26 UTC.

ClawSweeper review

What this changes

Settles 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
Reviewed head: b63272dadac15f9fe6575ff3eb83e64087ed3c89

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused repair and store regressions are solid, but the remaining mocked requester boundary leaves mandatory runtime proof incomplete.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The supplied after-fix evidence exercises the real lifecycle controller and SQLite settlement, including reopen and rollback, but mocks requester dispatch. It does not demonstrate the changed settlement after an actual rejected requester call through a real transport or running Gateway. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The supplied after-fix evidence exercises the real lifecycle controller and SQLite settlement, including reopen and rollback, but mocks requester dispatch. It does not demonstrate the changed settlement after an actual rejected requester call through a real transport or running Gateway. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 8 items Current main still excludes non-success settlement: The fetched main revision still requires succeeded task status and an ok child outcome in the atomic blocker. The lifecycle caller treats rejection as an owner-change error. The lifecycle and outcome-classification files are identical between this head and fetched main.
Latest release retains the restrictive predicate: The same successful-task-only settlement predicate exists in the supplied latest release, v2026.9.2; this repair is not already shipped there.
Earlier owner-mismatch finding resolved: The introduced patch rereads both durable owners inside the existing transaction, retains run and generation matching, and admits only matching terminal non-success states. It excludes already-delivered non-success receipts and preserves successful blocked-alert behavior.
Findings None None.
Security None None.

How this fits together

Subagents 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]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The supplied after-fix evidence exercises the real lifecycle controller and SQLite settlement, including reopen and rollback, but mocks requester dispatch. It does not demonstrate the changed settlement after an actual rejected requester call through a real transport or running Gateway. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Complete next step (P2) - Add real-behavior proof before merge: show an actual rejected requester call settling durably through the production path, with original child outcomes preserved and no repeated wake after recovery. Redacted terminal output or logs are sufficient; screenshots or video are preferred when they clearly show the result. Remove private identifiers, endpoints, and credentials. Update the PR body to trigger re-review; if needed, ask a maintainer to comment @clawsweeper re-review.
Agent review details

Security

None.

PR surface

Source +16, Tests +307. Total +323 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 23 7 +16
Tests 2 374 67 +307
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 397 74 +323

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #137332
Summary: This PR addresses the canonical issue's matching terminal non-success cases; orphan reconciliation remains outside its scope.

Members:

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

Technical review

Best 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.

Labels

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit. Replaced prior rating: 🧂 unranked krab.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.
  • remove merge-risk: 🚨 session-state: Current PR review selected no merge-risk labels.
  • remove merge-risk: 🚨 message-delivery: Current PR review selected no merge-risk labels.

Label justifications:

  • P1: The reported defect leaves delegated-task notification settlement retrying across restarts and disrupts requester workflows.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit. Replaced prior rating: 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The supplied after-fix evidence exercises the real lifecycle controller and SQLite settlement, including reopen and rollback, but mocks requester dispatch. It does not demonstrate the changed settlement after an actual rejected requester call through a real transport or running Gateway. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • Sho Jikumaru: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • joshavant: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Provide redacted after-fix output from a real requester failure showing durable wake clearance, preserved child outcomes, and no repeated settlement on recovery.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-03T14:30:32.530Z sha dbdf62c391b92242a20430152b6128369ee8b5a0 :: needs real behavior proof before merge. :: [P1] Keep successful owner mismatches fail-closed

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
@xydt-juyaohui
xydt-juyaohui force-pushed the fix/issue-137332-requester-settle-terminal-nonsuccess branch from dbdf62c to 5a3141e Compare September 3, 2026 14:52
@fuller-stack-dev fuller-stack-dev self-assigned this Sep 6, 2026
@fuller-stack-dev
fuller-stack-dev merged commit ad3f823 into openclaw:main Sep 6, 2026
215 of 216 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M 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