Skip to content

fix(setup): native Gateway setup times out validating configuration when the packaged CLI is slow - #1990

Merged
larroy merged 2 commits into
openclaw:mainfrom
larroy:fix/native-setup-command-timeout
Nov 3, 2026
Merged

larroy merged 2 commits into
openclaw:mainfrom
larroy:fix/native-setup-command-timeout

Conversation

@larroy

@larroy larroy commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: native Gateway setup fails with "Validating native Gateway configuration... Timed out." when the packaged Gateway CLI is slow to start (observed on ARM64).

User Impact

User impact: native Gateway setup gets past configuration validation on hosts where the packaged openclaw CLI needs more than 2 minutes per call. A CLI call that truly hangs now takes up to 4 minutes to fail instead of 2. Cancelling still stops it immediately.

Why This Change Was Made

Companion capped every packaged openclaw CLI call during native setup (config validate, the node-capabilities config set, gateway health, devices list, devices approve) at a hardcoded 2 minutes. On the failing host, config validate alone takes about 131 s, and its answer is valid. This PR doubles the default to 4 minutes and moves it to a named constant that OPENCLAW_SETUP_NATIVE_CLI_TIMEOUT (seconds) can override, as the repo guidelines ask. It parses the variable the same way as the existing OPENCLAW_SETUP_PACKAGE_ACQUISITION_TIMEOUT. The clawctl setup and NativeGatewayPackageClient bounds are unchanged.

Evidence

Failing run (native-setup-*.jsonl, redacted): StepPrepare ran openclaw.exe config validate --json with timeout_ms=120000. The process was killed at 120,070 ms with timed_out:true and no output, so setup failed.

Manual reproduction of the same command through the package alias (Gateway package 2026.10.900.0 arm64, isolated-session contract):

Run stdout appears Process exits Result
1 — 135.4 s {"valid":true,...,"warnings":[]}
2 126.0 s 131.5 s, exit 0 same

Both runs printed the stderr line CLI cleanup timed out: shared-state after 5000ms. Because the second run was just as slow, this is a steady-state delay, not cold start. The underlying CLI slowness belongs to the packaging repo. This PR only stops Companion from giving up first.

New NativeGatewayCliTimeoutTests cover:

  • the default is longer than the observed 131 s
  • valid overrides are used
  • 0, negative, non-numeric and out-of-range values keep the default

An independent read-only review found no P0-P2 issues. Its one P3 doc imprecision is fixed in 0f33d311.

Follow-up risk noted by review (not changed here)

In the same failing run, the isolated PreparePackageAsync step (NativeGatewayPackageClient.SetupAsync, 3-minute DefaultCommandTimeout) took 2 min 17 s, so it has about 43 s of headroom. It was not the failing step, and this PR doesn't change it.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Required proof pools

  • none: this only changes the timeout value and how it is resolved; nothing architecture-, installer-, WSL- or UI-specific changed. The ARM64 host only reproduced the slow CLI. Native setup proof on that host is listed under Not verified below.

Validation

Local, Windows ARM64, at 304b79bf:

  • ./build.ps1: exit 0
  • dotnet test ./tests/OpenClaw.SetupEngine.Tests/OpenClaw.SetupEngine.Tests.csproj --no-restore: 2529 passed, 4 skipped, 0 failed
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore: 4810 passed, 24 skipped, 0 failed
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore: 4788 passed, 0 failed
  • --filter FullyQualifiedName~NativeGatewayCliTimeoutTests: 6 passed, which confirms the new tests ran

At 0f33d311 (one-line doc change): ./scripts/validate-docs.ps1 passed, 69 Markdown files checked.

On the first Tray run, NativeGatewaySetupUxContractTests.NativeWizard_UsesSharedPageAndRpc_WithFailClosedStagedAuthorization failed. It asserted the old PairingCommandTimeout = TimeSpan.FromMinutes(2) literal. That source-text check was removed. The assertion that the two legacy pairing calls still forward environment was kept and updated to the new symbol.

Real Behavior Proof

  • Environment tested: Windows ARM64 (10.0.28000), OpenClaw Gateway Store package 2026.10.900.0 arm64 (isolated-session contract), unpackaged Debug Companion
  • PR head or commit tested: before the fix, a Debug build of an unrelated branch with identical native-setup code; the CLI timing was measured by running the command directly
  • Exact steps or command run: openclaw.exe config validate --json through the package execution alias, timed twice
  • Evidence after fix: not captured
  • Observed result: the command takes 126-131 s to produce {"valid":true}. That is over the old 120 s cap and under the new 240 s default.
  • Screenshot or artifact links verified? (Yes/No/N/A): N/A
  • Not verified or blocked: a full native Gateway setup run with this PR's build has not been performed. It needs a setup run against the installed Store Gateway, which changes Gateway runtime state.

Security Impact

  • New permissions or capabilities? (Yes/No): No
  • Secrets or tokens handling changed? (Yes/No): No
  • New or changed network calls? (Yes/No): No
  • Command or tool execution surface changed? (Yes/No): No
  • Data access scope changed? (Yes/No): No
  • If any answer is Yes, explain the risk and mitigation:

