Repository navigation
fix(subagents): atomically persist blocked completion alerts - #133192
Conversation
…ry permanently fails A detached subagent task that ends status=succeeded with deliveryStatus=failed and terminalOutcome=blocked (completion announce permanently failed) previously produced no proactive notification: shouldAutoDeliverTaskTerminalUpdate returned false for every non-cancelled subagent task, so the existing blocked-task follow-up path was unreachable for subagent runtime. Allow exactly that state through to the existing follow-up delivery; the normal subagent lifecycle ownership of provider-result publication is unchanged, as are silent notify policy, cancelled-subagent, acp, and non-terminal suppression. Fixes openclaw#133058
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 30, 2026, 10:35 AM ET / 14:35 UTC. ClawSweeper reviewWhat this changesThis PR lets a successful blocked subagent with permanently failed completion delivery queue the existing follow-up notification, preserves a delivery latch, and retries an unconsumed fallback after registry restore. Regression provenancePossible regression — probable (reviewed change; known regression link). No predecessor PR is attributed. Merge readiness⛔ Blocked until stronger real behavior proof is added - 4 items remain The reported silent-delivery path is present on current main and this PR repairs it through the existing task-delivery owner without a concrete introduced correctness defect. It remains open because the supplied live Gateway trace stops before the exact failed-and-blocked transition, so real after-fix behavior is not yet proven. Priority: P1 Review scores
Verification
How this fits togetherDetached subagents finish through the task registry, which attempts requester delivery and records its outcome. When direct delivery cannot reach the requester, the registry can place terminal and follow-up events into the requester session’s event queue for heartbeat processing. flowchart LR
A[Subagent completion] --> B[Task registry state]
B --> C{Requester delivery}
C -->|Delivered| D[Completion recorded]
C -->|Failed and blocked| E[Session fallback events]
E --> F[Durable queued state]
F --> G[Registry restore]
G --> H[Replay through task delivery]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +57, Tests +321. Total +378 across 9 files. View PR surface stats
Review metrics
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 one canonical task-delivery recovery path, retain the explicit at-least-once restart contract, and demonstrate the exact failed-and-blocked transition through a real gateway or authorized production-boundary transport trace before merge. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main records the failed-and-blocked state but the non-cancelled-subagent predicate rejects terminal delivery. The supplied live run confirms a related silent outcome, but not that exact transition. Is this the best way to solve the issue? Yes, the branch uses the existing terminal-delivery and fallback owners rather than creating a parallel route, and it covers the prior restart-latch finding. Its merge proof is incomplete because no real after-fix execution reaches the admitted failed-and-blocked state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0bd5c6a43b7d. LabelsLabel 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 (4 earlier review cycles)
|
…fication Review finding (heterogeneous seat review): after the blocked follow-up was queued, two production paths re-armed the new predicate by re-writing deliveryStatus=failed (requester-settle wake exhaustion; the direct-send fallback catch), so the same follow-up pair could be queued again. - record the successful fallback queueing as session_queued for the admitted blocked-subagent state (durable latch at the delivery owner) - guard updateTaskDeliveryByRunId against downgrading that state's session_queued/delivered back to an armed failed - tests: requesterOrigin direct-send shape, post-drain re-evaluation, wider predicate kill cases; filtered event assertions
Review finding (automated re-review P1 + heterogeneous seat review round 2): the latch was enqueue-only - the fallback queues two process-local system events and then persists session_queued, so a gateway restart between enqueue and heartbeat consumption lost the queue while the latch disabled every future retry (permanent silence again). - select restored blocked-subagent records (deliveryStatus failed or session_queued) for replay at first registry restore; the selector lives with the delivery policy (shouldReplayRestoredTaskTerminalDelivery, composed from the same predicate as shouldAutoDeliverTaskTerminalUpdate) - re-arm restored session_queued to failed in memory only; restore stays read-only - disk keeps session_queued until the replay outcome persists through the normal mutation path (at-least-once across restart) - replay each selected task through the canonical maybeDeliverTaskTerminalUpdate once listener ownership is established - tests: durable restart regression (queue loss + memory clear + SQLite restore -> replay re-queues terminal + follow-up exactly once; the re-entry latch still holds afterwards), plus a failed-branch crash-before-latch-persist seed
…penclaw#133058) The restore replay is canonical bookkeeping: it publishes the blocked alert/follow-up, not the retained provider result, and completion retry/dismiss resolve by exact task-run identity without gating on task.deliveryStatus (admission validates a freshly projected session_queued generation, not the stored row). The recovery-identity and admission-store tests captured pre-replay rows and raced the startup replay; settle the replay deterministically before capturing baselines and assert the exact canonical post-replay task state. Also type the replay catch callback parameter as unknown (use-unknown-in-catch-callback-variable).
…cked-delivery * origin/main: (261 commits) fix(clawdock): keep credentials out of diagnostic output (openclaw#133547) refactor(ui): avoid redundant presence work in avatar lists (openclaw#133548) fix(agents): recognize internal requester completion replies (openclaw#133543) fix: prevent duplicate queued user messages in chat clients (openclaw#133542) chore(ui): refresh control ui locales (openclaw#133544) fix(beam): restart delivery when the receiver changes (openclaw#133533) fix(models): recover /models browse from a replaced prepared catalog (openclaw#133221) perf(terminal): reuse control scans and remove repeated sanitization work (openclaw#133527) perf(agents): prepare only consumed tool and skill diagnostics (openclaw#133512) fix(line): offer the card command only on LINE (openclaw#132895) fix: keep Android publication independent of core release (openclaw#133471) refactor(agents): simplify compaction accounting (openclaw#133521) refactor(plugins): simplify registration lifecycle policy (openclaw#133364) perf(plugins): avoid eager loader imports for active registry reads (openclaw#133518) refactor(ui): consolidate chat rendering ownership (openclaw#133508) test(auto-reply): prepare memory flush model capabilities (openclaw#133532) fix(ui): replace startup hourglasses with capacity-aware rings (openclaw#133470) fix(talk): preserve provider conversation order in browser transcripts (openclaw#133493) fix(ui): deduplicate participant and viewer avatars (openclaw#133519) feat(ui): add CRT terminal theme (openclaw#133495) ...
…cked-delivery * origin/main: test: include v2026.8.1 release navigation (openclaw#133581) fix: stop cloud work before unrelated provider inspection finishes (openclaw#133476) fix(e2e): keep delete fixture target-compatible (openclaw#133526) fix(release): detect optional target E2E capability (openclaw#133525) fix(package): publish readable dist inventory (openclaw#133549) docs: add complete v2026.8.1 maintainer change index (openclaw#133585) fix(browser): preserve contextless worker and iframe sessions (openclaw#133571) fix(voice): discover configured provider candidates (openclaw#133507) refactor(ui): simplify chat rendering and lifecycle state (openclaw#133567) test: reduce maturity fixture cleanup time (openclaw#133566) improve: speed up legacy imports and transcript replacement (openclaw#133546) docs: add draft v2026.8.1 release notes (openclaw#133557) test: guard multi-project Vitest cache ownership (openclaw#133554) fix(memory): clarify default agent scope in command help (openclaw#133560)
…cked-delivery * origin/main: fix(ui): wait for restored draft before clearing (openclaw#133575) fix(deps): update fast-uri security patches (openclaw#133572) test: reduce workflow sanity fixture cleanup time (openclaw#133588) fix(media): normalize detected Matroska MIME (openclaw#133383) refactor(docker): retire ClawDock shell helpers (openclaw#133594) perf(browser): reuse snapshot refs and screenshot metadata (openclaw#133598) perf: load web chat history in larger, faster batches (openclaw#133565) fix(plugins): keep bundled plugins bundled when selected by plugins.load.paths (openclaw#133584) test: isolate shared /tmp session-store paths in runner and health suites (openclaw#133568) fix(cron): avoid no-op schedule repair writes (openclaw#133552)
|
@clawsweeper re-review The contributor branch now contains the maintainer repair at exact head The prior rank-up moves are addressed in the updated PR body: the ephemeral |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review The contributor branch now contains the maintainer repair at exact head The prior rank-up moves are addressed in the updated PR body: the ephemeral |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review The contributor branch now contains the maintainer repair at exact head The prior rank-up moves are addressed in the updated PR body: the ephemeral |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…w#133192) * fix(tasks): surface blocked follow-up when subagent completion delivery permanently fails A detached subagent task that ends status=succeeded with deliveryStatus=failed and terminalOutcome=blocked (completion announce permanently failed) previously produced no proactive notification: shouldAutoDeliverTaskTerminalUpdate returned false for every non-cancelled subagent task, so the existing blocked-task follow-up path was unreachable for subagent runtime. Allow exactly that state through to the existing follow-up delivery; the normal subagent lifecycle ownership of provider-result publication is unchanged, as are silent notify policy, cancelled-subagent, acp, and non-terminal suppression. Fixes openclaw#133058 * fix(tasks): latch blocked follow-up delivery against re-entry re-notification Review finding (heterogeneous seat review): after the blocked follow-up was queued, two production paths re-armed the new predicate by re-writing deliveryStatus=failed (requester-settle wake exhaustion; the direct-send fallback catch), so the same follow-up pair could be queued again. - record the successful fallback queueing as session_queued for the admitted blocked-subagent state (durable latch at the delivery owner) - guard updateTaskDeliveryByRunId against downgrading that state's session_queued/delivered back to an armed failed - tests: requesterOrigin direct-send shape, post-drain re-evaluation, wider predicate kill cases; filtered event assertions * fix(tasks): recover blocked follow-up after restart (openclaw#133058) Review finding (automated re-review P1 + heterogeneous seat review round 2): the latch was enqueue-only - the fallback queues two process-local system events and then persists session_queued, so a gateway restart between enqueue and heartbeat consumption lost the queue while the latch disabled every future retry (permanent silence again). - select restored blocked-subagent records (deliveryStatus failed or session_queued) for replay at first registry restore; the selector lives with the delivery policy (shouldReplayRestoredTaskTerminalDelivery, composed from the same predicate as shouldAutoDeliverTaskTerminalUpdate) - re-arm restored session_queued to failed in memory only; restore stays read-only - disk keeps session_queued until the replay outcome persists through the normal mutation path (at-least-once across restart) - replay each selected task through the canonical maybeDeliverTaskTerminalUpdate once listener ownership is established - tests: durable restart regression (queue loss + memory clear + SQLite restore -> replay re-queues terminal + follow-up exactly once; the re-entry latch still holds afterwards), plus a failed-branch crash-before-latch-persist seed * test(subagents): stabilize completion recovery after restore replay (openclaw#133058) The restore replay is canonical bookkeeping: it publishes the blocked alert/follow-up, not the retained provider result, and completion retry/dismiss resolve by exact task-run identity without gating on task.deliveryStatus (admission validates a freshly projected session_queued generation, not the stored row). The recovery-identity and admission-store tests captured pre-replay rows and raced the startup replay; settle the replay deterministically before capturing baselines and assert the exact canonical post-replay task state. Also type the replay catch callback parameter as unknown (use-unknown-in-catch-callback-variable). * fix(subagents): atomically persist blocked completion alerts * fix(subagents): route expiry through atomic owner * fix(subagents): preserve blocked delivery outcome --------- Co-authored-by: Vincent Koc <[email protected]>
What Problem This Solves
A successful subagent can exhaust required completion delivery and leave its
task failed/blocked without one durable requester-visible alert, silently
stranding the requester after the child has already finished.
The exact-head ephemeral Gateway regression drives that failed/blocked
exhaustion and observes one no-crash system event. Real SQLite fault injection
also proves the alert intent and failed/blocked state commit or roll back
together, while restart recovery invokes the committed intent once.
Summary
Fixes #133058.
This replaces the original downstream task-registry predicate, replay, and
session_queueddesign with one canonical subagent-completion owner operation.Both ordinary announce exhaustion and correlated queue settlement now use the
same operation.
Inside the existing shared-state SQLite write transaction, the operation:
systemEventintent per task generation;deferSqlitePostCommitPublication.The intent routes through
resolveEventSessionKey(crondescendants to theagent main session,
globaltoglobal) and preserves requester agent anddelivery context. Silent policy commits blocked state without an alert. Normal
successful delivery and ACP behavior are unchanged.
The original task-registry predicate relaxation, raw-session replay,
session_queuedlatch, polling/retry/timeout behavior, and associated testswere removed.
Crash Contract
The durable guarantee is exactly one alert intent per task generation,
insert-only and atomic with failed/blocked task and subagent state. A later
generation receives a new deterministic key.
If commit succeeds before in-process scheduling, startup recovery invokes the
durable intent once and tombstones it; a second recovery scan finds zero
pending intents. Model-visible consumption after durable-to-memory handoff is
best effort. This does not claim strict exactly-once delivery across every
possible crash window.
Current And Shipped Behavior
Current
mainand shippedv2026.7.1-2suppress generic terminal taskdelivery for non-cancelled subagents. The lifecycle could durably record a
successful task whose required completion delivery was failed/blocked without
creating a durable operator-visible alert at the transition owner.
The repair places the alert intent at that completion owner rather than
loosening downstream task policy. No schema version, table, config, protocol,
documentation, or changelog changes are included.
Evidence
7504a3b3c45393e793e2a3960585a4e781da94cd, 1/1 failed for the intendedreason: timeout waiting for the system event.
a0a9e8f9f390102ba847c8e0ddc2844d9384b73f,1/1 passed. The ephemeral Gateway drove actual successful subagent
completion through failed/blocked exhaustion and observed one no-crash
Task needs follow-upsystem event.admission/delivery, lifecycle, registry expiry, and task registry.
successful wake relabeled suspended delivery as delivered; head 1/1
passed, and the full lifecycle suite is 163/163.
subagent SQLite persistence and passes 1/1 without assertion or timeout
changes.
pnpm check:madge-import-cyclesand the full architecture gate pass withzero cycles after moving the canonical operation into the admission-store
leaf.
every mutation back; successful commit leaves all three.
failure cannot rewind memory past the committed block.
pnpm tsgo:core: passed.oxfmt,oxlint, andgit diff --check: passed.typecheck. Its core-test type shard is blocked by the unrelated shared
dependency error
ui/vite.config.ts(9,22): Could not find a declaration file for module 'pako'; no dependency install was performed in the worktree.outcomes; no test-only production seam was added.
Review Notes
ClawSweeper's prior rank-up moves are addressed:
but publisher run
33342148467failed withcould not verify the complete source; this repeats the prior publisher infrastructure failure and did notreport a code finding.
Codex CLI source ranges
codex-rs/cli/src/main.rs:220-245and:2840-2870were inspected directly;they are unrelated CLI behavior and impose no protocol/runtime dependency on
this repair.
LOC