Repository navigation
Conversation
Recheck live session ownership before rereading retained child metadata, keep unresolved retries on per-row bounded backoff, and wake recovery on owner publications or admission release. Move initial metadata reads to the session worker and fence pause, steer, kill, and queue changes across awaited reads.
|
🦞👀 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 26, 2026, 3:18 PM ET / 19:18 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch makes subagent restart recovery skip repeated session reads while a live owner remains, use worker metadata reads, and retry unresolved rows with bounded backoff, with accompanying tests and operations documentation. Merge readiness✅ Ready for maintainer review Keep open: current main still reads retained child sessions on each sweep, so this branch has distinct performance value. The follow-up commit repairs the superseded-row cleanup regression, and this review found no remaining definite patch defect. Priority: P2 Review scores
Verification
How this fits togetherThe subagent registry tracks child runs and sweeps them after interruptions or Gateway restarts. Recovery combines registry ownership and session metadata to decide whether to wait, settle a run, or leave cleanup to the ordinary sweeper. flowchart LR
A[Retained child runs] --> B[Registry sweep]
C[Live session owners] --> D[Recovery coordinator]
B --> D
D --> E{Owner active?}
E -->|Yes| F[Skip or retry]
E -->|No| G[Read session metadata]
G --> H[Recover or clean up]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +123, Tests +197, Docs +7. Total +327 across 11 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep recovery owned by the registry, with fresh authority checks before settlement and bounded retries for rows that cannot yet be reconciled. Do we have a high-confidence way to reproduce the issue? Yes, current-main source gives a high-confidence path: repeat sweeps of retained live-owned child rows call recovery and read session metadata each time. I did not execute that path in this read-only review. Is this the best way to solve the issue? Yes, the change stays with the registry recovery owner, uses the existing worker reader, and preserves live checks before settlement. The reported Testbox results support the scoped performance claim. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against cafb3a4d1ca2. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Serve the worker reader from the same mutable in-memory session fixture as the synchronous accessor. Preserve read failures and caller authority checks without changing registry assertions.
…aw#159082) * perf(agents): avoid repeated retained subagent recovery reads Recheck live session ownership before rereading retained child metadata, keep unresolved retries on per-row bounded backoff, and wake recovery on owner publications or admission release. Move initial metadata reads to the session worker and fence pause, steer, kill, and queue changes across awaited reads. * fix(agents): preserve superseded subagent orphan cleanup * test(agents): align registry fixtures with worker session reads Serve the worker reader from the same mutable in-memory session fixture as the synchronous accessor. Preserve read failures and caller authority checks without changing registry assertions.
What Problem This Solves
The subagent sweeper repeatedly reads and parses retained child sessions while a live session owner prevents restart recovery. Deferred rows also reschedule the entire sweep every second, repeating unrelated work.
User Impact
Unchanged live-owned rows skip session reads. Unresolved recovery retries independently at 1, 2, 4, 8…60 seconds; published session changes and admission release request a sweep within one second. Normal interruption, cancellation, and superseded-row cleanup remain with their existing owners. No new configuration, schema, or retention policy.
Why This Change Was Made
The coordinator retains small ownership predicates and registry/Gateway facts, rechecks live authority before every skip, and invalidates on owner publications or admission release. It deliberately does not cache arbitrary session classifications: notifications cannot establish freshness after a foreign SQLite commit. Unowned rows and saved requester wakes still receive fresh keyed reads.
Initial reads use the existing worker metadata projection, omitting saved prompt snapshots. Existing synchronous side-effect fencing stays authoritative. Pause, steer, kill, and queued eligibility now recheck across the awaited read. Superseded rows fall through to ordinary sweeper cleanup. Net production growth: 123 lines.
Evidence
The fixture uses the real sweeper/recovery composition, 30 retained running rows with live session owners, and entries larger than 1 MiB. Mocked storage counts keyed reads and actual JSON parsing; this is not a SQLite throughput benchmark.
That is 90% less parsing, 88.1% less sweep time, and zero reads on unchanged ticks. RSS includes the test harness and is not an isolated retained-heap measurement. The mock still parses the large entry on its first read, so the numbers do not credit the worker projection for omitting prompt payloads.
Production Testbox proof: 130 tests passed, including all 26 faithful SQLite/restart integration cases, on provider
blacksmith-testbox, profileopenclaw-check, leasetbx_01m3ff8jsfj6gp32j91d441d82, headf2f8b8fa7bf6d027a1ec0b0db30101eea396e0a2.Wall: 77.66 s for the wrapper, 82.02 s remote command. Test process costs: restart recovery 9.21 s / 53 tests; sweeper recovery plus worker-reader sibling 15.74 s / 46 tests; real restart integration plus sweeper lifecycle 36.97 s / 31 tests. The existing integration suite exercises persistence and restart ownership and accounts for most test execution time.
The read regression fails on the baseline. Separate baseline controls also fail for backoff and all four in-read ownership changes. Independent Codex review found no actionable P0–P2 issues, including the subsequent CI repair.
Current-head CI: https://github.com/openclaw/openclaw/actions/runs/36264969848 — success, head
7bfabdb874ec994d0639c2cf7596acc3426284fe; finalopenclaw/ci-gatepassed. Both previously failing shards passed: compact-large-2 job wall 368 s and compact-small-2 job wall 461 s, including setup.CI also exposed four stale mocks in
subagent-registry.test.ts: the new worker reader bypassed its in-memory session fixture. Both APIs now share the existing mutable fixture and preserve read failures and caller-current checks. All 186 registry seam tests pass. Across eight related fixture files, 338 tests passed and the two extra E2E failures described below remained. The remote E2E runtime build passed in 7m 55.6s; test-process wall times were 15.58s (186 tests), 14.13s (91 tests), 5.38s (5 tests), and 42.39s (58 E2E tests, two pre-existing failures). Combined with the separate 130-test proof, this is 468 passing tests. No production code changed in the fixture follow-up.Initial CI caught a genuine regression: an early guard skipped ordinary cleanup of a superseded predecessor. The guard now discards its cache and returns to ordinary cleanup; the original failing integration case passes on Testbox. That initial impacted agent-support CI shard ran 69 files / 1,624 cases in 138.95 s before reporting this failure.
Remote validation history and limits
All heavy local-invoked validation used the installed Crabbox CLI and Blacksmith Testbox. Each lease received one successful
pnpm install --frozen-lockfile; leases were replaced sequentially, never used for concurrent commands. All five leases are stopped.tbx_01m3fb9z8hrhntpafq3hae48rarun-vitestrestart-recovery file: expected read-regression failure, 46 existing tests passed. Patched recovery/sweeper/lifecycle files: 88 passed. Twocheck-changedattempts timed out during native file sync before checks ran.tbx_01m3fc2drngkc8dhqykbq7dm5wcheck-changedsync timed out.tbx_01m3fcmm8aqgvvn62r2s2vwbpqcheck-changedused stale runner refs and selected unrelated line-cap growth. Pinning basedd3e8a4af4d8fb8267c601cf7eacbdbf3bec2af9exposed two TypeScript narrowing issues, both fixed. Core types and structural checks passed; a later sync timed out.tbx_01m3fdrk6x9380pdwh50w2csxktbx_01m3ff8jsfj6gp32j91d441d82dd3e8a4af4d8reproduced exactly the same two failures; the candidate source was restored afterward. Both E2E runtime builds succeeded. Lease stopped.Known pre-existing E2E failures:
subagent-registry.requester-wake.e2e.test.tsstill expects a yielded alpha batch to wait for unrelated beta, and a stale unrelated sibling to consume a frozen batch’s deferral budget. Both failures reproduce with the lane’s baseline recovery implementation. They conflict with the intentionally independent frozen-batch behavior in #158642; neither failing assertion reaches the sweeper. These untouched expectations need separate maintenance.There is no completed standalone
check-changedrun on the final head; the exact-head CI run supplies the remaining broad type/lint/guard/docs gates. No live Gateway was changed or profiled. Unpublished foreign-store changes are discovered on the next bounded retry; this is intentionally not a general revision cache for every retained row.