Compatibility and Migration

  • Backward compatible? (Yes/No): Yes
  • Config or environment changes? (Yes/No): Yes. New optional OPENCLAW_SETUP_NATIVE_CLI_TIMEOUT. When unset, the default is 240 s.
  • Migration needed? (Yes/No): No
  • If yes, list the exact upgrade steps:

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

Isolated-session 'openclaw config validate --json' on ARM64 (package
2026.10.900.0) takes ~131s, past the hardcoded 2-minute cap, so native
setup failed in StepPrepare. Double the per-command deadline to 4 minutes
and make it overridable via OPENCLAW_SETUP_NATIVE_CLI_TIMEOUT (seconds).
@clawsweeper

clawsweeper Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🦞👀
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.

@larroy
larroy requested a review from karkarl November 3, 2026 17:32
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 3, 2026
@clawsweeper

clawsweeper Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

This PR gives packaged Gateway CLI calls during native setup a configurable four-minute timeout.

Example: On Windows ARM64, packaged configuration validation returns valid configuration after 131.5 seconds.

  • Before: Companion terminates the command after 120 seconds and fails setup.
  • After: The default 240-second budget accommodates that command duration.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is focused and source-correct, with reported passing automated validation, but required after-fix native setup proof is absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Native Gateway setup fails while a slow packaged CLI is still validating otherwise valid configuration.
Reason: The reported command duration exceeds the existing bound, and the collaborator-authored proposal explicitly approves the longer default and optional override.

Merge readiness

✅ Ready for maintainer review

Keep open: current main still imposes the reported two-minute limit, and this maintainer-authored PR provides a focused correction with no actionable source defect found.

Priority: P1
Reviewed head: 0f33d31151f77aa3788315f4e42900f51d126bb4

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Current-head native setup has not demonstrated validation exceeding 120 seconds and then advancing successfully, including a resumed setup with existing settings intact; no base-failing production-path regression run is supplied.
Agent review details

How this fits together

The native setup session delegates package-qualified CLI execution to NativeGatewaySetupHost, which passes the resolved deadline and caller cancellation to CommandRunner and returns output or a setup error.

flowchart LR
  A[Native setup page] --> B[Native setup session]
  B --> C[NativeGatewaySetupHost]
  D[Timeout policy] --> C
  C --> E[CommandRunner]
  E --> F[Packaged Gateway CLI]
Loading

Technical review

Best possible solution:

Keep one configurable CLI deadline in the existing setup host while preserving package lifecycle, authorization, cancellation, and stored user state.

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

Current-main source terminates validation after 120 seconds, matching the author's reported timeout and successful package-alias executions beyond that limit; this review did not execute the setup flow.

Is this the best way to solve the issue?

The focused budget correction addresses Companion's premature termination using existing execution owners, while leaving the package's underlying CLI slowness to its own owner.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Packaged configuration, health, and pairing command deadlines changes intended behavior with a stated reason (dba8121: Guided native onboarding bounded package-qualified commands while accounting for packaged Node and CLI startup; no inspected evidence requires exactly two minutes.)
  • Isolated capabilities and device command routing keeps the original intent (5abfabb: The isolated-session integration keeps configuration in the agent account and packaged openclaw as the device-command owner; the PR preserves arguments and environment separation.)
  • Legacy pairing environment source guard keeps the original intent (3eed1f1: The existing onboarding guard protects staged authorization and legacy profile forwarding; the update removes the obsolete exact timeout assertion while retaining forwarding coverage.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

Likely related people:

  • Karen: Raw commit dba8121 adds src/OpenClaw.SetupEngine.UI/NativeGatewaySetupHost.cs:6 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: dba81213371c; files: src/OpenClaw.SetupEngine.UI/NativeGatewaySetupHost.cs)
  • Paul Campbell: Raw commit 5abfabb adds src/OpenClaw.SetupEngine.UI/NativeGatewaySetupHost.cs:14 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5abfabb38e12; files: src/OpenClaw.SetupEngine.UI/NativeGatewaySetupHost.cs)
  • Pedro Larroy: Raw commit e5122db adds src/OpenClaw.SetupEngine.UI/NativeGatewaySetupHost.cs:9 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e5122db3c943; files: src/OpenClaw.SetupEngine.UI/NativeGatewaySetupHost.cs)

Review metrics

Metric Value Why it matters
Introduced diff Production +51/-9; tests +44/-2; documentation +10/-0 Growth implements one timeout policy and its override contract without adding runtime state or another execution path.

Labels

Label changes:

  • add P1: The reported slow packaged CLI causes a valid native Gateway setup to fail before configuration validation completes.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: The reported slow packaged CLI causes a valid native Gateway setup to fail before configuration validation completes.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Provide current-build native setup evidence on the affected slow ARM64 package path.

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.

Reviewed November 3, 2026, 12:42 PM ET / 17:42 UTC.

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

Labels

P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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.

1 participant