Repository navigation
fix: retain subagent results through Gateway restarts - #199868
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Codex Review Summary: ✅ CompletedThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d619804b5
ℹ️ 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".
|
@clawsweeper review Please review head 7d61980, especially unmarked requester recovery, accepted-input replay after restart, and atomic terminal removal facts. This builds on #199695's consumed-input owner. The PR body includes the restart reproduction, baseline failures, 0 lost of 6 checked completions, btrfs measurements, and the exact-parent attribution for the inherited unused test-helper export. |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThis PR recovers retained subagent results after restart, preserves replay attribution, and records delivery outcomes atomically when registry rows are removed. Example: A finished child holds CAPTURED_CUSTODY_RESULT while its settled requester has no restart marker.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR addresses concrete restart-related result loss that remains on main; no actionable introduced defect was found, and current-head CI is pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe subagent registry retains child execution and delivery facts; Gateway startup restores requester custody, completion owners deliver retained input, and cleanup records terminal outcomes in session-state history. flowchart TD
A[Finished child result] --> B[SQLite subagent registry]
B --> C[Gateway restart discovery]
C --> D[Requester authority admission]
D --> E[Requester transcript consumption]
E --> F[Completion settlement]
F --> G[Atomic removal and session event]
Technical reviewBest possible solution: Retain this focused repair using the existing discovery, admission, completion, and transactional history owners. Do we have a high-confidence way to reproduce the issue? Current-main discovery demonstrably excludes unmarked settled requesters, and supplied regressions cover the resulting recovery and cleanup failures; no target code was executed during this read-only review. Is this the best way to solve the issue? The patch repairs the existing owners, preserves fresh requester admission and complete-request conflict checking, and removes the false equivalence between retired process custody and store replacement. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8862ffc735fe. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +85, Tests +379, Docs +11, Other +40. Total +515 across 31 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes: No label 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 HistoryReview history (3 earlier review cycles)
Reviewed November 15, 2026, 10:30 PM ET / November 16, 2026, 03:30 UTC (Revision 4). |
|
Addressed both numbered items from the latest review on final head
The PR body now distinguishes five restart scenarios (0 lost of 7 checked completion rows; five second-restart receipt checks) from the stable-data upgrade proof. It also records the upgrade limitations: stable repeated delegation hit a prompt-prefix error before the pending-result setup, and automatic-startup-only migration hit a separate secrets-loading SQLite I/O error; the supported separate-process Doctor upgrade passed. These failures are not hidden or counted as passing proof. Final correction Codex autoreview is scoped-clean through P2. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Use current timestamps for newly created fixture sessions. Under CPU contention, maintenance pruned the 1970-dated children during admission, before receipt assertions. The exact CI main parent reproduced all five failures; this two-line correction passes the same contention run and all 43 coordination tests.
|
Final head is now
CI run 43786635304 failed five requester-receipt tests during initial admission. All five reproduce on its exact main parent The fixture now uses current timestamps. With the same 0.5-CPU runtime quota, all five cases change from failed to passed. All 43 affected-file cases pass normally. Production retention, the six-minute receipt checks, and their assertions are unchanged. Codex correction review is scoped-clean through P2. The changed-file pass has only the already attributed unused export from #198268; no other check failed. Fresh exact-head CI is required before landing. No CI rerun was requested. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Final correction head: 82b0483.
CI run 43791145697 exposed a harness overcount, reproduced on its exact merge under one-CPU Linux contention. The second custom message contains Recently Completed Subagents summary text, not another completion input. The filter now counts the completion-event fragment. Changing only that filter passes under the same contention; delivery and single-input assertions remain. The owner follow-up finalizes restored consumed private input before redispatch and uses observed store replacement, rather than generic retired custody. Both new regressions fail on the previous head. The existing selector-return regression also caught an overbroad deletion; the existing admission helper now passes that concrete observation to cleanup. Seventeen selected lifecycle and eight store-boundary cases pass, plus all 40 settlement, three normalization, and 38 requester-wake cases. Final Codex P0–P2 review is scoped-clean. The one-CPU crash attempt timed out in setup before result capture/crash. At normal four-CPU capacity, the unchanged case passes; no timeout or assertion was loosened. That setup limitation remains recorded. Changed-file checks retain the independently attributed main unused-export defect from #198268; all other checks pass. New exact-head CI must complete before landing. No CI rerun requested. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
* fix: retain subagent results through Gateway restarts * fix: preserve terminal state when retiring subagent results * test: keep requester receipt fixtures within session retention Use current timestamps for newly created fixture sessions. Under CPU contention, maintenance pruned the 1970-dated children during admission, before receipt assertions. The exact CI main parent reproduced all five failures; this two-line correction passes the same contention run and all 43 coordination tests. * fix: settle restored subagent consumption before retry
…stage 2) Catches the pure continuation candidate bc7e568 up to openclaw/openclaw main 41bdde2 (fetched 2026-11-19T14:32:59Z), 2,996 upstream commits past the old merge base 401a1de. Merge commit only; rerere disabled, so every resolution was made here. 80 conflicted paths (77 content, 3 modify/delete), each recorded with base, ours and theirs blobs and its reason in the lane's stage2-conflicts.md: - 8 take upstream whole: the openclaw#197153 pg16-smoke cherry-pick (6909b64) now ships upstream (ci.yml, ci-build-manifest, ci-workflow-planning test), the Control UI settings child moved onto runDistArtifactChild, the canary worker target and two active-facts migration tests. - 3 deleted with upstream: session-fork and update-candidate-canary suites whose production paths upstream removed; cwd-split folded away (openclaw#198916), its one continuation case rehomed to attempt.continuation-tools.test.ts. - One-owner cutovers where upstream now owns a fork extraction: the requester-origin projection and replacement-text helpers (openclaw#200533) replace the fork's byte-identical copies in user-turn-transcript.metadata.ts. - Ports into fork-extracted owners: removalReason in the queued-start plan and collector-group sweep (openclaw#199868), the async prepared-pricing usage diagnostic, the announce flow types, and the session-delivery codec, which gains upstream's mediaCandidate kind, reviewedTaskId and their schemas (openclaw#198227), importing its retention type from the leaf types module. - Transcript repair (openclaw#201304, post-b894): upstream's payload-free adapter kernel carries the fork's continue_delegate attachment redaction through a payload-adapter-only fact and a withBlock update. - Reset cleanup: upstream's process and retained-send stops (openclaw#199079, openclaw#200326) with the fork's continuation-aware reason as the single input; the chat reset's retention adapter wraps upstream's stopSessionResetWork, the Gateway preemption keeps stopSessionResetSubagents as upstream does. - Schema: upstream owns agent 42 (tool usage) and 43 (pending-input endings) and is at 43; 44 is unused upstream. Continuation's recipient authority moves 42 -> 44: version constants, step order, historical schemas, witness additive table and version set, backup scope, PostgreSQL ladder (V43 = current minus the authority table) and port descriptor. package.json schemaVersions state 40, agent 44. - Generated outputs regenerated, never hand-merged: config baseline, gateway validators, postgres schema catalogs, worker-access inventory. - Compile follow-through for upstream's delivery-union narrowing and its readSessionDelivery callers. Refs openclaw#129388
What Problem This Solves
Fixes finished subagent results being suspended or silently removed when a Gateway restart interrupts requester settlement or completion delivery.
User Impact
Dashboard requesters recover owed results after restart, retries retain the accepted input identity, and every removed registry row leaves a recorded delivered, suspended, or discarded outcome with a reason. No configuration or database schema change is required. Removal receipts use the existing session-state history retention (30 days / 50,000 events).
Why This Change Was Made
A settled requester can have pending child results without any interrupted-run marker. Startup skipped that requester, then the sweeper and announce cleanup interpreted retired process authority as a permanently replaced store. Recovery now selects those obligations through the existing requester index, and both false failure branches are removed.
An accepted completion replay could retain its operator profile but lose its original sender presentation. That changed the accepted-input identity despite identical content and provenance. Replay now preserves accepted attribution when the freshly admitted profile matches. It retains the complete-request conflict check. This builds on #199695's committed consumption fact: a consumed private result remains delivered and a restored consumed row finalizes without redispatch; accepting an input alone does not prove consumption.
Retryable rows are protected from completed-run cleanup. The single registry deletion owner records a terminal fact atomically with removal, including the terminal postimage when requester settlement or lifecycle expiry immediately retires a row.
Evidence
Team r337 (
257759ae→dd2d58be) drained at 23:31:19Z, exited at 23:31:27, restarted at 23:31:29, and reached readiness at 23:31:53. Read-only observations at +1/+6 minutes reported 4 lost results among 14 captured successful results: one was suspended asstore replacedwithout a delivery attempt; three had accepted-input idempotency conflicts during drain, then failed/retryable rows disappeared. Two additional pending rows disappeared without delivery evidence. Production transcript contents were not accessed; synthetic evidence does not establish which of those three production inputs were consumed.Related prior fixes: #198905, #199488, #198807, #198843, #199575. Integrated #199695 at
6d7a56de584a.Focused native suites passed 160 tests (117 custody/lifecycle cases and 43 requester-coordination cases), including a real-worker lifecycle-expiry regression that was red before the review correction and green afterward. Baseline regressions fail for unmarked requester discovery, false store replacement, six-minute deletion of retryable results, absent removal facts, and restored sender attribution. The real Gateway subprocess harness passes announce-in-flight, private consumption, busy-requester, settled-private-result, unmarked-requester, and private-announce crash cases: 0 lost of 8 explicitly checked completion rows, with another restart checking each captured result’s delivered receipt and single input (six repeat checks). The unmarked case recreates the observed persisted shape by removing only restart markers from the stopped synthetic requester after real child capture/drain; it verifies the result is pending and absent from the transcript before startup. The provider is synthetic; Gateway processes, SQLite, admission, transcript consumption, shutdown and restart are real.
Published stable
2026.11.3→ candidate compatibility proof passed through the supporteddoctor --fixupgrade: two completed registry rows and the original transcript survived, and a fresh chat completed. Automatic-startup-only upgrade hit a separate secrets-loadingERR_SQLITE_ERRORafter migration; that failure remains recorded, and is not represented as passing upgrade proof. Stable also hit a prompt-prefix error in the repeated-delegation setup, so pending recovery and stable data compatibility are separate proofs.pnpm check:changedcompleted after each correction. Own test lint findings were fixed and both affected lint scopes pass. Its remaining dead-export failure reproduces on exact parent6d7a56de584a:resolveRollbackWorkerInputsin the unchanged rollback test helper became unused whene4a30936bb35/ #198268 removed its external consumer. This is a main regression, not a passing gate. Format, typechecks, database/import guards and other checks passed. Codex P0–P2 autoreview found no actionable defects.Production delta: +141/-56, net +85 lines; tests +379 net lines. Growth is predominantly the requested atomic terminal removal facts and explicit removal reasons; the false store-replacement failure path is deleted. No schema, configuration, dependency, or cache change. No Control UI runtime imports of changed modules were found.
Linux/btrfs synthetic measurement: 42,871,726,080-byte agent DB (~39.9 GiB), 10,830 sessions, 4,300 obligations, 62,000 files / 1.116 GB; Node 24.22.1, 4 CPU / 12 GiB container limits. Five interleaved A/B process pairs, each with 20 warmups and 20 trials, plus two A/A pairs and separate allocation sampling. Baseline selects 4,300 sessions; candidate selects 6,046, recovering 1,746 omitted requesters.
A/A wall medians were 171.7/170.3 and 170.3/169.7 ms; CPU medians were 287.9/271.8 and 295.3/289.6 ms. Allocation control was 49.72 MB/pass. The added recovery costs work; this is not a speedup claim. These timings cover startup discovery, not full startup or workspace I/O, and sampled allocation excludes worker heaps. No Team data was copied or mutated.
Initial-head CI run 43782742045 failed only when the Bun correlated-recovery shard exceeded its 60-second no-output watchdog (exit 143, no assertion reported). The six selected tests passed locally under Bun with that same watchdog. This is not claimed inherited or fixed; the final head requires its own CI.
CI run 43786635304 exposed an inherited fixture race in five requester-receipt cases. All five reproduce on its exact main parent
6aae38f36ee8under Linux CPU contention. Normal session maintenance pruned newly created child fixtures becauseupdatedAt: 1dated them in 1970; diagnostic tracing reached the committed session-removal owner. The fixture was introduced by903b5f20eb4a/ #187270. This PR repairs the two fixture timestamps: the same contention run changes from 5 failed to 5 passed, and all 43 affected-file tests pass. Production retention and receipt assertions are unchanged. This is a repaired main test regression, not ignored CI noise.CI run 43791145697 found a transcript-counting defect in the new private-announce harness. On exact CI merge
dc6c6b3b61d3, a 1-CPU Linux run reproduces two matching carriers: the actual completion input and a later Recently Completed Subagents summary. Changing only the filter to count completion-event fragments passes under identical contention. No delivery assertion is removed. The final owner correction also has two baseline-red regressions: restored consumed private input must finalize without announcing again, and process-custody retirement must leave undelivered input retryable. Twelve selected lifecycle cases pass, including both regressions. Final Codex autoreview is scoped-clean through P2.Final Linux proof also passes graceful private announce and busy requester at one CPU, then private announce interrupted by process crash at four CPUs. The one-CPU crash attempt timed out during setup before any crash or completed-result capture; the unchanged case passes at the fixture’s normal capacity (28.17 seconds total), with unchanged timeouts and assertions. It is a recorded setup limit, not a claimed restart failure or inherited defect. All three final scenarios retain delivered receipts and exactly one captured-result input through a second restart.
The consumer sweep caught an additional contract while simplifying the false retirement branch: an actual store replacement observed during an announce must remain terminal even if its selector later returns. The existing test became red with pending instead of suspended. The admission helper now reports its concrete replacement observation to the cleanup owner; ordinary process retirement still does not imply replacement. This retains the existing store boundary without adding a cache, schema, or generic failure classification. Final focused proof and independent review cover this correction.
Final correction verification: 17 selected lifecycle cases and all 8 selected store-replacement cases pass, including the previously failing selector-return case; all 40 requester-completion settlement cases, 3 normalization cases, and 38 requester-wake product cases pass. The latter covers six-child batches, nested completion, overlapping callers, receipt retention, yielded cohorts, cancellation, and descendant settlement. Final Codex P0–P2 review is scoped-clean.
Exact-head CI 43797910391 also exposes a new main lint regression:
unicorn(prefer-structured-clone)in unchangedsrc/agents/tool-search-prepared-catalog.ts:118. The exact CI main parent8862ffc735fe6f5e553a69ea2fb7731a6b90fd87reproduces the identical diagnostic with the normal focused lint wrapper. Commitf4d2e45592438dbaae12975e1c4223a991285b7a/ #199909 introduced the JSON snapshot expression. This is an attributed main regression requiring follow-up, not a passing gate or ignored noise; the repair must preserve its intentional JSON normalization. No CI rerun requested. The final-head ClawSweeper review has zero open items and no findings.