Repository navigation
perf(subagents): skip terminal child reads during restart - #169034
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: needs maintainer review before merge. What this changesThis PR skips startup child-session reads for completed subagents while preserving reconciliation for unfinished runs. Example: Restart a Gateway retaining 3,000 completed subagents and their child sessions.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR provides a worthwhile recovery optimization that current main still lacks; no introduced defect was found, the previous conflict is resolved, and current-head CI gates are successful. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway startup hydrates persisted subagent registry rows, restores requester ownership, and passes unfinished execution or terminal settlement to the existing recovery, delivery, and cleanup owners. flowchart TD
A[Gateway startup] --> B[Registry hydration]
B --> C[Current run and recovery guards]
C --> D[Completed run settlement]
C --> E[Unfinished child reconciliation]
E --> D
D --> F[Guarded delivery and cleanup]
Technical reviewBest possible solution: Restore completed runs from registry facts while unfinished execution and final effects retain their existing session and lifecycle owners. Do we have a high-confidence way to reproduce the issue? Current main serially reads completed child sessions before advancing activation, so a failed completed-child read can block later runs; the PR reports a baseline-failing regression and real Gateway measurements, which this read-only review did not rerun. Is this the best way to solve the issue? The focused shortcut removes unnecessary I/O at the restoration owner without adding a cache or competing delivery path, while downstream cleanup retains its session-identity and authority checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6e06137f85ef. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +4, Tests +50, Docs +3. Total +57 across 4 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 HistoryReviewed October 11, 2026, 6:19 AM ET / 10:19 UTC (Revision 3). |
3aca714 to
17641f8
Compare
First-parent upstream 069a5b8..75df19c (17 commits, including openclaw#169043 entry lifecycle queries, openclaw#169034, openclaw#169058 memory index facts, openclaw#168950, openclaw#169019 telegram queued history replies, openclaw#168790/openclaw#168756/ openclaw#168759/openclaw#168739 Solid UI ports, openclaw#168813 codex metadata/startup lifecycles, openclaw#168981, openclaw#168992 agent preparation SQLite work). Only conflict: worker-access inventory, regenerated (631 files, 2436 calls). Auto-merged files carrying our overlay, reviewed: snapshot.ts (upstream's block-reply reconcile reads through index-1; our per-part continuation-marker strip in extractAssistantStreamSnapshot unchanged), codex side-question.ts (upstream's request-scoped client lease; our disableContinuationTools and the extracted dynamic-tool-call helper unaffected), subagent-registry-restore.ts, session-sharing-store.native.ts. Refs #1475 Co-Authored-By: Claude Opus 5.5 <[email protected]>
What Problem This Solves
Gateway restart recovery serially reopens child sessions for retained terminal subagents. Thousands of historical runs add tens of seconds to the post-ready recovery tail, and an unavailable completed child store can prevent activation from reaching unfinished runs.
User Impact
Completed subagents restore without the unnecessary startup child-session read. Existing delivery, cancellation, and interruption owners retain their checks. This shortens recovery completion; the measurements show no material readiness, first-chat, or memory improvement. No schema, config, or update migration changes are required.
Why This Change Was Made
Terminal records skip the startup read and continue through the existing current-row, restart-recovery, cancellation, and delivery checks. Unfinished executions and queued collectors retain their current-session reconciliation. The patch uses the simplified restoration owner on current main; it adds no cache or competing delivery path.
Production LOC is +4 (9 added, 5 removed). The current-session identity and queued-collector rollback contracts require retaining the existing read for unfinished runs. The condition removes a database read per terminal run while preserving those contracts. Related tests move into the existing test-support module so the oversized test file shrinks.
Evidence
Paired isolated Linux benchmark on AWS Crabbox
cbx_5e6599185151(c7a.8xlarge, Node 24.19.0), exact baseline48a348028fb0f9e60f57832e8b03b35264ccdf54and candidate17641f82f85a8f15d85248972db729f2479a8561. Each variant used the same stopped synthetic snapshot, one warmup, and three measured restarts: 3,000 completed subagents (50.7 MB retained payload), 3,000 child sessions, and 12,000 transcript messages.Recovery is 17.2× faster, saving 28.14 seconds. Readiness, first-chat latency, and memory show no material improvement in this sample. First chat ends at a successful
agent.waitterminal response from a loopback mock provider. Only documented pre-dispatch session-admission refusals are retried; candidate sample 0 required eight retries and the other five measured samples required none. Their time is included. No live state or external model calls were used.Startup phase medians (milliseconds)
The transcript-maintenance median has three baseline spans and two candidate spans; the third candidate completed its parent maintenance span without a matching transcript child span. This synthetic setup does not reproduce production plugin-service or import costs.
Validation:
48a34802, the new regression fails because the completed child store is unavailable. The patched path restores the active run without reading that completed child.tbx_01m4n61c091ream79dj7v9ghcb: 190 tests passed across the registry, cancellation, queued recovery, and restart recovery suites; export-name collision guard and both eager-import/source-closure files passed (20 tests). The new regression took 6 ms. The four-file test run took 57.85 s in Vitest; the owning infra pair took 35.84 s with one worker.src/web-search/runtime.test.ts. The same guard fails on a clean, untouched48a34802worktree. Neither that file nor its baseline is changed here.