Skip to content

fix: prevent node gateway hangs and runaway local inference - #115248

Merged
steipete merged 2 commits into
mainfrom
codex/node-gateway-restart-chaos
Jul 28, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/node-gateway-restart-chaos

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users running paired nodes, MCP and shell commands, the browser copilot, or local model providers could experience hanging gateway requests, orphaned node work, invalid reconnects, unsafe retries, malformed camera output, or runaway model discovery.

Why This Change Was Made

Carry one absolute invocation deadline across pairing, APNs wake, reconnect, plugin policy, and node transport; propagate cancellation only to first-party node hosts that support it; preserve command-dispatch ownership for safe retries. Extract reusable deadline and iOS foreground helpers so the gateway handler stays within the repository module limit. Bound self-hosted model probing without losing advertised models and validate external gateway and provider records at their boundaries.

User Impact

Node commands now time out and cancel predictably, including stalled pairing stores, late wake results, revoked pairings, browser reconnect failures, and timeouts longer than the Node timer limit. CLI camera and notification commands reject malformed records and invalid choices safely. Ollama and compatible self-hosted llama.cpp, vLLM, and SGLang catalog discovery remain bounded and keep all valid models.

Evidence

  • Based on main fe9893d.
  • Remote Blacksmith Testbox tbx_01kymefsjbjvq270r83ersyr4y.
  • 531 passing regression tests over 17 gateway, node-host, MCP, shell, CLI, browser, Ollama, streaming, preflight, self-hosted model, and end-to-end test files.
  • Adversarial regressions for stalled pairing capture and rechecks, revoked pairing, APNs hangs, absolute-deadline races, Node timer overflow, dispatched plugin retry ownership, 201 advertised self-hosted models, and browser-valid WebSocket closes.
  • Direct oxlint passes for all 18 changed core and browser files; gateway handler reduced to 697 lines.
  • Fresh independent autoreview clean for both the complete behavior change and extracted helper refactor.
  • Paired Ollama QA also exercised using the mock provider; this is deterministic protocol proof, not a claim of real local GPU inference.
  • The destructive gateway-restart-inflight-run scenario exposed a separate session SQLite lock-handoff defect. That compatibility-sensitive persistent-state problem is intentionally excluded and needs owner-reviewed follow-up.
  • Full Linux check:changed is being rerun on this exact head.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes size: XL labels Jul 28, 2026
@steipete
steipete marked this pull request as ready for review July 28, 2026 14:51
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Jul 28, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 28, 2026
@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 28, 2026, 11:23 AM ET / 15:23 UTC.

ClawSweeper review

What this changes

This PR carries one deadline through paired-node wake, policy, and transport work; forwards cancellation to first-party node hosts; bounds self-hosted model discovery; and validates related browser and CLI inputs.

Merge readiness

⛔ Blocked until stronger real behavior proof is added - 4 items remain

Keep this PR open for explicit maintainer review. It carries a protected maintainer label and changes the node gateway’s timeout and cancellation behavior across paired-node clients, so it should not be auto-closed or routed through automatic cleanup; the main remaining question is backward-compatible delivery of newly broadened cancellation frames.

Priority: P1
Reviewed head: 5c0a11dac024afaba704c46bd1ccd02bf27f1191
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch has substantial focused regression coverage, but real after-fix behavior proof is not inspectable from the supplied PR evidence and transport compatibility remains a merge decision.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: The body and successful workflow report regression testing, but no inspectable after-fix paired-node run, runtime log, terminal output, recording, or linked artifact is present in the supplied context; attach redacted evidence that directly demonstrates the changed behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The body and successful workflow report regression testing, but no inspectable after-fix paired-node run, runtime log, terminal output, recording, or linked artifact is present in the supplied context; attach redacted evidence that directly demonstrates the changed behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 4 items Protected maintainer handling: The supplied PR context shows the maintainer label, which OpenClaw policy treats as requiring explicit maintainer handling rather than automated closure or cleanup.
Cancellation contract changed: The branch removes the streaming-only cancellation guard and permits ordinary invokes to emit node.invoke.cancel when the connected client identifies as the first-party node host. This broadens observable gateway-to-node wire behavior and warrants released-host compatibility confirmation.
Deadline propagation coverage: The branch introduces an absolute-deadline helper and adds wake-path regression coverage for stalled pairing, wake, reconnect, timeout, and cancellation cases, indicating a concrete source-level fix path rather than a cosmetic timeout change.
Findings None None.
Security None None.

How this fits together

The gateway’s node-invocation path accepts commands from CLI, MCP, plugins, and browser clients, then resolves pairing, optionally wakes an offline node, applies policy, and sends work to the paired host. Provider setup separately reads self-hosted model catalogs and turns them into selectable local models.

flowchart LR
  Client[CLI, MCP, plugin, or browser client] --> Gateway[Gateway node invocation]
  Gateway --> Pairing[Pairing and wake]
  Pairing --> Policy[Command policy]
  Policy --> Transport[Paired node transport]
  Transport --> Outcome[Result, timeout, or cancellation]
  Setup[Self-hosted provider setup] --> Discovery[Bounded model discovery]
  Discovery --> Catalog[Available local models]
Loading

Decision needed

Question Recommendation
Should ordinary non-streaming invokes send cancellation frames to every first-party node-host client, or must this be capability/version-gated for older released paired hosts? Confirm host compatibility: Proceed if the oldest supported first-party node host handles or safely ignores ordinary-invoke cancellation frames, with that compatibility documented or tested.

Why: The patch deliberately broadens an established gateway-to-node transport behavior; source tests exercise the new first-party path, but the supplied context does not establish the minimum released node-host protocol contract.

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The body and successful workflow report regression testing, but no inspectable after-fix paired-node run, runtime log, terminal output, recording, or linked artifact is present in the supplied context; attach redacted evidence that directly demonstrates the changed behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - Non-streaming node invocations will now send node.invoke.cancel to any connected client identified as a first-party node host; verify the minimum supported released host safely handles that frame and that reconnect or retry behavior remains unchanged for older paired installations.
  • Resolve merge risk (P1) - The PR spans wake, pairing, plugin dispatch, browser reconnects, CLI validation, and provider discovery. The supplied test summary is substantial, but an inspectable after-fix runtime proof is still needed for the claimed real node-gateway and local-provider outcomes.
Agent review details

Security

None.

PR surface

Source +244, Tests +755. Total +999 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 11 375 131 +244
Tests 7 756 1 +755
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 18 1131 132 +999

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/node-registry.test.ts, serialized state: src/plugins/provider-self-hosted-setup.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Prove released-host cancellation compatibility (recommended)
    Add focused compatibility proof that the oldest supported first-party node host accepts or safely ignores node.invoke.cancel for ordinary invokes before merging.
  2. Adopt the new transport requirement
    Merge with an explicit maintainer decision that paired first-party node hosts must support the broadened cancellation frame and update the supported-version guidance.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Add a compatibility regression covering ordinary-invoke cancellation against the minimum supported node-host protocol behavior, then attach redacted after-fix runtime evidence.

Technical review

Best possible solution:

Retain one absolute invocation deadline, but land only after confirming the widened cancellation frame is compatible with the oldest supported first-party node host and attaching redacted after-fix runtime evidence for a paired-node timeout or cancellation path.

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

No high-confidence live reproduction is included in inspectable form. The affected deadline and cancellation paths are source-reproducible from the branch tests, but the supplied context does not show a directly inspectable paired-node runtime reproduction.

Is this the best way to solve the issue?

Unclear. A shared absolute deadline is a maintainable fix shape, but broadening cancellation delivery requires confirmation against the supported first-party node-host protocol before it is the safest solution.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: This targets gateway hangs and cancellation in paired-node command workflows that can affect active user operations.
  • add merge-risk: 🚨 compatibility: The branch changes the cancellation frame behavior for ordinary invokes on existing paired first-party node hosts.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The body and successful workflow report regression testing, but no inspectable after-fix paired-node run, runtime log, terminal output, recording, or linked artifact is present in the supplied context; attach redacted evidence that directly demonstrates the changed behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P1: This targets gateway hangs and cancellation in paired-node command workflows that can affect active user operations.
  • merge-risk: 🚨 compatibility: The branch changes the cancellation frame behavior for ordinary invokes on existing paired first-party node hosts.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The body and successful workflow report regression testing, but no inspectable after-fix paired-node run, runtime log, terminal output, recording, or linked artifact is present in the supplied context; attach redacted evidence that directly demonstrates the changed behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Protected maintainer handling: The supplied PR context shows the maintainer label, which OpenClaw policy treats as requiring explicit maintainer handling rather than automated closure or cleanup. (5c0a11dac024)
  • Cancellation contract changed: The branch removes the streaming-only cancellation guard and permits ordinary invokes to emit node.invoke.cancel when the connected client identifies as the first-party node host. This broadens observable gateway-to-node wire behavior and warrants released-host compatibility confirmation. (src/gateway/node-registry.ts:258, 5c0a11dac024)
  • Deadline propagation coverage: The branch introduces an absolute-deadline helper and adds wake-path regression coverage for stalled pairing, wake, reconnect, timeout, and cancellation cases, indicating a concrete source-level fix path rather than a cosmetic timeout change. (src/gateway/server-methods/nodes.invoke-deadline.ts:1, 5c0a11dac024)
  • Submitted validation is supplemental: The PR body reports a Blacksmith Testbox run and 531 passing regressions, while the supplied checks show repository checks and the proof workflow succeeding. The context does not include an inspectable after-fix live transcript, runtime log, recording, or artifact for the affected node/provider behavior. (5c0a11dac024)

