Repository navigation
fix(agents): avoid false subagent sweep failures during shutdown - #147904
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. Reviewed September 14, 2026, 5:38 AM ET / 09:38 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR cancels pending subagent maintenance sweeps when stopped, reports restart-drain refusals as skipped work, and adds lifecycle regression coverage. Merge readiness✅ Ready for maintainer review The fix remains useful: current main and v2026.9.4 retain the false-failure path. The reviewed patch has no blocking correctness findings, and the supplied Gateway observations demonstrate the intended result. Priority: P2 Review scores
Verification
How this fits togetherThe subagent registry periodically reconciles interrupted runs and cleans up completed work. Its scheduler passes maintenance through Gateway work admission, which refuses new work during restart drain. flowchart TD
A[Registered subagent runs] --> B[Sweep scheduler]
C[Registry activation or last-run release] --> B
B --> D{Gateway admits work?}
D -->|Yes| E[Reconcile and clean up runs]
D -->|Restart drain| F[Record skipped sweep]
E --> B
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +1, Tests +150. Total +151 across 3 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep scheduling in the existing sweeper, cancel pending work on stop, and preserve restart activation and genuine failure reporting. Do we have a high-confidence way to reproduce the issue? Yes: a scheduled sweep encountering restart drain reaches unconditional failure logging on current main. The supplied real Gateway before/after output corroborates that path; this review did not execute it. Is this the best way to solve the issue? Yes: the patch repairs the existing scheduler and uses the established drain-error predicate while preserving admission, reconciliation, and activation behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ca513db612ba. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
landpr-approve-admin-merge |
|
landpr-approve-unrelated-red |
|
landpr-approve-admin-merge |
|
landpr-approve-unrelated-red |
|
Thanks @obviyus! Proof: A real Gateway stopped and restarted with a sweep due during drain. The sweep was recorded as skipped, and registry lifecycle tests passed.
|
…nclaw#147904) ## What Problem This Solves A sweep due during Gateway shutdown reported a failure when restart drain correctly refused admission. ## Why This Change Was Made The sweeper cancels pending scheduling on stop. Drain refusals record skipped work and skip rearming while preserving recurring intent for restart. This state has one writer. ## User Impact Expected shutdown refusals no longer appear as sweep failures. Normal reconciliation and genuine error reporting remain intact. ## Evidence Real Gateway: `pnpm openclaw gateway run --port <port>`, then `pnpm openclaw gateway stop --force --json` while a service holds cleanup open. Before: `subagent run sweep failed: gateway is draining for restart`. After: `subagent run sweep skipped: gateway is draining for restart`. `pnpm openclaw gateway restart --json` also passed and reached ready again. All CLI and Gateway exits were 0. ## Compatibility No config, schema, protocol, or public API change. ## Consumers Registry activation, recovery scheduling, and last-run cleanup retain one scheduler. ## Invalidation Stop clears the pending timer and rerun; restart activation restores the regular cadence. ## Tests 34 registry lifecycle and recovery tests passed on the candidate and its merge with main. They exercise registration, last-row release, repeated activation, suspension, and overlapping timeout callbacks. Tests detect broken release/activation wiring and loss of periodic reconciliation after restart. Local preflight passed. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
A sweep due during Gateway shutdown reported a failure when restart drain correctly refused admission.
Why This Change Was Made
The sweeper cancels pending scheduling on stop. Drain refusals record skipped work and skip rearming while preserving recurring intent for restart. This state has one writer.
User Impact
Expected shutdown refusals no longer appear as sweep failures. Normal reconciliation and genuine error reporting remain intact.
Evidence
Real Gateway:
pnpm openclaw gateway run --port <port>, thenpnpm openclaw gateway stop --force --jsonwhile a service holds cleanup open.Before:
subagent run sweep failed: gateway is draining for restart.After:
subagent run sweep skipped: gateway is draining for restart.pnpm openclaw gateway restart --jsonalso passed and reached ready again. All CLI and Gateway exits were 0.Compatibility
No config, schema, protocol, or public API change.
Consumers
Registry activation, recovery scheduling, and last-run cleanup retain one scheduler.
Invalidation
Stop clears the pending timer and rerun; restart activation restores the regular cadence.
Tests
34 registry lifecycle and recovery tests passed on the candidate and its merge with main. They exercise registration, last-row release, repeated activation, suspension, and overlapping timeout callbacks. Tests detect broken release/activation wiring and loss of periodic reconciliation after restart. Local preflight passed.