Skip to content

fix(subagents): atomically persist blocked completion alerts - #133192

Merged
vincentkoc merged 10 commits into
openclaw:mainfrom
shojikumaru:fix/133058-subagent-blocked-followup
Aug 31, 2026
Merged

vincentkoc merged 10 commits into
openclaw:mainfrom
shojikumaru:fix/133058-subagent-blocked-followup

Conversation

@shojikumaru

@shojikumaru shojikumaru commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

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_queued design 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:

  • rereads the exact task and subagent rows under lock;
  • validates task identity, run identity, generation, and successful completion;
  • atomically records failed/blocked task and subagent delivery state;
  • inserts one deterministic systemEvent intent per task generation;
  • publishes process mirrors and schedules delivery only after commit through
    deferSqlitePostCommitPublication.

The intent routes through resolveEventSessionKey (cron descendants to the
agent main session, global to global) and preserves requester agent and
delivery 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_queued latch, polling/retry/timeout behavior, and associated tests
were 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 main and shipped v2026.7.1-2 suppress generic terminal task
delivery 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

  • Base red: with only the black-box Gateway regression applied to
    7504a3b3c45393e793e2a3960585a4e781da94cd, 1/1 failed for the intended
    reason: timeout waiting for the system event.
  • Head green: exact head a0a9e8f9f390102ba847c8e0ddc2844d9384b73f,
    1/1 passed. The ephemeral Gateway drove actual successful subagent
    completion through failed/blocked exhaustion and observed one no-crash
    Task needs follow-up system event.
  • Focused unit/integration suites: 382/382 passed across completion
    admission/delivery, lifecycle, registry expiry, and task registry.
  • Requester-settle state reversal regression: pre-fix 1/1 failed because a
    successful wake relabeled suspended delivery as delivered; head 1/1
    passed
    , and the full lifecycle suite is 163/163.
  • The existing delete-mode delivery-deadline regression now exercises real
    subagent SQLite persistence and passes 1/1 without assertion or timeout
    changes.
  • pnpm check:madge-import-cycles and the full architecture gate pass with
    zero cycles after moving the canonical operation into the admission-store
    leaf.
  • Real SQLite fault injection after queue, subagent, and task mutations rolls
    every mutation back; successful commit leaves all three.
  • Ordinary and correlated producers create the same deterministic row.
  • Cron descendant routes to main; global routes to global.
  • Silent policy and normal success create no blocked alert.
  • Same generation deduplicates; next generation creates a new key.
  • Commit-without-scheduling recovery invokes once; second scan recovers zero.
  • Requester-wake state is durable with suspension, and later bookkeeping
    failure cannot rewind memory past the committed block.
  • Existing ACP coverage is unchanged and green.
  • pnpm tsgo:core: passed.
  • Scoped oxfmt, oxlint, and git diff --check: passed.
  • Changed-file gate passed every policy/static check through core production
    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.
  • Mandatory Codex autoreview: no actionable findings, correctness 0.98.
  • Test-audit: regressions assert owner-boundary behavior and real SQLite/Gateway
    outcomes; no test-only production seam was added.

Review Notes

ClawSweeper's prior rank-up moves are addressed:

  • exact real behavior proof now reaches failed/blocked exhaustion;
  • the restart design is a durable transactional intent, not ephemeral replay;
  • production growth is reduced from the prior +57 design to below the hard cap;
  • the remaining crash boundary is stated precisely above.
  • Exact-head ClawSweeper publication was requested again after the final push,
    but publisher run 33342148467 failed with could not verify the complete source; this repeats the prior publisher infrastructure failure and did not
    report a code finding.

Codex CLI source ranges
codex-rs/cli/src/main.rs:220-245 and :2840-2870 were inspected directly;
they are unrelated CLI behavior and impose no protocol/runtime dependency on
this repair.

LOC

  • Production: +211 / -167, net +44
  • Tests: +504 / -61, net +443

…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
@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@shojikumaru
shojikumaru marked this pull request as ready for review August 30, 2026 08:22
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 30, 2026, 10:35 AM ET / 14:35 UTC.

ClawSweeper review

What this changes

This 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 provenance

Possible 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
Reviewed head: 778bd6ab8f36123e35f1a6b39d1538cb5f23ee4b

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The repair is focused and source-supported, but the real behavior evidence does not yet exercise the exact recovered failure path.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: The changed production owner is terminal task delivery, which feeds direct requester delivery or the session-event fallback. Mocked focused tests cover the failure, latch, and restart paths, but the provided real Gateway output explicitly does not reach the new failed-and-blocked admission tuple or show its after-fix fallback result. 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 stronger real behavior proof before merge: The changed production owner is terminal task delivery, which feeds direct requester delivery or the session-event fallback. Mocked focused tests cover the failure, latch, and restart paths, but the provided real Gateway output explicitly does not reach the new failed-and-blocked admission tuple or show its after-fix fallback result. 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 7 items Current-main defect: Current main still unconditionally suppresses terminal delivery for every non-cancelled subagent, making the failed-and-blocked follow-up path unreachable.
Failure producer and delivery owner: The subagent lifecycle records failed delivery before marking required completion blocked; the PR admits only that non-silent successful tuple and routes it through the canonical terminal-delivery owner.
Latch and replay behavior: The branch records session_queued only after both fallback events queue, prevents later failed-status writes from rearming that terminal tuple, and restores eligible rows through the same delivery function.
Findings None None.
Security None None.

