Skip to content

fix(agents): recover parent before restoring child completions - #178694

Merged
steipete merged 1 commit into
mainfrom
steipete/main-recovery-latency
Oct 20, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/main-recovery-latency

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

After a Gateway restart, an interrupted main-session turn (for example a fleet parent killed mid-turn) resumed 60–126 s after startup. docs/gateway/restart-recovery.md promises "a few seconds". Meanwhile every child completion bounced off the parent every 15 s with SESSION_WORK_START_CHANGED.

The cause was FIFO blockage:

  1. Child-completion restoration reserved the parent's mailbox before restart recovery had marked the parent orphaned.
  2. The reservation guard in subagent-announce-controller-source.ts only recognized already-marked recovery.
  3. Mailbox dispatch therefore queued the parent's own resumption behind unprepared child reservations. Two preparation jobs, each waiting up to 15 s for output, matched the ~60 s observed.

User Impact

Interrupted parent turns resume promptly after a Gateway restart while child completion reservations remain in FIFO order behind them. No configuration changes or migration are required.

Why This Change Was Made

Child restoration now invokes the existing recovery owner for the parent first, with commit-time ownership validation, before restoring child reservations. It adds no timer, queue or recovery state. The parent's interrupted turn runs on the first attempt, and all child reservations are retained in FIFO order behind it.

Evidence

  • main-session-restart-recovery-priority.test.ts "unmarked startup orphan": red on base (8 child inputs dispatched ahead of the parent) and green with the fix (first-attempt parent execution, 8 child reservations retained in order). Focused suites pass: main-session recovery marking, priority, admission and recovery (194), subagent-parent-recovery.restart-integration, requester-settle dispatch and restart, direct delivery, and the server.startup-recovery-* loopback Gateway tests (330 tests).
  • Live Crabbox, Gateway kill -9 while a fleet parent was still in its first turn:
    • main: the parent was marked at startup and resumed 61 s later (126 s on another build), with 8 SESSION_WORK_START_CHANGED bounces.
    • this branch: the parent resumed at 4 s after the HTTP listener came up (16 s after the kill, including boot), with 0 bounces.

Reconcile startup-orphaned requesters through the existing recovery owner before restoring child mailbox reservations. This prevents unfinished child output preparation from holding FIFO positions ahead of the interrupted parent, while preserving durable completion custody and order.

Add a regression with eight restored children that verifies first-attempt parent execution and retained FIFO child reservations. Focused recovery, requester-settle, direct-announcement, and loopback Gateway tests pass.
@clawsweeper

clawsweeper Bot commented Oct 20, 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: S labels Oct 20, 2026
@steipete
steipete marked this pull request as ready for review October 20, 2026 19:03
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T19:24:02.424979Z 256ce47 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
@steipete
steipete enabled auto-merge (squash) October 20, 2026 19:19
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR marks interrupted parents for recovery before restoring child completion mailbox reservations.

Example: A Gateway restarts with an interrupted parent and eight pending child completions.

  • Before: The reported parent recovery took 61 seconds after startup, with eight SESSION_WORK_START_CHANGED bounces.
  • After: The branch reportedly resumed the parent four seconds after the HTTP listener started, with zero bounces.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch and regression support correctness; directly inspectable proof is limited to the in-process test composition, with live behavior reported in prose.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its body reports a real Crabbox Gateway restart with parent recovery improving from 61 seconds and eight bounces to four seconds and zero bounces, without attaching the runtime capture.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Interrupted parent tasks can wait about a minute after restart while child completion attempts repeatedly fail to start.
Reason: The maintainer-authored direction restores documented recovery ordering and preserves the prior owner's deliberate completion-custody behavior.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR addresses a source-supported startup recovery delay that remains on main; no actionable patch defects were found, and exact-head CI is still pending.

Priority: P2
Reviewed head: 256ce470ff056ff1560544e6a17430a926b79092

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The reported live kill-and-restart result has no attached logs or recording for direct inspection.
Agent review details

How this fits together

Gateway startup restores durable subagent obligations into session controller mailboxes; the recovery owner must recognize interrupted parent work before child follow-ups reserve FIFO positions.

flowchart TD
  A[Gateway startup] --> B[Restore subagent obligations]
  B --> C[Load requester session]
  C --> D[Existing orphan recovery owner]
  D --> E[Resume interrupted parent]
  E --> F[Restore ordered child completions]
Loading

Technical review

Best possible solution:

Use the existing orphan recovery owner before either restored child reservation path, preserving durable obligations and their established ordering.

Do we have a high-confidence way to reproduce the issue?

Current source exposes the unmarked-orphan ordering gap, and the PR supplies a focused regression plus a reported live restart comparison; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch is a focused extension of the existing recovery-before-completion contract, with no competing scheduler, new state owner, or unnecessary test scaffolding.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against ce97c81929f1.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 26d770a adds src/agents/subagents/announce/subagent-announce-controller-source.ts:95 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 26d770af21fc; files: src/agents/subagents/announce/subagent-announce-controller-source.ts)

PR surface

Source +38, Tests +99. Total +137 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 39 1 +38
Tests 1 100 1 +99
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 139 2 +137

Review metrics

Metric Value Why it matters
Production versus regression growth Production +39/-1; tests +100/-1 The production growth wires existing recovery into two restoration paths; the single regression covers the previously unmarked startup case and retained child ordering.

Labels

Label changes:

  • add P2: A concrete restart scenario delays interrupted parent work behind child completions, with a focused repair and limited scope.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A concrete restart scenario delays interrupted parent work behind child completions, with a focused repair and limited scope.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 20, 2026, 3:19 PM ET / 19:19 UTC.

@steipete
steipete merged commit 00a052a into main Oct 20, 2026
213 checks passed
@steipete
steipete deleted the steipete/main-recovery-latency branch October 20, 2026 20:10
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
…law#178694)

Reconcile startup-orphaned requesters through the existing recovery owner before restoring child mailbox reservations. This prevents unfinished child output preparation from holding FIFO positions ahead of the interrupted parent, while preserving durable completion custody and order.

Add a regression with eight restored children that verifies first-attempt parent execution and retained FIFO child reservations. Focused recovery, requester-settle, direct-announcement, and loopback Gateway tests pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant