Repository navigation
fix(agents): preserve child results while parent recovery is running - #140930
Conversation
Wait for the existing named recovery admission owner before a subagent settle command claims its parent. Keep the accepted dispatch and idempotency key, refresh preparation after release, and revalidate cancellation, target identity, and lifecycle generation before execution. Closes #140911 Worked on by: - @Takhoffman Co-authored-by: Tak Hoffman <[email protected]>
|
🦞👀 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 maintainer review before merge. Reviewed September 7, 2026, 2:44 AM ET / 06:44 UTC. ClawSweeper reviewWhat this changesThe PR keeps accepted child-completion handoffs pending while parent recovery runs, then refreshes session preparation and checks cancellation and identity before continuing. Merge readiness✅ Ready for maintainer review This remains a useful repair for an observed child-completion failure that current main and the latest release still permit. No actionable introduced defect was found, and the maintainer-protected PR should remain open. Priority: P1 Review scores
Verification
How this fits togetherSubagent completion delivery sends finished child results back through the parent’s agent-command entrypoint. Recovery ownership controls when that parent can safely process the handoff. flowchart TD
A[Finished child result] --> B[Accepted parent handoff]
B --> C{Parent recovery active?}
C -->|Yes| D[Wait for recovery release]
D --> E[Refresh session and validate]
C -->|No| E
E -->|Valid| F[Parent consumes result]
E -->|Cancelled or changed| G[Reject and clean up]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +68, Tests +344. Total +412 across 3 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. Technical reviewBest possible solution: Preserve the accepted handoff through temporary recovery contention while retaining the existing durable admission guard, cancellation behavior, and delivery identity. Do we have a high-confidence way to reproduce the issue? Yes, source provides a high-confidence path: complete a child while its parent has an active recovery owner, causing the immediate foreground claim to reject before normal lane waiting. The supplied regressions target that ordering; this review did not execute them. Is this the best way to solve the issue? Yes. Waiting at the early command-recovery boundary addresses the rejection before downstream queueing can help, reuses existing owner-release notification, and preserves the durable guard without increasing retry budgets. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 240aa9e573c4. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Maintainer-side verification for
Limit: proof uses isolated synthetic SQLite fixtures and in-process delivery with stubbed provider execution, not a live production Gateway or provider. The patch does not revive already-exhausted batches. |
|
Merged via squash.
|
…claw#140930) Wait for the existing named recovery admission owner before a subagent settle command claims its parent. Keep the accepted dispatch and idempotency key, refresh preparation after release, and revalidate cancellation, target identity, and lifecycle generation before execution. Closes openclaw#140911 Worked on by: - @Takhoffman Co-authored-by: Tak Hoffman <[email protected]>
Closes #140911
What Problem This Solves
Fixes an issue where users restarting the Gateway during delegated work could lose the child-completion handoff while the parent was still recovering. The child could finish successfully, but the parent-settle turn failed before entering its normal session lane and spent its retry budget. The parent could then repeat already completed work.
Why This Change Was Made
The accepted
subagent_settlecommand now waits for the existing named recovery admission owner to release the parent, preserving the same accepted dispatch and idempotency key. It refreshes preparation afterward and uses the unchanged durable recovery guard to authorize execution. The owner is also rechecked around the asynchronous claim, covering recovery starting after the first check.Cancellation, Gateway generation changes, target replacement/rerouting, tombstones, and ownerless recovery residue still fail closed. Existing recovery and preparation leases remain owned by cleanup. Ordinary commands, transferred recovery leases, internal recovery effects, retry budgets, database schemas, and UI retention policies are unchanged.
User Impact
Completed delegated work can reach its parent after recovery instead of failing simply because that recovery is still active. No new configuration or manual recovery step is required for future handoffs. This does not revive already-exhausted delivery batches or change cross-restart ambiguous-delivery guarantees.
Evidence
check:changedpassed: formatting, core/test typechecking, changed lint, dead-export scans, schema/store guards, and import-cycle checks.git diff --checkpassed.Proof uses isolated synthetic SQLite fixtures and in-process delivery; provider execution is stubbed. No live provider, production Gateway, or UI test is claimed. Initial test/check/review attempts interrupted by a Gateway restart were not counted as passing; completed reruns supplied the evidence above.
Production change: +70/-2 lines. Tests: +345/-1 lines. The additional production logic owns the accepted wait, snapshot refresh, and cancellation/identity checks; it does not introduce a new queue or persistent state.
Worked on by
View the OpenClaw team session