Repository navigation
fix(agents): preserve subagent results when delivery fails - #118360
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 3, 2026, 3:46 AM ET / 07:46 UTC. ClawSweeper reviewWhat this changesThe branch preserves successful subagent results when requester delivery fails by storing completion and delivery state durably, then adds retry/dismiss recovery through Gateway methods, CLI commands, and the Tasks UI. Merge readinessThis PR addresses a real current-main failure mode: successful subagent completions can stop after a three-attempt announce retry limit, clear retained fallback output, and leave delivery blocked. The proposed durable owner, SQLite recovery path, and operator recovery actions are a coherent fix direction with strong submitted restart proof, but the branch is behind Priority: P1 Review scores
Verification
How this fits togetherA subagent finishes work and records a task result before OpenClaw hands that result back to the requester through direct or queued session delivery. This PR changes the durable boundary between the subagent registry, task records, SQLite delivery queue, and operator recovery surfaces when that handoff cannot complete. flowchart LR
A[Subagent execution] --> B[Canonical completion result]
B --> C[Task and subagent state]
C --> D[Session delivery queue]
D --> E{Delivery outcome}
E -->|Delivered| F[Requester session]
E -->|Blocked| G[Gateway, CLI, or Tasks recovery]
G --> D
Decision needed
Why: This is a broad persisted-state and public Gateway-contract change; the PR reports approval, but its final mergeable head must be reviewed after the current-base refresh rather than inferred from an earlier proof run. Before merge
Agent review detailsSecurityNone. Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land one canonical durable completion-delivery flow only after the rebased head proves legacy-row normalization, restart settlement, visible-versus-silent result selection, and the additive recovery API contract against current main. Do we have a high-confidence way to reproduce the issue? Yes — current main source has a concrete path: a required completion increments delivery attempts and gives up at the three-attempt cap, then clears pending/fallback result state while recording failed delivery and a blocked terminal outcome. Is this the best way to solve the issue? Yes, with maintainer confirmation — moving completion output into canonical durable state and settling correlated queue/task/subagent records through one owner is a better fix than extending the existing retry-limit workaround or adding another runtime fallback reader. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c49b68328ef2. 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 (19 earlier review cycles; latest 8 shown)
|
8ffbb9d to
9d85ecc
Compare
bf6b5c3 to
dacad35
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
dacad35 to
be4476d
Compare
778f0cf to
82d2ed5
Compare
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Rebased exact-head terminal-reply restart/recovery proofHead: After rebasing all 20 signed commits onto then-current Command: {"head":"129ff55e57060eb9e875ce2a85810604f10e2127","base":"5151dc481d71940300e4022f2b1894265a7b1b18","database":{"engine":"SQLite","exists":true,"path":"[redacted-temp-state]"},"firstRestart":{"visible":{"terminalReply":{"disposition":"visible","text":"VISIBLE_EXACT_HEAD_RESULT"},"result":"VISIBLE_EXACT_HEAD_RESULT"},"silentRetry":{"terminalReply":{"disposition":"silent"},"result":null},"silentDismiss":{"terminalReply":{"disposition":"silent"},"result":null}},"gateway":{"retry":[{"taskId":"task-visible-retry","ok":true,"duplicateRisk":true,"deliveryStatus":"pending","terminalOutcome":"succeeded","result":"VISIBLE_EXACT_HEAD_RESULT"},{"taskId":"task-silent-retry","ok":true,"duplicateRisk":true,"deliveryStatus":"pending","terminalOutcome":"succeeded","result":null}],"dismiss":[{"taskId":"task-silent-dismiss","ok":true,"duplicateRisk":false,"deliveryStatus":"dismissed","terminalOutcome":"blocked","result":null}]},"secondRestart":{"visibleRetry":{"delivery":"pending","generation":2,"result":"VISIBLE_EXACT_HEAD_RESULT"},"silentRetry":{"delivery":"pending","generation":2,"result":null},"silentDismiss":{"delivery":"discarded","disposition":"intentional_non_delivery","result":null}},"fallbackLeak":false}The rebased exact head preserves the same observed contract: visible output survives restart and retry, intentionally silent output remains absent through retry and dismissal, generation 2 and intentional dismissal survive a second restart, and the retained visible fallback sentinel never reaches Gateway output. |
|
Merged via rebase.
|
Closes #112616
What Problem This Solves
Fixes an issue where a successful subagent run could lose or strand its result when delivery back to the requester was queued, ambiguous, or failed. Delivery could stop after three attempts even while the documented 30-minute recovery window remained, restart settlement could race queued results, and operators had no safe way to inspect or recover a blocked completion.
Why This Change Was Made
Completion delivery now has one durable owner across the SQLite-backed subagent, task, and session-queue records. Execution success is tracked separately from delivery state, retries remain bounded by the hard-expiry window, and producer state settles before the queue reaches a terminal outcome. Startup recovery, scheduled delivery, and targeted recovery share the same settlement path.
Blocked results are retained for seven days and can be retried or intentionally dismissed through additive
operator.writeGateway methods, CLI commands, and the Tasks UI. A one-way idempotent database-open migration promotes shipped payload-only results into canonical completion and task state before obsolete fallback reads are removed; no schema-version bump is required. The permanent recovery API and the seven-day, 25-warning, 50-spawn-cap, and ten-generation defaults have maintainer approval.User Impact
Successful child execution remains successful even when result delivery is delayed or blocked. Operators can inspect and copy retained results, retry an ambiguous or failed delivery with a duplicate-risk warning, or dismiss it without losing access to the result. OpenClaw warns when 25 blocked completions are retained and pauses new subagent spawns at 50 instead of deleting recovery evidence.
Existing installations automatically normalize legacy retained-result rows on database open, preserving useful fallback output—including results captured before a final
NO_REPLY—across restart, retry, dismissal, queue recovery, and collector wait. Producer-owned visible terminal replies remain authoritative, while intentionally silent terminal replies never expose retained fallback text.Evidence
129ff55e57060eb9e875ce2a85810604f10e2127with 73 successful jobs, 5 skipped jobs, and zero failures, includingopenclaw/ci-gate, Node/Windows, protocol and boundary checks, iOS, Android, QA smoke, and Control UI E2E.tasks.retry/tasks.dismissGateway handlers. It shows visible results survive retry, silent results remain absent through retry and dismissal, generation 2 and intentional dismissal persist across a second restart, and retained fallback text does not leak.