How this fits together

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

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The changed production owner is terminal task delivery, which feeds direct requester delivery or the session-event fallback. Mocked focused tests cover the failure, latch, and restart paths, but the provided real Gateway output explicitly does not reach the new failed-and-blocked admission tuple or show its after-fix fallback result. 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.
  • Resolve merge risk (P2) - Fallback consumption is not durable, so a restart or administrative reload before heartbeat consumption can intentionally emit the terminal/follow-up pair again under the branch’s at-least-once recovery contract.
  • Resolve merge risk (P1) - The bug-fix diff has a net production increase of 57 lines; its replay and latch logic is coherent, but the added owner-boundary complexity should remain justified by exact production-path proof.
  • Complete next step (P2) - No narrow automated repair remains; the external contributor needs to supply real behavior proof for the exact changed path.
Agent review details

Security

None.

PR surface

Source +57, Tests +321. Total +378 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 5 105 48 +57
Tests 4 327 6 +321
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 432 54 +378

Review metrics

Metric Value Why it matters
Production versus regression coverage production +57 net, tests +321 net The added replay and latch behavior has substantial focused coverage, while the production expansion needs exact runtime proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #133058
Summary: This PR is a candidate implementation for the reported unreachable blocked-follow-up path; the other linked reports concern distinct terminal-state and periodic-notice behavior.

Members:

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

Merge-risk options

Maintainer options:

  1. Prove the exact failure recovery (recommended)
    Before merge, provide a redacted real gateway or authorized production-boundary trace that reaches failed-and-blocked completion delivery and observes exactly one fallback pair after restore.
  2. Accept at-least-once replay semantics
    Retain the current recovery design while explicitly accepting that a restart before queue consumption can repeat the requester-facing pair.

Technical review

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

Labels

Label justifications:

  • P1: A permanently failed detached-subagent completion can otherwise leave the requester without a proactive outcome.
  • merge-risk: 🚨 message-delivery: The new restart recovery intentionally permits repeated terminal/follow-up events when the prior queued events were not consumed.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The changed production owner is terminal task delivery, which feeds direct requester delivery or the session-event fallback. Mocked focused tests cover the failure, latch, and restart paths, but the provided real Gateway output explicitly does not reach the new failed-and-blocked admission tuple or show its after-fix fallback result. 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:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • 100menotu001: 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.

  • Add a redacted real gateway or authorized production-boundary trace for the failed-and-blocked completion transition, including the observed fallback result after restart.

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 (4 earlier review cycles)
  • reviewed 2026-08-30T08:29:16.731Z sha b895f11 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-30T10:25:59.016Z sha b895f11 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-30T12:34:46.318Z sha 010ff2c :: needs real behavior proof before merge. :: [P1] Keep the fallback recoverable across a gateway restart
  • reviewed 2026-08-30T14:01:21.047Z sha 5d607eb :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 30, 2026
…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
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 30, 2026
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
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 30, 2026
…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).
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Aug 30, 2026
@vincentkoc vincentkoc self-assigned this Aug 30, 2026
…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)
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: L and removed size: M labels Aug 30, 2026
@vincentkoc vincentkoc changed the title fix(tasks): surface blocked follow-up when subagent completion delivery permanently fails fix(subagents): atomically persist blocked completion alerts Aug 30, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

The contributor branch now contains the maintainer repair at exact head
de9d2cc6f8683b52cd6ba73af497ec1ab4a757d1.

The prior rank-up moves are addressed in the updated PR body: the ephemeral
Gateway reaches actual failed/blocked exhaustion and observes one system event;
the alert is now one deterministic durable SQLite intent per generation,
atomic with blocked state; startup recovery and the bounded crash contract are
covered; production growth is net +45.

@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 30, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

The contributor branch now contains the maintainer repair at exact head
6ab774ed832bacb356d83b7763c63c0bb44eb545.

The prior rank-up moves are addressed in the updated PR body: the ephemeral
Gateway reaches actual failed/blocked exhaustion and observes one system event;
the alert is now one deterministic durable SQLite intent per generation,
atomic with blocked state; startup recovery and the bounded crash contract are
covered. The canonical owner now lives in the admission-store leaf with zero
architecture cycles, and the existing delete-mode expiry regression passes
through real SQLite persistence. Production growth is net +44.

@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 30, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

The contributor branch now contains the maintainer repair at exact head
a0a9e8f9f390102ba847c8e0ddc2844d9384b73f.

The prior rank-up moves are addressed in the updated PR body: the ephemeral
Gateway reaches actual failed/blocked exhaustion and observes one system event;
the alert is now one deterministic durable SQLite intent per generation,
atomic with blocked state; startup recovery and the bounded crash contract are
covered. The canonical owner now lives in the admission-store leaf with zero
architecture cycles, and the existing delete-mode expiry regression passes
through real SQLite persistence. A new base-red/head-green lifecycle regression
proves that a successful requester-settle wake cannot relabel already
suspended/blocked completion state as delivered. The authored PR context gate
is green, and production growth remains net +44.

@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc
vincentkoc merged commit 1c10f70 into openclaw:main Aug 31, 2026
675 of 679 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

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

Labels

agents Agent runtime and tooling gateway Gateway runtime merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L 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.

[Bug]: succeeded-but-delivery-failed subagent tasks are never proactively surfaced (queueBlockedTaskFollowup unreachable for runtime "subagent")

2 participants