Skip to content

fix(gateway): gateway stays offline after agent restart on Windows - #134549

Merged
steipete merged 2 commits into
openclaw:mainfrom
nerclid:fix/windows-agent-gateway-restart
Sep 2, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
nerclid:fix/windows-agent-gateway-restart

Conversation

@nerclid

@nerclid nerclid commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Hello! Please review the proposed solution and tests. I chose this route because it executes an existing, known good and reliable restart route. There were some simpler, but more blunt, solutions like routing all the relevant calls instead of filtering them as I have. If you would like me to make changes, please let me know. Codex was used to assist, however, I personally reviewed the code, and made changes as stated herein.

I also did some testing on #120134 and #120230, and decided a different solution was needed.

Thank you for looking, and giving consideration.

Below this point, I have asked the agent to write the remaining portion of the PR based on my notes and progress.

What Problem This Solves

Fixes #120134.

A windows user can reliably restart the gateway through the gateway agent.

Fixes an issue where users asking an agent running inside a Windows Gateway to run plain openclaw gateway restart would see the Gateway stop and remain offline until someone manually started it again.

The affected workflow is an agent-initiated restart from inside the running Gateway process tree on Windows.

Why This Change Was Made

For a plain Windows restart issued from the Gateway service environment, this change selects the existing Gateway-aware safe restart path so the running Gateway owns the deferred Scheduled Task handoff.

It deliberately preserves native routing for external callers, external-supervisor mode, stopped-Gateway recovery from external terminals without Gateway-service markers, non-Windows and node-service callers, and explicit --force, --wait, --preserve-definition, and --skip-deferral behavior.

User Impact

This also addresses @nerclid’s September 1, 2026 report in Discord #clawtributors: on Windows 11 Pro with default user permissions, asking the agent to restart the Gateway left it offline.

Users can ask an on-Gateway agent to restart a Windows Scheduled Task Gateway and expect a replacement Gateway to start, become healthy, and reconnect the webchat without manual recovery.

Existing external restart workflows and explicit lifecycle controls retain their prior behavior.

Evidence

Maintainer verification (September 1, 2026)

The maintainer independently reproduced the routing regression: with the pre-fix resolver and this PR’s unchanged tests, pnpm test src/cli/daemon-cli/register-service-commands.test.ts failed exactly 1/36 cases (uses safe restart for a plain Windows Gateway service restart, expected safe: true, received safe: false). The contributor resolver was restored byte-for-byte afterward; the identical focused command then passed 36/36 with exit 0. The native task cleanup and respawn/helper suites also passed 65/65, and the safe-RPC acknowledgement test passed. The untouched external-supervision suite twice timed out in its 180-second import hook while building worker bundles, so that broader local run is not claimed as passing. Native Windows live execution is unavailable on the maintainer Mac; the Windows observations below remain contributor-reported, not independently repeated live runs. The original exact-head aggregate CI passed, but its Windows job was skipped. A separate Windows probe, dispatched with the exact contributor SHA as target_ref, passed its Windows CI test step; its native Scheduled Task preflight failed because the runner reported user_interactive=False, so it does not provide independent live restart proof. After a patch-identical rebase, the focused routing, safe-RPC, respawn/helper, and native cleanup command passed all 103 tests with exit 0.

Both the Gateway and legacy daemon CLI docs now describe implicit safe routing and distinguish request acceptance from successor health.

Contributor-reported environment

  • Windows 11 Pro, native, guest, with an OpenClaw installation.
  • Fresh, unmodified baseline: OpenClaw 2026.8.1, revision ea80657.
  • Node.js 24.18.0.
  • Restart initiated by a real model-backed agent from webchat using plain openclaw gateway restart.

Before the change

The failure reproduced in 3/3 independent runs.

In each run, the restart controller was inside the Gateway process tree, the Gateway stopped, the controller did not reach Scheduled Task relaunch, and no replacement Gateway appeared.

After the change

The same end-to-end webchat-agent workflow passed in 3/3 consecutive runs.

Test PID transition Route Request to ready Result
1 1864 -> 6320 safe-rpc mode=deferred 30.502 s Scheduled Task result 0, RPC healthy, webchat reconnected
2 6320 -> 1196 safe-rpc mode=deferred 30.294 s Scheduled Task result 0, RPC healthy, webchat reconnected
3 1196 -> 6664 safe-rpc mode=deferred 29.371 s Scheduled Task result 0, RPC healthy, webchat reconnected

No duplicate task handoff, stale listener, unexpected in-process managed restart, configuration drift, or plugin-version drift was found.

Routing and preservation

  • 11/11 runnable restart transitions completed with distinct replacement PIDs, Scheduled Task result 0, and healthy RPC.
  • Route-selection checks passed 13/13.
  • Original-versus-patched option parity passed 18/18 outside the identified external-supervisor overlap.
  • The corrected external-supervisor exclusion passed 10/10 focused offline cases, including normalized mixed-case and whitespace-padded values.
  • Explicit --safe remains safe in external-supervisor mode.
  • External plain restart retains targeted non-safe RPC and successor-health verification.
  • Force, wait, preserve-definition, skip-deferral, node-service, non-Windows, direct RPC, and config-watcher paths retain their existing routing.

Contributor-reported repository validation

  • node scripts/run-vitest.mjs src/cli/daemon-cli/register-service-commands.test.ts - 36/36 passed on Windows with Node 24.18.0 against base 0f0ae34d9a2b84cff53a4540ab50d3666e197b71.
  • pnpm build - passed on Windows with Node 24.18.0 and pnpm 12.1.0 against base 0f0ae34d9a2b84cff53a4540ab50d3666e197b71; exit 0, total build time 5m 33.4s, all 9/9 unified tsdown invocations completed, and no tracked files changed beyond the two candidate files.
  • pnpm check - passed on Windows with Node 24.18.0 and pnpm 12.1.0 against base 0f0ae34d9a2b84cff53a4540ab50d3666e197b71; exit 0 in 854.788 s. All 18 preflight guards, 5 typecheck targets, 23 lint shards, the 32,063-file format pass, and 8 policy guards completed successfully.
  • [-] pnpm test - attempted on native Windows with Node 24.18.0 and pnpm 12.1.0; manually stopped after approximately 16m 40s when unrelated Windows EPERM, platform, and temporary-file locking failures accumulated. The run produced no final exit status, and no observed failure named either candidate file. The focused candidate suite separately passed 36/36.

Regression proof: with the test patch applied before the production repair, the same focused command failed exactly 1/36 cases because the plain Windows Gateway-service restart produced safe: false instead of safe: true; the repaired source-and-test patch then passed 36/36. The later check cleanup removed a redundant boolean wrapper and formatted the test without changing behavior.

Build proof: the candidate source-and-test patch completed the repository build with exit 0; the log contained no FAILED, ERROR, FATAL, or [INEFFECTIVE_DYNAMIC_IMPORT] markers. The later check cleanup was a semantic no-op in production code and formatter-only in the test.

Check proof: the check first identified one unnecessary boolean conversion and one formatting issue in the candidate; both were corrected minimally. The final tracked diff remains limited to the production resolver and its focused test, git diff --check passes, and the lockfile matches HEAD.

Provenance and related-PR clarification

I have observed this behavior throughout my approximately four to five months using OpenClaw. No earlier known-good release or introducing change has been identified, so I believe this should be classified as a longstanding defect with regression provenance unknown, rather than a probable regression.

PR #120230 is not a demonstrated alternative fix, and should not be considered partial overlap. I tested its current head d4b40a7f32aa597302c7c7852e3db1109c36e33f in the native model-backed Windows workflow. The restart controller survived and schtasks /End succeeded, but the existing Gateway retained the port, no successor Gateway was created, and restart failed. The detailed result is recorded in my comment on that PR.

Evidence boundaries

The broad pnpm test attempt is not claimed as a pass or a failure.

The implicit repair intentionally applies only to a plain Windows Gateway-service restart.

The same command run from an external interactive terminal is not affected.

It does not claim to change Gateway-descendant explicit --force, --wait, --preserve-definition, or --skip-deferral behavior, or any non-Windows, node-service, external-caller, stopped-Gateway recovery, or external-supervisor path.

Preservation claims for other entry points rest on the separate 11/11 runnable transitions, 13/13 route-selection checks, 18/18 option-parity checks, and focused external-supervisor matrix rather than an equivalent deep-capture series for every path.

Safe RPC acknowledges the accepted restart request before successor health is known; all three independent external observations nevertheless proved a distinct healthy replacement and webchat reconnection.

External-supervisor mode was not active during the three live runs, so that exclusion is supported by the focused 10/10 routing matrix rather than a live external-supervisor restart.

No UI was changed, so before-and-after screenshots are not applicable.

Final exact-head gate

Head 0a8b47ddd0e06b8bd953119ad17f1f20125136b6 has green exact-head CI and a fresh clean branch autoreview. Rebase preserved both patches exactly and retained @nerclid’s authorship. See the maintainer review and full evidence boundaries.

node scripts/check-changed.mjs -- docs/cli/daemon.md docs/cli/gateway.md src/cli/daemon-cli/register-service-commands.ts src/cli/daemon-cli/register-service-commands.test.ts completed with exit 0 after the rebase, including core/test typechecks, all three zero-entry dead-export scans, targeted lint, and policy guards.

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S labels Aug 31, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 8:49 PM ET / September 2, 2026, 00:49 UTC.

ClawSweeper review

What this changes

The PR routes plain Windows Gateway-service restarts initiated from the Gateway process through the existing safe restart request and documents the limited behavior change.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: current main and v2026.8.2 retain the failing plain-restart routing, while this exact branch introduces a narrow, source-consistent repair with no actionable correctness finding.

Priority: P1
Reviewed head: 0a8b47ddd0e06b8bd953119ad17f1f20125136b6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-consistent repair has strong reported Windows behavior proof and appropriate command-boundary coverage.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The changed resolver feeds the existing safe Gateway request, and the PR body records three native Windows Gateway-service webchat-agent runs after the fix with distinct replacement PIDs, healthy RPC, and reconnection.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The changed resolver feeds the existing safe Gateway request, and the PR body records three native Windows Gateway-service webchat-agent runs after the fix with distinct replacement PIDs, healthy RPC, and reconnection.
Evidence reviewed 9 items Introduced routing predicate: The PR-introduced predicate enables safe routing only for Windows Gateway-service environments, excluding external supervision and explicit force, wait, preserve-definition, and skip-deferral controls.
Agent command environment: Gateway-host exec preparation starts from process.env and sanitizes that inherited base, so installed Gateway service markers reach the affected host-shell route.
Existing safe restart owner: Lifecycle dispatch checks external supervision first, then sends safe requests through the existing Gateway RPC; the Gateway handler schedules the existing safe restart coordinator.
Findings None None.
Security None None.

How this fits together

An agent shell command inherits its Gateway service environment and invokes the shared Gateway/daemon lifecycle CLI. The resolver chooses either native service control or the running Gateway’s deferred restart coordinator, which then relaunches the Windows Scheduled Task.

flowchart LR
A[Agent shell command] --> B[Gateway service environment]
B --> C[CLI restart routing]
C --> D[Safe Gateway request]
D --> E[Restart coordinator]
E --> F[Scheduled Task handoff]
F --> G[Replacement Gateway]
Loading

Before merge

  • Resolve merge risk (P1) - The production diff is net +11 lines for a new lifecycle eligibility decision; regression protection depends on preserving the strict service-marker and explicit-option exclusions exercised by the focused table.
  • Complete next step (P2) - The open PR already owns the narrow repair; no separate automated repair lane is warranted.
Agent review details

Security

None.

PR surface

Source +11, Tests +128, Docs +4. Total +143 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 13 2 +11
Tests 1 129 1 +128
Docs 2 6 2 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 148 5 +143

Review metrics

Metric Value Why it matters
Production versus test delta production +11 net, tests +128 net, docs +4 net The added production logic is limited to command-route eligibility and explicit option preservation; the table-driven tests cover the affected routing matrix.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #120134
Summary: This PR is a candidate fix for the canonical Windows Gateway-descendant restart failure.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Accept the narrow safe-route change (recommended)
    Merge the predicate with its documented exclusions because the Windows Gateway-child path has focused routing coverage and reported native after-fix recovery.
  2. Pause for additional native coverage
    Keep the PR open if maintainers require fresh independent Windows Scheduled Task evidence beyond the supplied three-run live result.

Technical review

Best possible solution:

Keep the eligibility policy at the shared command-routing boundary, retain the explicit exclusions, and land the existing Gateway-owned safe restart path rather than changing native task-tree termination.

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

Yes at high confidence from source: on Windows a Gateway-descendant plain restart reaches native taskkill /T unless the new service-environment route selects safe RPC. This read-only review did not execute a Windows service, while the PR body supplies three reported native after-fix runs.

Is this the best way to solve the issue?

Yes. Reusing the running Gateway’s existing safe restart owner before native task-tree termination is narrower and safer than weakening the Scheduled Task cleanup path or routing every Windows restart through safe mode.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c7277fb99e69.

Labels

Label changes:

  • add merge-risk: 🚨 availability: The change alters the restart path for a running Windows Gateway, so an incorrect eligibility boundary could affect service recovery.

Label justifications:

  • P1: An agent-initiated restart can leave a Windows Gateway offline until an operator manually recovers it.
  • merge-risk: 🚨 availability: The change alters the restart path for a running Windows Gateway, so an incorrect eligibility boundary could affect service recovery.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The changed resolver feeds the existing safe Gateway request, and the PR body records three native Windows Gateway-service webchat-agent runs after the fix with distinct replacement PIDs, healthy RPC, and reconnection.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed resolver feeds the existing safe Gateway request, and the PR body records three native Windows Gateway-service webchat-agent runs after the fix with distinct replacement PIDs, healthy RPC, and reconnection.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Satoshi F.: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (8 earlier review cycles)
  • reviewed 2026-08-31T23:58:05.387Z sha 204bdb9dad1f44c43b492b680460074b74e9614e :: needs maintainer review before merge. :: none
  • reviewed 2026-09-01T00:20:52.673Z sha 958b63b685652e30f70691bc69fb7fd8d561c24b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-01T01:17:31.371Z sha 6c6728eae9941c4e70063fdf4e9b2602767e9087 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-01T02:35:39.227Z sha 6c6728eae9941c4e70063fdf4e9b2602767e9087 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-01T03:48:11.377Z sha 6c6728eae9941c4e70063fdf4e9b2602767e9087 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T00:17:09.668Z sha 4f7a071dc7fc990733d3924672b59c7db7200115 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T00:24:22.920Z sha 4f7a071dc7fc990733d3924672b59c7db7200115 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T00:37:04.181Z sha 0a8b47d :: needs maintainer review before merge. :: none

@nerclid
nerclid force-pushed the fix/windows-agent-gateway-restart branch 2 times, most recently from ad57179 to 6c6728e Compare September 1, 2026 01:09
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 1, 2026
@steipete

steipete commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer review

Best-fix verdict: best fix at the command-routing owner. The native Windows restart ends the Scheduled Task and terminates the Gateway process tree before relaunch (src/daemon/schtasks-control.ts:337, src/daemon/schtasks-process.ts:311). An agent-launched CLI is in that tree and can die before /Run. The shared Gateway/daemon resolver previously selected the native path unless --safe was explicit (src/cli/daemon-cli/register-service-commands.ts:35). The reviewed main baseline and stable v2026.8.1 retained that behavior before this landing.

The candidate selects the existing safe RPC only for plain Windows Gateway-service calls. src/cli/daemon-cli/lifecycle.ts:527 preserves external-supervisor ownership; src/cli/daemon-cli/lifecycle-safe-restart.ts:86 submits gateway.restart.request; src/infra/restart-coordinator.ts:112 schedules the restart; src/cli/gateway-cli/run-loop.ts:347 closes the server before src/infra/process-respawn.ts:62 reaches the existing detached Windows helper (src/infra/windows-task-restart.ts:108). No replacement native termination policy or extra restart helper is needed.

Alternatives considered: making every Windows restart safe would break stopped-Gateway recovery for external terminals; suppressing tree cleanup in the task owner changes verified native cleanup and can leave the old listener alive (also observed by @nerclid in #120230 (comment)). The existing safe owner is preferable to either alternative.

Code read includes the resolver and real Commander registration for both Gateway and legacy daemon, lifecycle and safe/external-supervisor owners, Scheduled Task control/process/runtime owners, service environment producer, restart coordinator/run loop/respawn/helper, update handoff and restart-helper siblings, supervisor markers, and the adjacent tests. I personally checked Codex's codex-rs/protocol/src/config_types.rs:261 (default shell inheritance) and codex-rs/protocol/src/shell_environment.rs:99 (environment construction): service markers are inherited by default, while explicit environment filtering can remove them. The patch reuses isGatewayServiceEnv; it does not introduce a second marker parser. A later shared detector from the Linux managed-update handoff work can be adopted separately when that owner lands.

ClawSweeper remaining items addressed: accept the narrowly scoped command-boundary predicate; no separate repair job or new lower-level restart flow is warranted. Production is +13/-2 (net +11), tests +129/-1 (net +128), and documentation +6/-2. The production growth represents the missing routing decision plus preservation of the shipped force/wait/preserve-definition/skip-deferral contracts and external-supervisor ownership. Folding that decision into native task control would duplicate Gateway-safe policy; deleting those exclusions would change public behavior. No unrelated consolidation was used to offset the count. No config, dependency, storage, or schema changes.

Independent regression proof: pnpm test src/cli/daemon-cli/register-service-commands.test.ts with the original resolver substituted failed exactly 1/36 cases, uses safe restart for a plain Windows Gateway service restart, because expected safe: true was safe: false. Restoring the contributor source byte-for-byte made the identical command pass 36/36, exit 0. Native cleanup plus respawn/helper tests passed 65/65; the safe-RPC acknowledgement test passed. The additional unmodified external-supervision suite twice timed out in its 180-second import hook while preparing worker bundles; its 13 cases did not execute, so that broader command is not claimed as a pass.

Windows evidence is explicitly separate: the contributor reports three failing-before and three passing-after Windows 11 model-backed webchat runs. I could not repeat that live flow on this Mac. The dedicated Windows probe was dispatched with target_ref 6c6728eae9941c4e70063fdf4e9b2602767e9087; its Windows CI test step passed, but native Scheduled Task proof was skipped after the runner reported user_interactive=False: https://github.com/openclaw/openclaw/actions/runs/33572849343. This is Windows test proof, not an independent live agent-restart result. Safe RPC acknowledges request acceptance, not successor health; the docs now say so. Stopped-Gateway recovery is preserved for external terminals without inherited Gateway-service markers.

The initial local changed gate stopped on five due plugin-compatibility records; main already carried the owning fix, #135322 (91067e340a1811f94a3f119fae329542c3f23872). A patch-identical rebase absorbed that fix without editing the ledger or SDK. The earlier docs-follow-up CI failure was in dependency installation, not this repair; the final exact head is green as recorded below.

The uncommitted full-diff autoreview returned: autoreview scoped-clean: no accepted/actionable findings in the selected Git scope and priority. Credit stays with Josh (@nerclid); the maintainer follow-up only aligns Gateway and daemon documentation and adds independent verification.

The refreshed ClawSweeper review covers the final head; its two maintainer decisions are explicitly accepted above: preserve the narrow eligibility boundary and avoid a separate repair job. Exact-head CI is green.

Exact-head landing update

The rebase was patch-identical for both commits (git range-diff marked both =) and preserves Josh’s authorship. Final head: 0a8b47ddd0e06b8bd953119ad17f1f20125136b6. Exact-head CI completed green: https://github.com/openclaw/openclaw/actions/runs/33575522638; the repository watcher ended STATUS state=SUCCESS pending=0 superseded=0 / GREEN. Fresh branch autoreview also returned autoreview scoped-clean: no accepted/actionable findings in the selected Git scope and priority. The refreshed ClawSweeper review on this exact head has no actionable findings; its eligibility-boundary/production-growth decision is accepted for the reasons above, and no separate repair job is needed.

The earlier 4f7a071dc7fc CI run failed before tests in a Matrix crypto dependency download (ECONNRESET, followed by its installer’s undefined err variable); no dependency patch was made. The rebased focused command passed all 103 tests with exit 0: pnpm test src/cli/daemon-cli/register-service-commands.test.ts src/cli/daemon-cli/lifecycle-safe-restart.test.ts src/infra/process-respawn.test.ts src/infra/windows-task-restart.test.ts src/daemon/schtasks.stop.test.ts. This covers 36 routing cases, two safe-RPC tests, 35 respawn/helper cases, and 30 native cleanup cases. The broader external-supervision timeout and interactive Windows limitation above remain explicit. Proceeding through the repository-native landing gates.

Landed

Merged via scripts/pr as 3a0a623; #120134 is closed as completed. prepare-run complete and merge-verify passed were observed before the exact reviewed head merged. The merge retained Josh’s contributor credit. Native local worktree cleanup completed, but deleting the contributor’s remote branch was denied; it was left intact. The wrapper recorded the durable merge receipt and completion comment.

Final local verification: node scripts/check-changed.mjs -- docs/cli/daemon.md docs/cli/gateway.md src/cli/daemon-cli/register-service-commands.ts src/cli/daemon-cli/register-service-commands.test.ts completed with exit 0 after the rebase, including core/test typechecks, all three zero-entry dead-export scans, targeted lint, and policy guards.

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Sep 2, 2026
@steipete
steipete force-pushed the fix/windows-agent-gateway-restart branch from 4f7a071 to 0a8b47d Compare September 2, 2026 00:29
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Sep 2, 2026
@steipete
steipete merged commit 3a0a623 into openclaw:main Sep 2, 2026
300 checks passed
@steipete

steipete commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

RomneyDa added a commit that referenced this pull request Sep 19, 2026
* fix(update): restore Gateway after partial stop failure

Adapt the service-mutation recovery invariant to the 2026.8 updater owner.

(cherry picked from commit ad682b4)

* fix(update): replace unsupported service Node runtimes

Adapt the recorded-service runtime probe to the 2026.8 daemon install plan.

(cherry picked from commit fe79d36)

* fix(gateway): gateway stays offline after agent restart on Windows (#134549)

* fix(gateway): keep agent restart alive on Windows

* docs(gateway): clarify Windows agent restart routing

---------

Co-authored-by: Josh <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
(cherry picked from commit 3a0a623)

* fix: published Linux upgrades leave unchanged gateways stopped (#151049)

* fix(update): preserve service fingerprints across published upgrades

Keep known-empty systemd override metadata out of the fingerprint retained by published updaters through 2026.9.4. Preserve full command metadata for runtime pinning and reject actual protected service changes.

* test: group silence failures with error payload coverage

Keep the required sealed-answer fixture field while moving its related failure-policy cases into the existing error payload test module. Preserve every case and assertion without growing the over-cap payload test file.

(cherry picked from commit 4475640)

* fix(doctor): preserve explicitly configured profile workspaces (#145976)

* fix(doctor): preserve configured profile workspaces

* fix(doctor): avoid assuming workspace ownership

Co-authored-by: ericcaiwx-star <[email protected]>
(cherry picked from commit 1e8ba48)

* fix(plugins): stop relocated install records from shadowing bundled plugins (#144843)

* fix(plugins): stop relocated install records from shadowing bundled plugins

A `path` install record stores an absolute directory. When that directory is
another OpenClaw installation's bundled plugin tree, the record survives the
installation move and is rediscovered as an `origin: "global"` candidate.
`global` outranks `bundled`, so the stale pin won the duplicate-id contest and
the plugin resolved from the old installation. `resolvePluginTrust` then saw
`record.source === "path"` and downgraded it to `origin-path`, which revokes
trusted plugin state and fails trusted-only APIs mid-turn.

`isIntentionalInstalledBundledDuplicate` also suppressed the duplicate warning,
because installed-shadows-bundled is normally deliberate, so the swap was silent.

Treat a plugin directory inside a *different* installation's bundled roots as
stale: it no longer outranks the current bundled copy, and it no longer counts
as an intentional shadow, so the existing duplicate warning reports it.

* fix(plugins): name the stale install record instead of a generic duplicate

The duplicate-id warning reported "global plugin will be overridden by bundled
plugin", which describes the mechanism but gives an operator nothing to act on.
A pin into another installation's bundled tree is a stale record rather than a
deliberate override, so report it as one and name the remedy.

* docs(agents): record that a stored absolute path is not provenance

The stale-pin defect this branch fixes came from a persisted absolute path that
kept conferring bundled status after the installation it named was replaced.
Record the invariant so the next record type does not repeat it.

* fix(plugins): narrow the stale-pin gate to relocated compiled trees

Review of the preceding guard found two ways it misfired.

It answered "foreign" by negating a membership test against the running
package roots, so an install whose root resolves from neither argv nor the
module URL saw every bundled tree as foreign, including its own. Compiled
sibling trees and the module walk-up fallback resolve exactly that way, so the
gate now fails open when the running root is unknown.

It also accepted `<root>/extensions/<id>`, the documented
`plugins install --link` development target, which made a deliberate local
override report as a stale record and told the developer to delete it. Only
compiled `dist`/`dist-runtime` trees travel with an installation, so the shape
check is limited to those, and a plugin inside the configured dev source root is
excluded at the call site, where importing it raises no cycle.

* test(auth): pin external credential refresh timing (#152771)

---------

Co-authored-by: Peter Steinberger <[email protected]>
(cherry picked from commit 5ec3614)

* fix(plugins): archive updates fail on development-only dependencies (#143350)

* fix(plugins): isolate npm manifest resolution

* fix(plugins): preserve hook host dependencies

* test(plugins): align npm isolation coverage with CI limits

* fix(plugins): link optional-only OpenClaw host dependencies

* test(gateway): settle companion databases before fixture cleanup

* test(plugins): cover optional hosts in native import preparation

* test(skills): close status watchers before retiring fixture roots

---------

Co-authored-by: Gio Della-Libera <[email protected]>
Co-authored-by: Jason (Json) <[email protected]>
(cherry picked from commit cbf935b)

* fix(gateway): release agent leases when shutdown completes (#151435)

Drain the existing agent database lifecycle during final Gateway retirement before shared state closes. Preserve sibling ownership and surface native-close failures without dropping their lease.

Four new regressions fail on the original code. The repair passes 92 focused cases and an isolated four-case rerun, changed checks, and independent P0-P2 review.

(cherry picked from commit 3381de9)

* fix: restore Gateway restarts after Git updates (#138781)

* fix: restore Gateway restarts after Git updates

* test: align update installer mock with eager import

(cherry picked from commit 24d8119)

---------

Co-authored-by: josh <[email protected]>
Co-authored-by: Josh <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Eric Cai <[email protected]>
Co-authored-by: Gio Della-Libera <[email protected]>
Co-authored-by: Gio Della-Libera <[email protected]>
Co-authored-by: Jason (Json) <[email protected]>
Co-authored-by: Jason O'Neal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 'openclaw gateway restart' run via agent exec kills the CLI itself on Windows (taskkill /T terminates child process), leaving the gateway stopped

2 participants