Skip to content

fix: planned restarts no longer log the expected subagent sweep skip as a warning - #201774

Open
Anurag-5ingh wants to merge 1 commit into
openclaw:mainfrom
Anurag-5ingh:fix/subagent-sweep-drain-log-level
Open

Anurag-5ingh wants to merge 1 commit into
openclaw:mainfrom
Anurag-5ingh:fix/subagent-sweep-drain-log-level

Conversation

@Anurag-5ingh

@Anurag-5ingh Anurag-5ingh commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Refs #200440

What Problem This Solves

Every planned Gateway restart can log WARN subagent run sweep skipped: gateway is draining for restart. The skip is the designed behavior: restart drain refuses new background work, and the next Gateway resumes the sweep. Logging it as a warning makes routine restarts look like faults. The reporter counted 155 of these lines in 31 days of nightly restarts.

User Impact

The expected drain skip is still recorded, at info, so it no longer shows up as a warning on every restart. A genuine sweep failure still logs subagent run sweep failed: ... at warn.

Why This Change Was Made

#147904 changed this refusal from a "sweep failed" message to "sweep skipped" and kept it as a record of skipped work. It went through warn only because that was the sweeper's only logger. The sweeper now also receives info from the registry's existing subsystem logger, and the drain skip uses it. Scheduling is unchanged: the refused tick still returns without rearming, as before.

Scope follows the review's suggested first repair: only the drain-skip severity. The health-refresh capacity errors and lease-wait volume in the issue need separate evidence, so this PR refers to the issue instead of closing it.

Evidence

  • New regression test in subagent-registry-sweeper-recovery.test.ts: with restart drain marked through the real Gateway work-admission module, a sweeper tick records the skip at info, makes no warn call, does no cleanup and keeps the run. It fails on current main (the skip goes to warn) and passes with this change.

  • Sweeper and registry suites pass: sweeper recovery, lifecycle, owed batches, kill and restart settle, registry pressure, plus every suite using the sweeper test helpers and the lifecycle timer retention fixture (191 tests).

  • pnpm tsgo:core, pnpm tsgo:core:test, oxlint, oxfmt and git diff --check are clean.

  • Live Gateway capture, before and after. Isolated state dir and port, model served by the repo's local QA mock provider (startQaMockOpenAiServer), channels skipped. Steps: pnpm openclaw gateway run --port <port>, then pnpm openclaw agent --message 'Call sessions_spawn with task="..." mode=run' so a real subagent launch arms the sweeper, then SIGTERM to that foreground Gateway timed to land just before the sweeper's next 60-second tick. The tick then starts inside the stop drain. Same steps on both builds; only the two runtime files differ.

    Before (main), structured Gateway log:

    00:34:22.986 [gateway] received SIGTERM; shutting down
    00:34:23.151 [agents/subagent-registry] subagent run sweep skipped: gateway is draining for restart
                 "logLevelName":"WARN"
    00:34:23.219 [shutdown] completed cleanly in 230ms
    

    After (this branch):

    00:31:34.319 [gateway] received SIGTERM; shutting down
    00:31:34.503 [agents/subagent-registry] subagent run sweep skipped: gateway is draining for restart
                 "logLevelName":"INFO"
    00:31:34.604 [shutdown] completed cleanly in 279ms
    

    Shutdown completed cleanly in both runs; only the recorded level changed.

A sweep refused because the Gateway is draining for a planned restart is
expected and is resumed by the next Gateway. Record it at info instead of
warn; genuine sweep failures stay at warn.

Refs openclaw#200440
@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Nov 19, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR logs expected subagent sweep refusals during Gateway drain at INFO while retaining WARN for genuine sweep failures.

Example: A subagent sweep becomes due while the Gateway drains after SIGTERM.

  • Before: The expected skip produces WARN: subagent run sweep skipped: gateway is draining for restart.
  • After: The same skip produces INFO, preserving the record without signaling a fault.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused, correct repair with direct Gateway evidence; the overall tier reflects partial coverage of the linked issue, while workflow approval remains a separate gate.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The new PR-body logs resolve the previous review's missing-proof blocker: the CLI-launched isolated Gateway exercises the production registry, sweeper, admission check, and subsystem logger during SIGTERM drain, showing WARN before and INFO after; the mock model endpoint does not replace the changed logging path.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Routine planned restarts emit a warning for background work that was intentionally refused.
Reason: Expected drain refusal is already classified by the owner, making a narrow severity correction valuable; the broader linked report appropriately remains open.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: the focused logging correction is useful and introduces no identified defects; exact-head CI still awaits workflow approval.

Priority: P3
Reviewed head: f655bc99ac1d7f9e91c5e2f9d197cec2300f1905

Before merge

Findings

None.

Agent review details

How this fits together

The subagent registry supplies logging callbacks to its background sweeper, which submits cleanup through Gateway work admission and records accepted work, expected drain refusals, or genuine failures.

flowchart TD
  A[Subagent registry] --> B[Scheduled sweeper tick]
  B --> C[Gateway work admission]
  C --> D[Admitted cleanup]
  C --> E[Drain refusal]
  E --> F[INFO skip record]
  D --> G[WARN on genuine failure]
Loading

Technical review

Best possible solution:

Use the existing registry logger to record expected drain skips at INFO while preserving admission, scheduling, cleanup, and genuine failure warnings.

Do we have a high-confidence way to reproduce the issue?

Current-main source directly routes expected drain refusal to WARN, and the contributor supplies a matching Gateway capture; this read-only review ran no target code.

Is this the best way to solve the issue?

The patch is the smallest complete severity correction: it extends the existing logger injection, updates every consumer, and adds one regression without introducing another policy owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f0f3db9e4aeb.

Provenance checked

  • Expected drain-refusal logging changes intended behavior with a stated reason (f4ffd8c: Distinguish expected shutdown refusal from genuine sweep failure, retain a skipped-work record, and avoid rearming during drain.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +3, Tests +17. Total +20 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 4 1 +3
Tests 4 17 0 +17
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 21 1 +20

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This corrects misleading operational severity without changing restart success or cleanup behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-19T11:07:19.352Z sha f655bc9 :: needs real behavior proof before merge. :: none

Reviewed November 19, 2026, 2:10 PM ET / 19:10 UTC (Revision 2).

@Anurag-5ingh

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Added a live Gateway before/after capture to the PR body: a real subagent launch arms the sweeper, the Gateway is stopped as the tick comes due, and the same skip is recorded at WARN on main and at INFO on this branch.

@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Nov 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant