Repository navigation
fix(exec): arm the gateway node invoke deadline from exec host=node - #116591
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 2:40 PM ET / 18:40 UTC. ClawSweeper reviewWhat this changesThe PR adds a top-level Gateway invocation deadline to Merge readiness✅ Ready for maintainer review Keep this PR open for normal maintainer merge review. Current Priority: P1 Review scores
Verification
How this fits together
flowchart LR
A[Agent exec request] --> B[Node execution target]
B --> C[Gateway invocation request]
C --> D[Pending invocation deadline]
D --> E[Paired node command]
E --> F[Terminal node result]
F --> G[Agent terminal outcome]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +17, Tests +65. Total +82 across 5 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Merge the focused request-boundary repair after the normal maintainer review and required checks for the exact head complete. Do we have a high-confidence way to reproduce the issue? Yes. The supplied exact-head paired-node proof runs real 35-second Is this the best way to solve the issue? Yes. Adding the existing top-level AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 560eda25b085. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
Crabbox before/after proofRan the fix against a fresh remote checkout of this PR's head (
ScenarioOperator runs Before — no top-level
|
| Phase | Result |
|---|---|
PR head, bash-tools.exec-host-node + both cancellation suites |
3 files, 86 passed |
| Same checkout with the single payload line reverted | 9 failed, 70 passed |
CRABBOX_PHASE:gateway-deadline-proof 20.2s 2 passed
CRABBOX_PHASE:payload-shape-after 0.1s payload emits top-level timeoutMs: true
CRABBOX_PHASE:tests-after 12.2s 86 passed (3 files)
CRABBOX_PHASE:revert-payload-line 0.0s reverted the single payload line
CRABBOX_PHASE:tests-before 9.9s 9 failed | 70 passed
The revert phase deletes exactly one line (timeoutMs: params.target.invokeDeadlineMs,), so the 9 failures are attributable to the fix itself rather than to unrelated churn. The scratch proof file used for the registry scenario is not part of the diff.
80930c4 to
f8fa0ae
Compare
|
Both rank-up moves are done. Runtime behavior proof is now in the PR body under "Runtime behavior proof (before/after)", with the full write-up in this comment. It drives the real Rebased on current @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Maintainer review at This fixes LOC: +109/-27 (5 files) FindingsNo code findings. The implementation is focused, and the targeted tests cover direct, approved, prepared, zero-timeout, long-timeout, saturated-budget, and cancellation paths. Best-fix verdict: best fix. Supplying the existing top-level Provenance: PR #115248 added the Gateway absolute-deadline machinery; this PR repairs the remaining caller omission. Current Code read: Remaining uncertainty / merge proof: the current before/after proof exercises the real registry and result handler with a simulated node connection. Before merge, run a physically paired node command lasting over 30 seconds and show that the originating exec caller receives the terminal result. By: Omar Shahine (@omarshahine, acct 2014-12-29), an established OpenClaw contributor. |
|
@clawsweeper re-review |
Yigtwxx
left a comment
There was a problem hiding this comment.
Reviewed at f8fa0ae, focused on whether the three-budget model is actually enforced rather than just asserted.
The new coverage is load-bearing — I verified it by mutation rather than by reading. I broke the derivation (resolveNodeInvokeWaitMs returning invokeDeadlineMs - 5_000, i.e. a caller wait shorter than the Gateway deadline) and ran the suite twice:
| run | what changed | result |
|---|---|---|
| 1 | mutated production only | 9 failed / 70 passed — every failure at expectSystemRunInvoke L433, expected 30000 to be 40000 |
| 2 | mutation + all 7 call-site literals updated to match the mutant (simulating an author "fixing" the reds) | 9 failed / 70 passed — 7 failures now at L435, expected 35000 to be less than or equal to 30000 |
That second run is the interesting one. The ordering assertions at L434-436 read the helper's own parameters rather than the recorded call, so at first glance they look tautological and unable to catch a production regression. They aren't: L432-433 pin those parameters to the recorded payload, so the only way to silence them is to make the literals inconsistent with each other, which is exactly what L434-436 then catch. The two layers cover each other, and it("arms the gateway invocation deadline for a budget longer than the 30s registry fallback") fails in both directions. Worth stating explicitly since "these three lines don't touch call" is the natural first objection to this helper.
Also confirmed the small-timeout case can't invert: the Math.max(10_000, ...) floor is applied to the deadline at L101 before the wait derives from it at L108, which is what keeps timeout: 1 from producing a wait below its own deadline.
One finding, inline: the invariant this establishes holds for system.run but not for the other node.invoke hop in the same file. prepareNodeSystemRun sends a 15 s caller wait with no top-level timeoutMs, so the Gateway falls back to its fixed 30 s pending timer — the inverted ordering, and the same abandoned-invoke shape the PR is fixing. The branch pins that gap deliberately with a test, so this is a scope question rather than a defect; details and two low-cost options are in the inline comment.
For the record, hypotheses I checked that came back clean: the tests are not mock-shielded (bash-tools.exec-host-node-phases.js is unmocked in this suite, so call.params?.timeoutMs reads the real payload); timeout: 0 is not treated as 0 ms (resolveNodeRunTimeoutMs keeps the literal 0 for the node while the deadline independently falls back to the default budget); and the saturation case where all three collapse to MAX_SAFE_TIMEOUT_DELAY_MS is documented at L104-106 and unreachable in practice.
The gateway deadline machinery from #115248 reads a top-level timeoutMs on the node.invoke payload, but buildNodeSystemRunInvoke() only ever emitted the nested program budget. With p.timeoutMs undefined the registry falls back to a fixed 30s pending-invoke timer, drops the pending entry, and discards the node's later success as ignored, so the caller never sees a terminal outcome. Serialize the resolved invocation deadline as the top-level timeoutMs and keep three ordered budgets: node program runtime < gateway deadline < caller wait. A zero timeout still means "no program-runtime timer" and is never rewritten, while the gateway deadline and caller wait stay positive and finite so neither side can hang forever. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 8ea5a828-596c-4bf9-9382-0081bd0d50cd
f8fa0ae to
809a734
Compare
|
Restacked exact head @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…penclaw#116591) The gateway deadline machinery from openclaw#115248 reads a top-level timeoutMs on the node.invoke payload, but buildNodeSystemRunInvoke() only ever emitted the nested program budget. With p.timeoutMs undefined the registry falls back to a fixed 30s pending-invoke timer, drops the pending entry, and discards the node's later success as ignored, so the caller never sees a terminal outcome. Serialize the resolved invocation deadline as the top-level timeoutMs and keep three ordered budgets: node program runtime < gateway deadline < caller wait. A zero timeout still means "no program-runtime timer" and is never rewritten, while the gateway deadline and caller wait stay positive and finite so neither side can hang forever. Co-authored-by: Omar Shahine <[email protected]> Co-authored-by: Copilot App <[email protected]> Copilot-Session: 8ea5a828-596c-4bf9-9382-0081bd0d50cd
|
@omarshahine, following up on this PR's explicitly deferred strict-timeout compatibility decision, not reopening the merged deadline fix. Would the exec/runtime owners accept a separate change that rejects invalid explicit timeouts before node discovery, approval, or dispatch, while preserving omitted/default and explicit-zero semantics? The requested contract rejects null/nonfinite values at direct API boundaries, negative values, positive sub-millisecond values, and values above the supported timer range. The public JSON/schema boundary needs its own validation proof; nonfinite numbers are not JSON inputs. Public-source evidence:
We intend to retain strict rejection downstream pending owner direction. Should this become a focused compatibility proposal, or remain downstream policy? In particular, please confirm the intended validation boundary and upper-limit/grace rule before implementation. No new timeout setting, deadline machinery, retry policy, or change to |
What Problem This Solves
Follow-up to #115248. That PR landed the Gateway-side invocation deadline machinery (
awaitNodeInvokeWithinDeadline,NODE_INVOKE_DEADLINE_EXPIRED, typed dispatch provenance), but theexec host=nodepath never arms it.buildNodeSystemRunInvoke()emitsnodeId/command/params/idempotencyKeyand puts the command budget only in nestedparams.timeoutMs. There is no top-leveltimeoutMs, which is exactly whatsrc/gateway/server-methods/nodes.invoke.tsreads to deriveinvokeDeadlineAtMs:With it undefined,
src/gateway/node-registry.tsfalls back to a fixed timer:So every
exec host=nodeinvocation gets a 30s Gateway deadline no matter what the caller asked for. The pending invoke is deleted at 30s, and the node's later success is acknowledged and thrown away as{ ok: true, ignored: true }innodes.handlers.invoke-result.ts.The longer budget was only ever used as the caller's websocket wait (
callGatewayTool("node.invoke", { timeoutMs: target.invokeTimeoutMs }, invoke)), which does not control the server-side registry deadline.Repro
An approval-required
exec host=nodecommand that runs a bit over 30s:ignored, and the caller never receives a terminal outcome.Approval wall-clock makes this worse: the 30s registry timer starts at dispatch, so an approval that takes 20s leaves 10s of usable runtime.
Why This Change Was Made
Serialize the resolved invocation deadline as a top-level
timeoutMson thenode.invokepayload, so the existing machinery is armed instead of dormant. This is the same top-level shapesrc/cli/nodes-cli/register.location.tsalready uses.Three ordered budgets, all derived in
resolveNodeExecutionTargetfrom values that already exist — no new config knob, no new constants:params.timeoutMs(unchanged)invokeDeadlineAtMsruntime + 5stransport grace (the existing helper, just renamed)deadline + 5s(same grace convention)runtime < deadline < caller waitholds for every finite positive budget, so the Gateway's deadline-expiry answer wins the race rather than the caller giving up first. Both upper budgets saturate together atMAX_SAFE_TIMEOUT_DELAY_MS, where the ordering degenerates by design.timeout: 0semantics are preserved exactly: the nested value stays0(no program-runtime timer on the node) and is never rewritten to a default or a finite process timeout, while the deadline and caller wait fall back to the default budget so neither the Gateway nor the caller can hang forever.The
NodeExecutionTarget.invokeTimeoutMsfield is split intoinvokeDeadlineMsandinvokeWaitMsso the two are not confusable at the call sites.User Impact
exec host=nodecommands with a budget longer than 30s now complete instead of silently producing no terminal outcome. Shorter commands are unaffected apart from a 5s longer caller-side wait. No config surface, no new flags, no behavior change forsystem.run.prepare(still a 15s round-trip with no deadline) or for any non-exec node path.Evidence
src/agents/bash-tools.exec-host-node.test.tspreviously asserted only the caller option and the nestedparams.timeoutMs, which is precisely why this gap went uncovered.expectSystemRunInvokenow asserts the top-level payload value too and checks the budget ordering. New/extended coverage:30_000 / 35_000 / 40_000timeoutSec: 12:12_000 / 17_000 / 22_000timeoutSec: 120regression test — proves the budget is not clipped to the 30s registry fallbacktimeout: 0— nested stays0; deadline and caller wait stay positive and finiteMAX_SAFE_TIMEOUT_DELAY_MSwithout producing a zero/undefined deadlinesystem.run.preparetest pins that the short prepare round-trip gains no deadlineReverting only the payload line fails 9 tests in this suite, so the coverage is real rather than tautological.
tsgo --noEmitreports no errors in the touched files; remaining output is pre-existing and unrelated (openai-transport-stream.test-support.ts,ui/src/e2e/*).oxfmtclean.Runtime behavior proof (before/after)
Test assertions alone only prove the payload shape, so this drives the real
NodeRegistrywith a fake node connection over a 120s budget, where the node finishes at 35s — past the registry's 30s fallback, well inside the requested budget. Run in a Crabbox lease against a fresh remote checkout of this PR's head (providerlocal-container,node:24-bookworm; leasecbx_90564ed15345, runrun_30359597aed5, exit 0).Before — no top-level
timeoutMs:{ "armedTimeoutMs": 30000, "resultAccepted": false, "gatewayAckToNode": { "ok": true, "ignored": true }, "callerResult": { "ok": false, "error": { "code": "TIMEOUT", "message": "node invoke timed out" } } }The registry arms 30s instead of the requested 125s, deletes the pending invoke, and
handleInvokeResult()returnsfalsefor the node's success at 35s — whichnodes.handlers.invoke-result.tsacknowledges as{ ok: true, ignored: true }. The command really did succeed on the node; the caller is told it timed out.After — deadline serialized on the payload:
{ "armedTimeoutMs": 125000, "resultAccepted": true, "gatewayAckToNode": { "ok": true }, "callerResult": { "ok": true, "payload": { "exitCode": 0, "aggregated": "done" } } }The pending invoke is still registered at 35s and the node's result reaches the caller.
Same-checkout suite contrast, where the revert phase deletes exactly one line (
timeoutMs: params.target.invokeDeadlineMs,):Physical paired-node proof (macOS)
Verified end to end on exact PR head
809a73433fbd7acf4da437e69f1c6aeb9f04a9a0using a fresh build of that revision. The Gateway and node host ran as separate processes with separate state directories and separate signed device identities. No shared Gateway token or password was supplied.The isolated Gateway used loopback
gateway.auth.mode=none. In that supported no-shared-secret configuration, first-time physical device identity pairing was silently auto-approved by the Gateway (approvedVia: silent); it was not manually approved. SSH verification was disabled. The distinct node command-surface pairing request was then manually approved. Final status reported:{ "displayName": "ProofNode-116591-809a7343", "version": "2026.7.2", "approvalState": "approved", "paired": true, "connected": true, "commands": ["system.run"] }The real
executeNodeHostCommandcaller then dispatched unique 35-secondsystem.runcommands through that paired node:timeoutSec: 45timeoutSec: 00(unbounded node process timer)Gateway transport timing independently confirms that both results crossed the old 30-second boundary and reached the originating caller:
There was no timeout or ignored result in either PR-head run. This also directly verifies that
timeout: 0preserves nestedparams.timeoutMs: 0while still arming finite Gateway and caller budgets.For contrast, current
mainata1c689e375ec9daf1b6522e8a0aee1ff9805c1feran the same separate-node 35-second path and returnedTIMEOUT: node invoke timed outafter 30,004ms; the unique completion marker never reached the caller. That control was canceled at timeout, so it did not emit a later ignored-result log line.Rebased on current
mainBranch refreshed onto
fd343ca8cc95and the focused suites re-run on exact head809a73433fbd: 3 files, 87 passed. Core production and test type checks, targeted Oxlint/Oxfmt, Knip unused-export scans,git diff --check,pnpm build, and fresh structured autoreview all passed. The delegated changed-check failed before execution during Daytona sync prune, so the same repository-planned gates ran through the documented trusted-source local fallback.Out of scope
No typed unknown-execution outcome or
failureKindenum; no stricter timeout validation (rejecting null/negative/sub-millisecond/oversized values is a separate compatibility-affecting change); nogateway.nodes.invokeTimeoutMsstyle config knob; no changes tosrc/agents/tools/nodes-tool.ts.system.run.prepareis intentionally excluded because it is a short, non-execution preflight and retains its existing 15s caller wait / registry-default behavior; aligning prepare deadlines is separate follow-up scope.