Repository navigation
Description
Summary
With the native (MSIX / Store) Gateway, a cold boot leaves Companion permanently "not connected" until the app is restarted. The startup connect happens exactly once, and it is rejected while the Gateway package is still in the starting state. Nothing reconnects afterwards — not the WebSocket backoff, not the operator reconnect scheduler, and not the managed-local auto-repair monitor.
The fix is not user error and not a timing coincidence: the Gateway needs ~150 s to become reachable after boot, and the one-shot startup attempt lands inside that window every time.
Environment
- Windows 11, Companion v2026.9.8-1 (latest release), installed from the MSIX/Store package
- Gateway: native MSIX package,
isolated-session-v1runtime contract, endpointws://127.0.0.1:54610/ - Companion autostarts on logon; the Gateway package also starts on its own at boot
- Verified the same code exists on
main(c59652f) and on tagv2026.9.8-1, so this is shipped behavior, not an outdated build
Steps to reproduce
- Reboot the machine with the native Gateway installed and Companion set to autostart.
- Let both start on their own (Gateway takes ~150 s to open its HTTP/WS listener).
- Open Companion.
Expected
Companion shows "connecting" and connects on its own once the Gateway is ready (the readiness budget already exists: IsolatedGatewayRuntime.StartupTimeout = 180 s by default).
Actual
Companion stays disconnected indefinitely. Restarting the app makes it connect within seconds.
Evidence from openclaw-tray.log (offsets from Gateway start)
| Offset | Event |
|---|---|
| T+0 | Gateway package starts (its own gateway.json records the start) |
| T+77 s | Companion tray starts |
| T+79 s | Connecting to last successful gateway during startup: ws://127.0.0.1:54610/ (identity.DeviceToken) — and then nothing |
| T+148 s | Gateway log: [gateway] ready |
| T+163 s | User restarts Companion |
| T+169 s | Connecting to gateway: ws://127.0.0.1:54610/ |
| T+173 s | Handshake complete (hello-ok) |
The diagnostic signature matters: the failed attempt logs no Connecting to gateway: line, no Loaded Ed25519 device identity, and no error line at all. The connect pipeline never reaches the WebSocket layer, so there is nothing to retry.
Root cause
1. The startup connect is one-shot
src/OpenClaw.Tray.WinUI/App.xaml.cs — TryConnectGatewayIfCredentialAvailable(...) calls _connectionManager.ConnectAsync(record.Id) once during startup and only observes the task for faults. There is no scheduler behind it.
2. The pipeline refuses a Gateway that is still booting
GatewayConnectionManager.ConnectCoreAsync (src/OpenClaw.Connection/GatewayConnectionManager.cs:434) calls AuthorizeCredentialForEndpointAsync → NativeGatewayEndpointSecurity.AuthorizeAsync → IsolatedGatewayRuntime.EnsureRunningCoreAsync:
src/OpenClaw.Connection/NativeGateway/IsolatedGatewayRuntime.cs:105
if (status.State is "not-started" or "stopped")
{
...
status = await StartAndWaitAsync(package, endpoint.Port, cancellationToken).ConfigureAwait(false);
}
if (status.State != "running" || status.Port != endpoint.Port)
throw new NativeGatewayContractException(
"The package-managed Gateway is not running on Companion's selected port. " +
"Check clawctl gateway-service status before connecting.");The state vocabulary (src/OpenClaw.Connection/NativeGateway/NativeGatewayPackageClient.cs:150) is running, not-started, stopped, starting, unhealthy, unknown.
So a Gateway that is already booting on its own reports starting, which:
- does not enter the
not-started/stoppedbranch that would wait, and - fails the
!= "running"check and throws immediately.
StartAndWaitAsync already knows how to poll starting/unhealthy until ready (IsolatedGatewayRuntime.cs:212) with a bounded budget, but that loop is unreachable from a starting state.
3. The rejection parks the connection in Error and returns
GatewayConnectionManager.cs:445
if (!endpointAuthorization.Allowed)
{
_stateMachine.TryTransition(ConnectionTrigger.ConnectRequested);
...
_stateMachine.TryTransition(...ConnectionTrigger.WebSocketError..., endpointAuthorization.Detail);
_diagnostics.Record("setup", "Blocked strong credential before managed-local endpoint ownership was proven", ...);
EmitStateChanged();
return;
}No client is created, so no WebSocket attempt, no connecting log line, no error log line — exactly the observed signature.
4. No retry path covers this failure
WebSocketClientBase.cs:381schedulesReconnectWithBackoffAsynconly after a socket was actually attempted.IOperatorReconnectScheduler.ScheduleOperatorReconnect(GatewayConnectionManager.cs:3341) exists only forOperatorReconnectReason.PostBootstrapHandoffand operator-token recovery.ManagedLocalGatewayAutoRepairMonitordeliberately ignores native records:WslKeepAlivePolicy.IsSetupManagedLocalRecord→GatewayRecord.ResolveManagedDistroNamereturnsnullwhenNativePackageFamilyName is not null(GatewayRecord.cs:195-199, comment: "A native gateway's display name must never confer legacy WSL ownership"). The in-app self-heal therefore never runs for the native Gateway.
Suggested fix
Minimal, two changes:
IsolatedGatewayRuntime.EnsureRunningCoreAsync: treatstarting(andunhealthy) as a pending start and enter the existing bounded readiness poll instead of throwing. E.g. factor the status loop out ofStartAndWaitAsyncintoWaitForRunningAsyncand call it for both thenot-started/stoppedbranch and astarting/unhealthypre-state. A cold boot withinStartupTimeoutthen simply succeeds.ConnectCoreAsync: for a native record whose authorization failed withGatewayErrorKind.Networkand aNoListener/UnknownListenerprovenance, schedule one bounded retry (newOperatorReconnectReason, reusing the existing backoff helper) instead of parking inErrorforever.
A unit test with a fake package client returning starting then running (in the style of the existing IsolatedGatewayRuntime tests) would lock this in.
Workaround
A logon wrapper that polls http://127.0.0.1:54610/health and only launches Companion once the Gateway answers, plus a bounded watchdog that relaunches Companion if it does not connect, works reliably. That is what I am using now, but it is a shim for a state the client should handle itself.
Notes / limits
- The evidence is from logs plus the source above; I did not instrument the running app, so the exact provenance kind at the failure instant is inferred from the silent branch and the code path rather than read out of the state snapshot.
- No secrets, tokens, device ids or user names are included in this report.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsBacklog
Activity
clawsweeper commentedon Oct 28, 2026
ClawSweeper status: review started.
Codex review: this still needs some work.
Summary
Current main still rejects an already-starting native Gateway before transport recovery can run; the linked fixes leave this failure unresolved.
Reproducibility: An initial starting status deterministically throws before socket creation, and an existing test explicitly asserts that rejection; no live reproduction, build or tests ran in this read-only review, and WinApp CLI was unavailable.
Maintainer decision needed
Next step
Decide whether to allow passive waiting, then establish a failing starting-to-running regression requiring automatic connection without lifecycle adoption or premature credential release.
Review details
Best possible solution:
Provide bounded passive readiness observation without lifecycle adoption, followed by fresh listener verification and visible Retry now recovery on expiry.
Do we have a high-confidence way to reproduce the issue?
An initial starting status deterministically throws before socket creation, and an existing test explicitly asserts that rejection; no live reproduction, build or tests ran in this read-only review, and WinApp CLI was unavailable.
Is this the best way to solve the issue?
Target the pre-socket readiness boundary after resolving lifecycle policy; reusing StartAndWaitAsync would dispatch a start and introduce cleanup ownership, while generic Network or UnknownListener retries would cover unrelated failures.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning medium; reviewed against 66b9b5a559a0.
Label changes
Label changes:
clawsweeper:fix-shape-clear: Current issue advisory state selects this label.Label justifications:
P1: A source-confirmed failure in released code breaks automatic Gateway connection after ordinary logon.impact:ux-friction: Recovery requires a manual retry or Companion restart; a first-run dead end without an in-product route is not established.Evidence reviewed
Acceptance criteria:
What I checked:
src/OpenClaw.Connection/NativeGateway/IsolatedGatewayRuntime.cs:141, 66b9b5a559a0)src/OpenClaw.Connection/GatewayConnectionManager.cs:446, 66b9b5a559a0)tests/OpenClaw.Connection.Tests/IsolatedGatewayRuntimeTests.cs:828, 66b9b5a559a0)docs/ONBOARDING_WIZARD.md:524, 66b9b5a559a0)src/OpenClaw.Connection/NativeGateway/IsolatedGatewayRuntime.cs, 5abfabb38e12)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.Reviewed November 14, 2026, 10:27 PM ET / November 15, 2026, 03:27 UTC.
github-actions commentedon Nov 12, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updated OpenClaw Windows details or it will be closed.
shuweili102-hub commentedon Nov 23, 2026
I can reproduce the same startup connection issue on a newer build.
Environment
Startup behavior
On cold boot, the Companion log reports:
"Gateway service status: gateway starting, session running, readiness startup-eligible (gateway-mode-local)."
It then reports:
"Blocked strong credential before managed-local endpoint ownership was proven"
The Companion process remains running, but the initial connection does not recover automatically.
Manual reconnect works
After the Gateway is ready, manually reconnecting succeeds:
This suggests the initial connection is rejected before the WebSocket handshake, so the normal WebSocket retry mechanism may not be triggered.
Could you confirm whether this issue is fixed in a newer build, and whether the Companion can retry automatically once the managed Gateway reaches the ready state?
Thanks.