Skip to content

fix(subagents): leave interrupted delivery reservations to their recovery owner - #184100

Merged
steipete merged 1 commit into
mainfrom
steipete/cx-first-turn-queued
Oct 26, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/cx-first-turn-queued

Conversation

@steipete

@steipete steipete commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

In a live subagent stress run with two Gateway kill -9 restarts, two of twelve Codex-runtime parents stayed status=queued with hasActiveRun=true for over 35 minutes. Each had a fresh continuation input queued that never ran.

User Impact

Ready parent continuations can run after repeated Gateway restarts without being blocked by retained interrupted child deliveries. No configuration changes or migration are required.

Why This Change Was Made

Root cause

Both parents had completed their recovery turns and yielded. Their queued inputs were fresh boot-2 continuations, so no dead-boot claim was involved. On restore, reserveRestoredSubagentControllerSources (subagent-announce-controller-source.ts) reserved requester-mailbox slots for unprepared deliveries of older interrupted child generations, ahead of those ready continuations. Recovery refuses superseded child generations, so nobody ever prepared or released those reservations, and requester FIFO blocked the parent. The live_owner skip in main-session recovery reflects current process-local controller activity, which was this stuck reservation, not a persisted lease.

Fix

Interrupted terminal deliveries (terminalOwner === "interrupted-recovery") are no longer reserved during restore. Their recovery owner reserves them right before the actual announcement, after it reconciles them. No new leases, fencing or state. Documented in docs/concepts/subagent-yield-handoff.md.

Evidence

  • SQLite-backed regression in subagent-controller-inputs.test.ts proves one completion followed by the user turn, in FIFO order. It fails on base (expected [...] to have a length of 1 but got 2, 1 failed / 16) and passes with the fix, twice.
  • Green: restart-integration (35), completion admission mailbox (20).
  • Format, lint and targeted agents/sessions typecheck pass.

Known remaining gap, not addressed here: retained notices from superseded historical child executions still are not cleaned up. They can no longer starve ready parent work.

Landing CI

CI run 40258699310 at 77675382fa6a7049910afb07fe891df435db67cd has one failing test: public yielded settle replay with real Gateway admission > recovers public work once through a sibling and reconciles its private child final in src/gateway/server.subagent-settle-replay.harness.test.ts. It records error/cancelled where ok/completed is expected at server.subagent-settle-replay-recovery.test-support.ts:459.

The same 23-test file on the exact CI main baseline, 2f1a6b9c35437f169dfbb0d66dcbb44e972bdfb3, reproduces the identical assertion (22 passed, 1 failed). These test files are unchanged by this PR. A focused Linux/Bun rerun with this PR passed all 23 tests; that passing replay is not claimed as a repair. All other CI checks passed. Landing uses the authorized native pre-existing-failure exception and preserves the red CI evidence. The intermittent baseline replay defect remains a follow-up.

Prevent retained interrupted child deliveries from blocking ready parent continuations after repeated Gateway restarts. Reserve those inputs only when their recovery owner can prepare the announcement, preserving FIFO for runnable work.

Add a SQLite-backed restore and controller regression, and document the reservation ownership contract.
@clawsweeper

clawsweeper Bot commented Oct 26, 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.

@steipete
steipete marked this pull request as ready for review October 26, 2026 02:21
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S labels Oct 26, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 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-26T02:23:59.842734Z 7767538 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. P1 High-priority user-facing bug, regression, or broken workflow. 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 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR defers interrupted subagent delivery reservations until their recovery owner prepares the announcement.

Example: After two Gateway restarts, an interrupted generation-1 child delivery precedes a ready generation-2 parent continuation.

  • Before: Restore reserves both inputs, allowing the unprepared interrupted delivery to block the ready continuation.
  • After: Restore reserves the ready continuation; interrupted delivery remains owed until recovery prepares its reservation.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A minimal, coherent patch with meaningful controller-boundary regression coverage; after-fix evidence remains in-process rather than a shipped Gateway run.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor proof gate is exempt for this maintainer-authored PR; supplied after-fix evidence exercises SQLite-backed restore and controller admission, while the live stress report describes the original failure.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Ready parent continuations can remain queued behind interrupted child deliveries after repeated Gateway restarts.
Reason: The maintainer-authored direction aligns restore custody with the existing recovery owner; historical-record cleanup is explicitly separate from restoring progress.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR makes a focused reservation-ownership correction, with no actionable introduced defect found. The failing CI assertion also occurs independently on another PR.

Priority: P1
Reviewed head: 77675382fa6a7049910afb07fe891df435db67cd

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not show the post-fix two-restart scenario through a running Gateway and real agent.
Agent review details

How this fits together

Gateway startup restores durable subagent obligations into the requester session controller; its mailbox then admits ready continuations and user turns in FIFO order.

flowchart TD
A[Durable subagent records] --> B[Gateway restore]
B --> C[Ready completion reservation]
B --> D[Interrupted recovery owner]
D --> E[Reconcile and prepare delivery]
E --> F[Requester mailbox]
C --> F
F --> G[Parent continuation or user turn]
Loading

Technical review

Best possible solution:

Keep mailbox reservation with the existing recovery owner until interrupted delivery is ready, while retaining its durable obligation.

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

The base source and reported red/green controller regression establish the premature reservation path; the full two-restart stall was not independently reproduced, and fetched main additionally contains the overlapping recovery repair in #184069.

Is this the best way to solve the issue?

The guard is the smallest complete ownership correction: it reuses the existing announcement reservation path, preserves retained records, and adds no state, lease, configuration, or alternate delivery mechanism.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Restore-time individual completion reservations changes intended behavior with a stated reason (36e277d: The session-controller consolidation rebuilt durable completion obligations into requester FIFO custody. Subsequent ownership work preserved current-owner checks and retirement handling.)
  • Restored cohort readiness and ordering keeps the original intent (d738163: Unfinished child or descendant cohorts must remain outside the requester mailbox until runnable; this PR preserves that policy and extends the readiness principle to interrupted individual delivery.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit d738163 adds src/agents/subagents/announce/subagent-announce-controller-source.ts:218 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d7381633d77a; files: src/agents/subagents/announce/subagent-announce-controller-source.ts)
  • Paul Bohm: Raw commit f83b7ad adds src/agents/subagents/announce/subagent-announce-controller-source.ts:180 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f83b7ade15f3; files: src/agents/subagents/announce/subagent-announce-controller-source.ts)

PR surface

Source +2, Tests +61, Docs +3. Total +66 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 2 0 +2
Tests 1 61 0 +61
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 66 0 +66

Labels

Label changes:

  • add P1: The reported repeated-restart incident left real parent continuations queued for over 35 minutes, blocking an active agent workflow.
  • 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:

  • P1: The reported repeated-restart incident left real parent continuations queued for over 35 minutes, blocking an active agent workflow.
  • 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 25, 2026, 10:37 PM ET / October 26, 2026, 02:37 UTC.

@steipete
steipete merged commit d576313 into main Oct 26, 2026
216 of 222 checks passed
@steipete
steipete deleted the steipete/cx-first-turn-queued branch October 26, 2026 03:14
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
…penclaw#184100)

Prevent retained interrupted child deliveries from blocking ready parent continuations after repeated Gateway restarts. Reserve those inputs only when their recovery owner can prepare the announcement, preserving FIFO for runnable work.

Add a SQLite-backed restore and controller regression, and document the reservation ownership contract.
RomneyDa added a commit that referenced this pull request Oct 28, 2026
…184100)

Prevent retained interrupted child deliveries from blocking ready parent continuations after repeated Gateway restarts. Reserve those inputs only when their recovery owner can prepare the announcement, preserving FIFO for runnable work.

Add a SQLite-backed restore and controller regression, and document the reservation ownership contract.

(cherry picked from commit d576313)

Adaptation-Base: cecd7059127eb19b4d2a2d2143e6bd4cb126b40b
Adaptation-Scope: Defer interrupted-recovery owners rather than consume restored runnable slots
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 9818af9044e4659c7396fcdf218c515ab246e57b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. 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