Skip to content

Fix/nodes run timeout propagation - #42590

Closed
danedane wants to merge 4 commits into
openclaw:mainfrom
danedane:fix/nodes-run-timeout-propagation
Closed

danedane wants to merge 4 commits into
openclaw:mainfrom
danedane:fix/nodes-run-timeout-propagation

Conversation

@danedane

Copy link
Copy Markdown

Summary

• Problem: nodes run (system.run) kills any node command taking >30s because callGatewayTool uses gatewayOpts.timeoutMs (default 30s) regardless of commandTimeoutMs or invokeTimeoutMs values.
• Why it matters: Makes nodes run unusable for any real workload (builds, coding agents, long scripts) on paired nodes.
• What changed: Compute runGatewayTimeout from invokeTimeoutMs or commandTimeoutMs + 15s, propagate it to both the websocket call options and the message-level timeoutMs.
• What did NOT change (scope boundary): No schema changes, no gateway-side changes, no new parameters. Only the agent-side timeout propagation logic in nodes-tool.ts.

Change Type (select all)

• [x] Bug fix
• [ ] Feature
• [ ] Refactor
• [ ] Docs
• [ ] Security hardening
• [ ] Chore/infra

Scope (select all touched areas)

• [ ] Gateway / orchestration
• [x] Skills / tool execution
• [ ] Auth / tokens
• [ ] Memory / storage
• [ ] Integrations
• [ ] API / contracts
• [ ] UI / DX
• [ ] CI/CD / infra

Linked Issue/PR

• Closes #
• Related #

User-visible / Behavior Changes

• nodes run commands with commandTimeoutMs or invokeTimeoutMs set will now correctly wait for the node to complete instead of timing out at 30s.
• No new parameters or config changes. Existing behavior for commands <30s is unchanged.

Security Impact (required)

• New permissions/capabilities? No
• Secrets/tokens handling changed? No
• New/changed network calls? No
• Command/tool execution surface changed? No
• Data access scope changed? No

Repro + Verification

Environment

• OS: WSL2 (Ubuntu) + Windows 11 paired node
• Runtime/container: Node v22.22.0, OpenClaw v2026.3.8
• Model/provider: github-copilot/claude-opus-4.6
• Integration/channel: Telegram
• Relevant config: Default gateway config, Windows companion node paired via LAN

Steps

Pair a Windows node with OpenClaw gateway
Run nodes run with a command that takes >30s (e.g., ping -n 35 127.0.0.1) and commandTimeoutMs: 60000
Observe timeout behavior
Expected

• Command completes after ~35s and returns stdout with all 35 ping replies

Actual

• Before fix: gateway timeout after 30000ms error at 30s
• After fix: Command completes successfully (34.6s), returns full output

Evidence

• [x] Trace/log snippets

Before fix:

{"status":"error","error":"gateway timeout after 30000ms"}

After fix (monkey-patched dist):

{"stdout":"...35 pings...","exitCode":0,"timedOut":false,"durationMs":34605}

Also tested GitHub Copilot CLI (74s run) successfully via Windows node after fix.

Human Verification (required)

• Verified scenarios: 35-ping test (34.6s), Copilot CLI codebase analysis (74s), both via Windows node
• Edge cases checked: No invokeTimeoutMs set (falls back to commandTimeoutMs + 15s); neither set (preserves default 30s behavior)
• What you did not verify: Approval retry path (tested only the first-attempt path); nodes invoke action (separate code path with same issue, not addressed here)

Review Conversations

• [x] I replied to or resolved every bot review conversation I addressed in this PR.
• [x] I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

• Backward compatible? Yes
• Config/env changes? No
• Migration needed? No

Failure Recovery (if this breaks)

• How to disable/revert this change quickly: Revert the single commit; timeout falls back to default 30s behavior.
• Files/config to restore: src/agents/tools/nodes-tool.ts
• Known bad symptoms reviewers should watch for:

If runGatewayTimeout computes an unexpectedly large value, gateway websocket connections could stay open longer than intended. Mitigated by only deriving from user-provided timeout params.

Risks and Mitigations

• Risk: Gateway websocket connections held open longer when large commandTimeoutMs values are passed.