Likely related people:

  • steipete: The supplied commit history attributes both branch commits to this person across the gateway deadline, node transport, and self-hosted provider surfaces; the available review context does not expose enough current-main history to identify an additional owner confidently. (role: recent area contributor; confidence: medium; commits: 92e71e27c3de, 5c0a11dac024; files: src/gateway/node-registry.ts, src/gateway/server-methods/nodes.invoke.ts, src/plugins/provider-self-hosted-setup.ts)

Rank-up moves

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

  • Attach redacted terminal output, logs, or a recording showing a paired-node timeout or cancellation completing predictably after this change.
  • Confirm the minimum supported first-party node host safely handles ordinary-invoke node.invoke.cancel frames.

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.

@steipete
steipete merged commit 2b8e639 into main Jul 28, 2026
188 of 197 checks passed
@steipete
steipete deleted the codex/node-gateway-restart-chaos branch July 28, 2026 16:47
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Jul 28, 2026
…etwork-none

* origin/main:
  feat(skills): shared authoring standards make learned skills routable (#115103)
  fix(matrix): suppress previews for modifying hooks
  fix: prevent node gateway hangs and runaway local inference (#115248)
  refactor(ui): adopt @lit/task across remaining page surfaces (#115274)
  fix(slack): cap chat.update edit text at the 4000-char limit, not the 8000 send limit (#115027)
  [AI-assisted] docs: recommend Node 26 in quickstart, landing, and platform install docs (#115064)
  refactor(workboard): tidy Control UI card execution helpers (#115195)
  perf(agents): amortize history-limit eviction with hysteresis (#115273) (#115281)
vincentkoc added a commit that referenced this pull request Jul 28, 2026
…-20260728

* origin/main:
  fix(tui): order delayed prompts before completed replies (#115219)
  feat(macos): enable Computer Control by default and diagnose stale Accessibility grants (#115280)
  fix(qa): restore full-stack scenarios and truthful suite exits (#115290)
  feat(memory): backfill past sessions from Control UI (#115266)
  docs: link macOS onboarding pages to app download (#111361)
  feat(skills): shared authoring standards make learned skills routable (#115103)
  fix(matrix): suppress previews for modifying hooks
  fix: prevent node gateway hangs and runaway local inference (#115248)
  refactor(ui): adopt @lit/task across remaining page surfaces (#115274)
vincentkoc added a commit to christian-lallo/openclaw that referenced this pull request Jul 28, 2026
* origin/main: (62 commits)
  feat(macos): enable Computer Control by default and diagnose stale Accessibility grants (openclaw#115280)
  fix(qa): restore full-stack scenarios and truthful suite exits (openclaw#115290)
  feat(memory): backfill past sessions from Control UI (openclaw#115266)
  docs: link macOS onboarding pages to app download (openclaw#111361)
  feat(skills): shared authoring standards make learned skills routable (openclaw#115103)
  fix(matrix): suppress previews for modifying hooks
  fix: prevent node gateway hangs and runaway local inference (openclaw#115248)
  refactor(ui): adopt @lit/task across remaining page surfaces (openclaw#115274)
  fix(slack): cap chat.update edit text at the 4000-char limit, not the 8000 send limit (openclaw#115027)
  [AI-assisted] docs: recommend Node 26 in quickstart, landing, and platform install docs (openclaw#115064)
  refactor(workboard): tidy Control UI card execution helpers (openclaw#115195)
  perf(agents): amortize history-limit eviction with hysteresis (openclaw#115273) (openclaw#115281)
  fix: schema-version refusal blames a downgrade that never happened and cannot identify the stale install (openclaw#115232)
  fix: restore Fish completion after global CLI options (openclaw#115222)
  refactor(agents): collapse the client-tool catalog branch (openclaw#115212)
  fix(macos): signed rebuild no longer stalls on app shutdown (openclaw#103957)
  fix(agents): prevent repeated Code Mode output across waits (openclaw#115213)
  refactor(ui): split Profile (identity) from Usage (statistics) (openclaw#115245)
  fix(channels): report a channel that cannot receive as unhealthy instead of connected (openclaw#115229)
  fix(cli): reject malformed infer model refs (openclaw#115225)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 29, 2026
…#115248)

* fix(node): bound gateway wake, cancellation, and local inference

* refactor(gateway): extract bounded node invocation policies
omarshahine added a commit that referenced this pull request Jul 31, 2026
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
omarshahine added a commit that referenced this pull request Aug 1, 2026
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
omarshahine added a commit that referenced this pull request Aug 1, 2026
…116591)

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: Omar Shahine <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 8ea5a828-596c-4bf9-9382-0081bd0d50cd
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant