Repository navigation
fix(agents): preserve restart recovery for delegated child work - #181373
Conversation
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
16b70ec to
3b5f46f
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3b5f46f78f
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ) { | ||
| // A denied source cannot notify the parent. The recovery owner still owes | ||
| // this exact child a local outcome, without borrowing execution authority. | ||
| const notice = await appendAssistantMessageToSessionTranscript({ |
There was a problem hiding this comment.
Route the recovery notice through SessionManager
When an interrupted child lacks a restorable requester source, this writes the synthetic assistant notice through appendAssistantMessageToSessionTranscript rather than the required awaited SessionManager.appendMessageAsync owner. That bypasses the scoped transcript invariant responsible for assigning parentId and persisting the message, so the recovery notice can be attached outside the child transcript's active branch; route this append through the session manager while retaining the existing recovery fences.
AGENTS.md reference: src/agents/AGENTS.md:L15-L15
Useful? React with 👍 / 👎.
|
Codex review: blocked before merge. What this changesThis PR preserves registry custody, requester recovery facts, and completion delivery for delegated child follow-ups across Gateway restarts. Example: A parent sends a follow-up to agent:main:dashboard:existing-child with timeoutSeconds: 1, then the Gateway restarts.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep this PR open: it repairs a current recovery gap with maintainer-approved direction, but the new interruption notice violates the scoped transcript append contract. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe sessions_send tool admits child work into the subagent registry, which coordinates restart recovery and returns results to the original requester under current authority. flowchart TD
A[Requester turn] --> B[Sessions send tool]
B --> C[Subagent registry]
C --> D[Restart recovery]
D --> E[Child execution]
E --> F[Requester completion]
C --> F
Technical reviewBest possible solution: Retain the existing registry recovery owner and completion lifecycle, with the interruption notice appended through the required SessionManager owner. Do we have a high-confidence way to reproduce the issue? Current main restricts durable follow-up completion custody to zero-timeout callers and can omit requester recovery facts without an outward route; supplied regressions report base failures, but no reproduction was executed during this read-only review. Is this the best way to solve the issue? Using the existing registry and requester authority owner is the smallest coherent repair; the added notice should follow the scoped transcript writer contract. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 012da8342e51. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +230, Tests +341, Docs +11. Total +582 across 17 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 23, 2026, 1:57 AM ET / 05:57 UTC. |
|
Reviewed the notice-writer finding against the full source path, with a second independent source review. I am retaining the guarded host-owned notice API used by
The PR has no schema or decoder change. The focused proof uses persisted SQLite state and simulated Gateway generation/resolver replacement, including missing-authority and legacy/unverified records. It does not claim a packaged upgrade from v2026.10.6; that unrun scenario is now explicit in the body. No concrete incompatible stored shape was identified. Exact-head CI has completed. Only @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…claw#181373) * fix(agents): preserve restart recovery for delegated child work * test(sessions): tighten restart recovery proof typing and expectations
) * fix(agents): preserve restart recovery for delegated child work * test(sessions): tighten restart recovery proof typing and expectations (cherry picked from commit a8a3680) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 2df5f5982cc6bab8d19c90e061602caa62ad04ed)
) * fix(agents): preserve restart recovery for delegated child work * test(sessions): tighten restart recovery proof typing and expectations (cherry picked from commit a8a3680) Adaptation-Base: cecd7059127eb19b4d2a2d2143e6bd4cb126b40b Adaptation-Scope: Durable operator original-requester custody and denied-source child-local interruption; no preexisting process-local hunks replayed Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit bccdf933e1b70e6fb62fe894efa1cb5ca0a2ac2a)
) * fix(agents): preserve restart recovery for delegated child work * test(sessions): tighten restart recovery proof typing and expectations Candidate adaptation: qualify persisted delegated-child custody with an exited native writer and two fresh native readers; test-only cold-process and fail-closed controls. Non-operator durable grants remain deliberately undefined. (cherry picked from commit a8a3680) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 271315112e62861bd6f91c46e1646b5a89cf6610)
…ns in gateway lane FRV tests (#187589) * fix(sessions): keep malformed rows out of the legacy transcript locator projection The #181247 backport (08ee066) adapted the main change for the release branch's legacy sessionFile locator by projecting json_extract(entry_json, '$.sessionFile') on every selected row. SQLite raises 'malformed JSON' for an unreadable entry_json before parseSessionEntryJson can apply its skip/reject policy, so ordinary selected listings and gateway lookups failed with a raw SQLite error. Project the locator only for transcript selections and only for valid JSON rows. Release-only: main retired the sessionFile locator. * test(logging): isolate log-tail prefix cases from cached inode (#173376) (cherry picked from commit 40806cf) * test(gateway): realign sessions_send owner continuation to the #181373 backport 9b8ee9c (#181373 backport) adopts timed sessions_send children into the requester turn and changes the inline wait to waitForAgentRunReply. The backport dropped a8a3680's matching fixture changes, so the test spied on the old SessionFollowupCompletion.take and waited forever. Apply main's fixture hunk (observe waitForAgentRunReply and registry persistence). The release branch has no session-controller liveness check (#175837), so a claimed result is handed back only by the requester run's settlement; the synthetic original run now performs the settleRequesterRun call its embedded runner makes on completion. Adapted from a8a3680 * test(agents): keep six-outcome settle fixture undelivered after consumed-cohort backport The 2f7589a backport of #181260 filters delivered child findings from settle wakes (needsRequesterSettleFindings). On main, #178104 moved the shared makeSettledChild default to pending delivery; the release fixture still defaults to delivered, so this case lost every finding. Mark its children pending, as the backport did for its other undelivered fixtures. * test(gateway): keep progress-only settle recovery undelivered after #181260 backport Backport 2f7589a dropped the source commit's fixture change because main had moved the recovery case into server.subagent-settle-replay-recovery.test-support.ts. Apply the same 'progress only' pending-delivery setup to the inline release copy. (adapted from commit 535989c) * test(agents): keep private settle policy fixtures undelivered after #181260 backport Backport 2f7589a filters delivered child findings from settle wakes. On main, #178104 moved the shared fixture default to pending and renamed these cases to pending pairs; the release fixture still defaults to delivered, so the private marker was filtered. Mark the children pending. * test(agents): mock retireRequesterFollowupAuthority in settle retry fixture Backport 9b8ee9c (#181373) made execution cleanup call retireRequesterFollowupAuthority. This release-only fixture mocks requester-cron-authority.js without that export, so the retry wake threw and warned. Main no longer has this mock. * fix(subagents): keep queued collectors out of operator completion custody The release adaptation 4643f86 of #181373 started capturing the operator continuation context for every spawn so collectors also record their original requester source. It dropped the collect guard on binding completion authority, so a queued collector retained an operator source hold after its parent completed or stopped. Main binds only non-collect runs (authority && !registerParams.collect); restore that guard here and keep completionAuthorityRequired aligned with it. * test(agents): mark settle retry cron-authority mock as isolation The added retireRequesterFollowupAuthority export changed the grandfathered factory hash. Name the isolation reason and prune the stale baseline entry. --------- Co-authored-by: Patrick Erichsen <[email protected]>
What Problem This Solves
Delegated child sessions can stay interrupted after a Gateway restart, including dashboard-keyed children and follow-ups whose caller waited for an inline result.
User Impact
Parent-owned child work retains its existing recovery owner and normal late completion delivery across restarts. Missing requester authority produces a visible interruption in the child's history. Explicit cancellation remains final, and ordinary cron completion stays quiet.
This cannot reconstruct a missing historic execution record or a lost requester grant. A fresh authenticated
sessions.sendcan continue retained child history under the current caller's authority;sessions.recoverstill requires the original recovery evidence. Check retained history and uncertain tool outcomes before repeating work.Why This Change Was Made
Dashboard keys already belong to the native subagent registry. The gaps were in admission: synchronous
sessions_sendfollow-ups lacked a durable execution record, internal replies could omit requester recovery facts when there was no outward delivery route, and an outer drain-error handler could clear the claim as an ordinary failure.Use the existing registry for child follow-ups regardless of inline wait, consume an inline terminal result through its existing completion obligation, and transfer the already-captured requester authority for late delivery. Save internal requester facts independently of delivery routing and classify live restart refusals consistently. The main-session owner continues to exclude delegated children.
No schema or configuration changes. Production delta: +229 lines (+301/-72); test delta: +342 (+366/-24). The growth preserves the existing authority and completion lifecycle while adding the missing durable admission and visible failure behavior; it introduces no additional recovery owner or state store.
Evidence
The unchanged base fails the dashboard-resume, missing-authority visibility, synchronous-custody, and live-drain claim-retention regressions.
All 72 cases passed across:
subagent-detached-recovery.restart-integration.test.ts: real reply admission, persisted SQLite state, dashboard child continuation, late completion, and missing-source visibility after simulated restart.restart-recovery-claim.lifecycle.test.ts: requester facts without delivery, live drain preservation, stale drain and explicit Stop controls.openclaw-tools.sessions-send-child-coordination.test.ts: synchronous and asynchronous custody, yielded/pending observations, inline success/error/timeout, and quiet cron follow-up.server.sessions-send-owner-continuation.test.ts: real Gateway admission and final plugin-write authority for success, child error, revocation, reassignment, and a new user turn.Independent autoreview: no actionable P0–P2 findings. Changed-file formatting and lint, the core native typecheck, and export-name collision checks passed. An additional 63 authority and import-closure cases passed; both recovery files were rerun successfully after a small lint-driven simplification.
Local proof preceded a patch-identical, conflict-free rebase; PR CI validates the current head.
No benchmark was needed for this correctness repair. Production diagnosis was read-only; no recovery RPC or deployment was performed. Restart simulation stubs model dispatch and delivery transport; the Gateway authority test exercises native admission with a synthetic plugin effect.
CI Follow-up
The first CI run found an unsafe property access in the new transcript assertion and a pre-existing strict steering-options expectation. The assertion now narrows the reader's
unknownvalues; the steering test explicitly expectsisInboundUserReply: false. The complete sessions tool file passed 64 cases and the restart integration file passed all 10 cases after these repairs. The repair diff also received independent autoreview with no actionable findings.The separate progress-card failure in
subagent-control.worker.test.ts(settles the progress card according to intentional external silence) reproduces identically on this PR and with all changed production modules replaced by their unchanged base versions atb9689588648536c51480404580835776a2112485: one failure, 25 skipped in each run, expected one retirement and received zero. Commit535989c929969613a4641a8b32acdf6fffe1c192(#181260), already in the base, made public settlement honor its required visible-result obligation. This older fixture creates required public results but still expectsNO_REPLYto retire the card. The affected settlement path is unchanged by this PR. This is retained as an attributed inherited CI failure, not reported as passing.Final exact-head CI: run 39906904038, head
3b5f46f78f69f8b7d7a7800d4633d1defeb2b0df. All three PostgreSQL conformance shards, builds, production/test typechecks, lint, security checks, and other test shards passed. The only failed test is the attributed progress-card assertion above, inchecks-node-changed-compact-small-3; the CI gate fails downstream from it. Its test and settlement-source blobs are identical across the reproduced baseline, CI's protected-main parentc902f9aa2f647863825e1337cb6eed671256d40a, and tested merge5b155949226f8593a39cf9627c50f08a144c21a8.Review follow-up: retain the same guarded host-notice append API used by main-session restart failure reporting (#181180). It resolves the active transcript parent inside the transaction and retains exact-session, lifecycle, expected-recovery-state, and idempotency checks. Direct SessionManager append does not expose the expected-recovery-state contract. The reported branch-placement defect was independently checked and not reproduced from the source path; the broad wording in the agents guide should distinguish model appends from existing host-owned lifecycle notices.
No storage schema or decoder changed. The restart regressions use persisted SQLite state and replace the Gateway generation/resolver in-process; they are not a packaged stable-binary upgrade. An upgrade run from v2026.10.6 was not performed.