• Mitigation: Timeout is derived directly from user-specified params — no unbounded defaults. If neither commandTimeoutMs nor invokeTimeoutMs is set, behavior is unchanged (30s default).

Q added 2 commits March 10, 2026 16:41
…or system.run

The nodes 'run' action passes commandTimeoutMs to the node as the
process timeout, and invokeTimeoutMs inside the node.invoke message.
However, callGatewayTool uses gatewayOpts.timeoutMs (default 30s) for
the websocket call timeout, meaning any node command taking >30s is
killed by the gateway before the node can respond.

This computes runGatewayTimeout from invokeTimeoutMs (if set) or
commandTimeoutMs + 15s buffer, and uses it for both the
callGatewayTool options and the message-level timeoutMs. This ensures
the gateway waits long enough for the node to complete the command.

Affects both the initial run attempt and the post-approval retry path.
Addresses review feedback: small commandTimeoutMs values (e.g. 2s)
could shrink the gateway timeout below 30s, which breaks node
wake/reconnect flows that need the full default budget.
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Mar 11, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fa36bae42c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/tools/nodes-tool.ts Resolved
…invokeTimeoutMs

Addresses review: explicit invokeTimeoutMs should be honored as-is
for callers that need short timeouts for fast failure/retry. The 30s
floor now only applies to the commandTimeoutMs-derived path.
@greptile-apps

greptile-apps Bot commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a timeout propagation bug in the nodes run (system.run) action where the gateway websocket always used its default 30-second timeout regardless of the user-specified commandTimeoutMs or invokeTimeoutMs, making any command longer than 30 seconds fail prematurely.

The fix introduces runGatewayTimeout, derived from invokeTimeoutMs (priority) or commandTimeoutMs + 15s (fallback), clamped to a 30s floor, and applies it to both the callGatewayTool websocket options and the message-level timeoutMs for both the initial attempt and the approval-retry path. The change is minimal and backward-compatible.

Issue found:

A logic flaw remains: when both invokeTimeoutMs and commandTimeoutMs are provided with invokeTimeoutMs < commandTimeoutMs + buffer, the derived runGatewayTimeout still caps at the 30s floor only—not at commandTimeoutMs + buffer. This reproduces the premature timeout symptom (e.g., invokeTimeoutMs = 10_000, commandTimeoutMs = 60_000 → gateway closes at 30s while the 60s command is still running). The guard should ensure runGatewayTimeout ≥ Math.max(invokeTimeoutMs, commandTimeoutMs + 15_000, 30_000).

Confidence Score: 2/5

  • The PR has a real logic bug where contradictory timeout parameters can still trigger premature timeouts; should be addressed before merge.
  • The core timeout propagation fix is sound and addresses the primary 30-second hard limit issue. However, a logic flaw remains in the edge case where invokeTimeoutMs is explicitly set smaller than commandTimeoutMs + buffer—the gateway timeout still caps at 30s rather than protecting the full command duration. This is a concrete, reproducible bug that can reproduce the same symptom the PR is trying to fix, just via a different parameter combination. The issue merits correction before wide deployment.
  • src/agents/tools/nodes-tool.ts — specifically the timeout derivation logic at lines 645–651 needs to guard against invokeTimeoutMs undercutting commandTimeoutMs + buffer.

Last reviewed commit: 9af7e20

Comment thread src/agents/tools/nodes-tool.ts Resolved
…imeoutMs is shorter

Addresses Greptile review: when both params are set and
invokeTimeoutMs < commandTimeoutMs + buffer, the gateway would still
kill the connection before the node finishes. Now takes the max of
derivedTimeout, commandTimeoutMs + 15s, and 30s floor.
@steipete

Copy link
Copy Markdown
Contributor

Closing this as implemented after Codex review.

Current main already supersedes this PR: the nodes run path it patches no longer exists, system.run is intentionally blocked from nodes invoke, and node shell execution now goes through exec host=node, which derives and applies a longer gateway timeout for node.invoke calls.

What I checked:

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review notes: reviewed against 564f820efa2b; fix evidence: commit 564f820efa2b.

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

Labels

agents Agent runtime and tooling size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants