From 3f579fe8267c1696b5280b8cf0016d97e4de9a31 Mon Sep 17 00:00:00 2001 From: Aaron Erickson Date: Fri, 22 May 2026 19:39:00 -0700 Subject: [PATCH 01/13] test: trigger release blocker validation From 3f5db4fe66a851e251d73b2568846de37cba0206 Mon Sep 17 00:00:00 2001 From: Aaron Erickson Date: Fri, 22 May 2026 19:41:38 -0700 Subject: [PATCH 02/13] test: add release blocker validation e2es --- .github/workflows/nightly-e2e.yaml | 85 +++++++++++++++++++ .../e2e/test-openclaw-tui-chat-correlation.sh | 57 +++++++++++++ 2 files changed, 142 insertions(+) create mode 100755 test/e2e/test-openclaw-tui-chat-correlation.sh diff --git a/.github/workflows/nightly-e2e.yaml b/.github/workflows/nightly-e2e.yaml index 153ca321b0b..bbda336b0e7 100644 --- a/.github/workflows/nightly-e2e.yaml +++ b/.github/workflows/nightly-e2e.yaml @@ -82,6 +82,7 @@ on: Valid: cloud-e2e, cloud-onboard-e2e, cloud-inference-e2e, skill-agent-e2e, docs-validation-e2e, messaging-providers-e2e, openclaw-slack-pairing-e2e, + openclaw-tui-chat-correlation-e2e, openclaw-discord-pairing-e2e, messaging-compatible-endpoint-e2e, kimi-inference-compat-e2e, @@ -395,6 +396,90 @@ jobs: path: /tmp/nemoclaw-e2e-openclaw-slack-pairing-install.log if-no-files-found: ignore + # ── OpenClaw TUI Chat Correlation E2E (#2603/#3145) ─────────── + # Creates a fresh OpenClaw sandbox, then runs the live gateway/webchat + # correlation harness against rapid sequential sends. + openclaw-tui-chat-correlation-e2e: + if: >- + github.repository == 'NVIDIA/NemoClaw' && + (github.event_name != 'workflow_dispatch' || + inputs.jobs == '' || + contains(format(',{0},', inputs.jobs), ',openclaw-tui-chat-correlation-e2e,')) + runs-on: ubuntu-latest + timeout-minutes: 75 + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + ref: ${{ inputs.target_ref || github.ref }} + + - name: Setup Node.js + uses: actions/setup-node@e6c0a5f2b715a71878efbdd1228a4bb278e7ab3e # v6.0.1 + with: + node-version: "22" + + - name: Install test dependencies + run: npm ci + + - name: Run OpenClaw TUI chat correlation E2E test + env: + NVIDIA_API_KEY: ${{ secrets.NVIDIA_API_KEY }} + NEMOCLAW_NON_INTERACTIVE: "1" + NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE: "1" + NEMOCLAW_RECREATE_SANDBOX: "1" + NEMOCLAW_SANDBOX_NAME: "e2e-openclaw-tui-correlation" + GITHUB_TOKEN: ${{ github.token }} + run: bash test/e2e/test-openclaw-tui-chat-correlation.sh + + - name: Upload install log on failure + if: failure() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: install-log-openclaw-tui-chat-correlation + path: /tmp/nemoclaw-e2e-openclaw-tui-correlation-install.log + if-no-files-found: ignore + + # ── DGX Station GPU optional proof validation (#3600) ────────── + # CI cannot emulate GB300, but this guards the release-blocker mitigation: + # optional direct GPU proofs must not abort onboard before the fatal throw. + issue-3600-gpu-proof-optional-e2e: + if: >- + github.repository == 'NVIDIA/NemoClaw' && + (github.event_name != 'workflow_dispatch' || + inputs.jobs == '' || + contains(format(',{0},', inputs.jobs), ',issue-3600-gpu-proof-optional-e2e,')) + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - name: Checkout + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + ref: ${{ inputs.target_ref || github.ref }} + + - name: Setup Node.js + uses: actions/setup-node@e6c0a5f2b715a71878efbdd1228a4bb278e7ab3e # v6.0.1 + with: + node-version: "22" + + - name: Verify optional GPU proof cannot abort onboard + run: | + node - <<'NODE' + const fs = require('node:fs'); + const source = fs.readFileSync('src/lib/onboard.ts', 'utf8'); + const start = source.indexOf('function verifyDirectSandboxGpu'); + const end = source.indexOf('\n}\n\nfunction upsertMessagingProviders', start) + 2; + if (start < 0 || end < 2) { + throw new Error('verifyDirectSandboxGpu function not found'); + } + const fn = source.slice(start, end); + const optional = fn.indexOf('if (proof.optional === true) return;'); + const throwing = fn.indexOf('throw new Error(`GPU proof failed:'); + if (!(optional >= 0 && throwing >= 0 && optional < throwing)) { + throw new Error('optional GPU proof handling does not precede fatal throw'); + } + console.log('optional-before-throw=true'); + NODE + # ── OpenClaw Discord Pairing E2E (#4061) ────────────────────── # Hermetic Discord Gateway placeholder rewrite proof, then connect-shell # `openclaw pairing approve discord ` against shared state. diff --git a/test/e2e/test-openclaw-tui-chat-correlation.sh b/test/e2e/test-openclaw-tui-chat-correlation.sh new file mode 100755 index 00000000000..c97b937a4cc --- /dev/null +++ b/test/e2e/test-openclaw-tui-chat-correlation.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Validation-only E2E for release-blocker close calls: +# #2603 - previous TUI/chat message disappears after reconnect/scroll +# #3145 - rapid sequential TUI messages duplicate or arrive out of order +# +# The Vitest live harness drives OpenClaw's gateway websocket directly against a +# real sandbox. This wrapper creates a fresh cloud-backed OpenClaw sandbox first +# so CI evidence is not dependent on a developer machine's stale sandbox state. + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +REPO="$(cd "${SCRIPT_DIR}/../.." && pwd)" + +SANDBOX_NAME="${NEMOCLAW_SANDBOX_NAME:-e2e-openclaw-tui-correlation}" +INSTALL_LOG="${E2E_OPENCLAW_TUI_CORRELATION_INSTALL_LOG:-/tmp/nemoclaw-e2e-openclaw-tui-correlation-install.log}" + +cleanup() { + if [ "${NEMOCLAW_E2E_SKIP_CLEANUP:-0}" = "1" ]; then + return + fi + SANDBOX_NAME="$SANDBOX_NAME" bash "${SCRIPT_DIR}/e2e-cloud-experimental/cleanup.sh" --verify >/dev/null 2>&1 || true +} +trap cleanup EXIT + +export NEMOCLAW_SANDBOX_NAME="$SANDBOX_NAME" +export E2E_CLOUD_ONBOARD_INSTALL_LOG="$INSTALL_LOG" +export NEMOCLAW_E2E_KEEP_SANDBOX=1 +export NEMOCLAW_NON_INTERACTIVE="${NEMOCLAW_NON_INTERACTIVE:-1}" +export NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE="${NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE:-1}" +export NEMOCLAW_RECREATE_SANDBOX="${NEMOCLAW_RECREATE_SANDBOX:-1}" + +bash "${SCRIPT_DIR}/test-cloud-onboard-e2e.sh" + +# Pick up PATH changes from the public installer in this shell. +# shellcheck source=test/e2e/lib/install-path-refresh.sh +. "${SCRIPT_DIR}/lib/install-path-refresh.sh" +nemoclaw_refresh_install_env +nemoclaw_ensure_local_bin_on_path +export PATH="/usr/local/bin:${HOME}/.local/bin:${PATH}" + +openclaw_version="$( + openshell sandbox exec --name "$SANDBOX_NAME" -- openclaw --version 2>&1 || true +)" +echo "Sandbox OpenClaw version: ${openclaw_version}" +if ! grep -q "2026.5.18" <<<"$openclaw_version"; then + echo "Expected fresh sandbox to run OpenClaw 2026.5.18" >&2 + exit 1 +fi + +cd "$REPO" +NEMOCLAW_ISSUE_2603_LIVE=1 \ + NEMOCLAW_ISSUE_2603_SANDBOX="$SANDBOX_NAME" \ + npx vitest run test/openclaw-tui-chat-correlation.test.ts --reporter=verbose From d724cfead66fc78f9962fbbe3bae9b163babbfb3 Mon Sep 17 00:00:00 2001 From: Aaron Erickson Date: Fri, 22 May 2026 19:42:45 -0700 Subject: [PATCH 03/13] test: fix validation workflow setup-node action --- .github/workflows/nightly-e2e.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightly-e2e.yaml b/.github/workflows/nightly-e2e.yaml index bbda336b0e7..0b24cae34a2 100644 --- a/.github/workflows/nightly-e2e.yaml +++ b/.github/workflows/nightly-e2e.yaml @@ -414,7 +414,7 @@ jobs: ref: ${{ inputs.target_ref || github.ref }} - name: Setup Node.js - uses: actions/setup-node@e6c0a5f2b715a71878efbdd1228a4bb278e7ab3e # v6.0.1 + uses: actions/setup-node@v6 with: node-version: "22" @@ -457,7 +457,7 @@ jobs: ref: ${{ inputs.target_ref || github.ref }} - name: Setup Node.js - uses: actions/setup-node@e6c0a5f2b715a71878efbdd1228a4bb278e7ab3e # v6.0.1 + uses: actions/setup-node@v6 with: node-version: "22" From 8a1e0a4ac133eea5dab8ae88b9937ba1a1ba4346 Mon Sep 17 00:00:00 2001 From: Aaron Erickson Date: Fri, 22 May 2026 19:57:28 -0700 Subject: [PATCH 04/13] test: harden tui chat validation harness Signed-off-by: Aaron Erickson --- .github/workflows/nightly-e2e.yaml | 2 +- test/e2e/test-openclaw-tui-chat-correlation.sh | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightly-e2e.yaml b/.github/workflows/nightly-e2e.yaml index 0b24cae34a2..aba4e6e754d 100644 --- a/.github/workflows/nightly-e2e.yaml +++ b/.github/workflows/nightly-e2e.yaml @@ -419,7 +419,7 @@ jobs: node-version: "22" - name: Install test dependencies - run: npm ci + run: npm ci --include=dev - name: Run OpenClaw TUI chat correlation E2E test env: diff --git a/test/e2e/test-openclaw-tui-chat-correlation.sh b/test/e2e/test-openclaw-tui-chat-correlation.sh index c97b937a4cc..6491b2c5e85 100755 --- a/test/e2e/test-openclaw-tui-chat-correlation.sh +++ b/test/e2e/test-openclaw-tui-chat-correlation.sh @@ -52,6 +52,12 @@ if ! grep -q "2026.5.18" <<<"$openclaw_version"; then fi cd "$REPO" + +if [ ! -x ./node_modules/.bin/vitest ]; then + echo "Restoring repository dev dependencies for the live Vitest harness" + npm ci --include=dev +fi + NEMOCLAW_ISSUE_2603_LIVE=1 \ NEMOCLAW_ISSUE_2603_SANDBOX="$SANDBOX_NAME" \ - npx vitest run test/openclaw-tui-chat-correlation.test.ts --reporter=verbose + ./node_modules/.bin/vitest run test/openclaw-tui-chat-correlation.test.ts --reporter=verbose From 42ac24a7a32e350b9be486d140fbe2af397eaab4 Mon Sep 17 00:00:00 2001 From: Aaron Erickson Date: Fri, 22 May 2026 20:05:23 -0700 Subject: [PATCH 05/13] test: harden token rotation output assertions Signed-off-by: Aaron Erickson --- test/e2e/test-token-rotation.sh | 58 ++++++++++++++++----------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/test/e2e/test-token-rotation.sh b/test/e2e/test-token-rotation.sh index 7f2c86260ae..5a4c06e1e5f 100755 --- a/test/e2e/test-token-rotation.sh +++ b/test/e2e/test-token-rotation.sh @@ -324,7 +324,7 @@ process.exit('SLACK_APP_TOKEN' in h ? 0 : 1); echo "$ONBOARD_OUTPUT" | tail -30 fi - if echo "$ONBOARD_OUTPUT" | grep -q "credential(s) rotated"; then + if grep -q "credential(s) rotated" <<<"$ONBOARD_OUTPUT"; then pass "Credential rotation detected" else fail "Credential rotation not detected in onboard output" @@ -335,31 +335,31 @@ process.exit('SLACK_APP_TOKEN' in h ? 0 : 1); # Rotation message must name only the telegram-bridge provider — Discord # token is unchanged, so a stray discord-bridge entry would indicate a # false-positive in detectMessagingCredentialRotation. - if echo "$ONBOARD_OUTPUT" | grep -q "credential(s) rotated:.*telegram-bridge"; then + if grep -q "credential(s) rotated:.*telegram-bridge" <<<"$ONBOARD_OUTPUT"; then pass "Rotation message identifies telegram-bridge" else fail "Rotation message did not identify telegram-bridge" info "Onboard output:" - echo "$ONBOARD_OUTPUT" | grep "credential(s) rotated" || true + grep "credential(s) rotated" <<<"$ONBOARD_OUTPUT" || true fi - if echo "$ONBOARD_OUTPUT" | grep -q "credential(s) rotated:.*discord-bridge"; then + if grep -q "credential(s) rotated:.*discord-bridge" <<<"$ONBOARD_OUTPUT"; then fail "Rotation message unexpectedly named discord-bridge (Discord token did not change)" info "Onboard output:" - echo "$ONBOARD_OUTPUT" | grep "credential(s) rotated" || true + grep "credential(s) rotated" <<<"$ONBOARD_OUTPUT" || true else pass "Rotation message did not name discord-bridge (Discord unchanged)" fi - if echo "$ONBOARD_OUTPUT" | grep -qE "credential\(s\) rotated:.*slack-(bridge|app)"; then + if grep -qE "credential\(s\) rotated:.*slack-(bridge|app)" <<<"$ONBOARD_OUTPUT"; then fail "Rotation message unexpectedly named slack-bridge/slack-app (Slack tokens did not change)" info "Onboard output:" - echo "$ONBOARD_OUTPUT" | grep "credential(s) rotated" || true + grep "credential(s) rotated" <<<"$ONBOARD_OUTPUT" || true else pass "Rotation message did not name slack-bridge or slack-app (Slack unchanged)" fi - if echo "$ONBOARD_OUTPUT" | grep -q "Rebuilding sandbox"; then + if grep -q "Rebuilding sandbox" <<<"$ONBOARD_OUTPUT"; then pass "Sandbox rebuild triggered by rotation" else fail "Sandbox rebuild not triggered" @@ -385,7 +385,7 @@ process.exit('SLACK_APP_TOKEN' in h ? 0 : 1); echo "$ONBOARD_OUTPUT" | tail -30 fi - if echo "$ONBOARD_OUTPUT" | grep -q "reusing it"; then + if grep -q "reusing it" <<<"$ONBOARD_OUTPUT"; then pass "Sandbox reused when tokens unchanged" else fail "Sandbox was not reused (unexpected rebuild)" @@ -410,7 +410,7 @@ process.exit('SLACK_APP_TOKEN' in h ? 0 : 1); echo "$ONBOARD_OUTPUT" | tail -30 fi - if echo "$ONBOARD_OUTPUT" | grep -q "credential(s) rotated"; then + if grep -q "credential(s) rotated" <<<"$ONBOARD_OUTPUT"; then pass "Credential rotation detected" else fail "Credential rotation not detected in onboard output" @@ -419,31 +419,31 @@ process.exit('SLACK_APP_TOKEN' in h ? 0 : 1); fi # Symmetric assertion to Phase 2: only the discord-bridge entry should appear. - if echo "$ONBOARD_OUTPUT" | grep -q "credential(s) rotated:.*discord-bridge"; then + if grep -q "credential(s) rotated:.*discord-bridge" <<<"$ONBOARD_OUTPUT"; then pass "Rotation message identifies discord-bridge" else fail "Rotation message did not identify discord-bridge" info "Onboard output:" - echo "$ONBOARD_OUTPUT" | grep "credential(s) rotated" || true + grep "credential(s) rotated" <<<"$ONBOARD_OUTPUT" || true fi - if echo "$ONBOARD_OUTPUT" | grep -q "credential(s) rotated:.*telegram-bridge"; then + if grep -q "credential(s) rotated:.*telegram-bridge" <<<"$ONBOARD_OUTPUT"; then fail "Rotation message unexpectedly named telegram-bridge (Telegram token did not change)" info "Onboard output:" - echo "$ONBOARD_OUTPUT" | grep "credential(s) rotated" || true + grep "credential(s) rotated" <<<"$ONBOARD_OUTPUT" || true else pass "Rotation message did not name telegram-bridge (Telegram unchanged)" fi - if echo "$ONBOARD_OUTPUT" | grep -qE "credential\(s\) rotated:.*slack-(bridge|app)"; then + if grep -qE "credential\(s\) rotated:.*slack-(bridge|app)" <<<"$ONBOARD_OUTPUT"; then fail "Rotation message unexpectedly named slack-bridge/slack-app (Slack tokens did not change)" info "Onboard output:" - echo "$ONBOARD_OUTPUT" | grep "credential(s) rotated" || true + grep "credential(s) rotated" <<<"$ONBOARD_OUTPUT" || true else pass "Rotation message did not name slack-bridge or slack-app (Slack unchanged)" fi - if echo "$ONBOARD_OUTPUT" | grep -q "Rebuilding sandbox"; then + if grep -q "Rebuilding sandbox" <<<"$ONBOARD_OUTPUT"; then pass "Sandbox rebuild triggered by rotation" else fail "Sandbox rebuild not triggered" @@ -469,7 +469,7 @@ process.exit('SLACK_APP_TOKEN' in h ? 0 : 1); echo "$ONBOARD_OUTPUT" | tail -30 fi - if echo "$ONBOARD_OUTPUT" | grep -q "reusing it"; then + if grep -q "reusing it" <<<"$ONBOARD_OUTPUT"; then pass "Sandbox reused when tokens unchanged" else fail "Sandbox was not reused (unexpected rebuild)" @@ -494,7 +494,7 @@ process.exit('SLACK_APP_TOKEN' in h ? 0 : 1); echo "$ONBOARD_OUTPUT" | tail -30 fi - if echo "$ONBOARD_OUTPUT" | grep -q "credential(s) rotated"; then + if grep -q "credential(s) rotated" <<<"$ONBOARD_OUTPUT"; then pass "Credential rotation detected" else fail "Credential rotation not detected in onboard output" @@ -503,39 +503,39 @@ process.exit('SLACK_APP_TOKEN' in h ? 0 : 1); fi # Both slack-bridge (bot token) and slack-app (app token) should rotate. - if echo "$ONBOARD_OUTPUT" | grep -q "credential(s) rotated:.*slack-bridge"; then + if grep -q "credential(s) rotated:.*slack-bridge" <<<"$ONBOARD_OUTPUT"; then pass "Rotation message identifies slack-bridge" else fail "Rotation message did not identify slack-bridge" info "Onboard output:" - echo "$ONBOARD_OUTPUT" | grep "credential(s) rotated" || true + grep "credential(s) rotated" <<<"$ONBOARD_OUTPUT" || true fi - if echo "$ONBOARD_OUTPUT" | grep -q "credential(s) rotated:.*slack-app"; then + if grep -q "credential(s) rotated:.*slack-app" <<<"$ONBOARD_OUTPUT"; then pass "Rotation message identifies slack-app" else fail "Rotation message did not identify slack-app" info "Onboard output:" - echo "$ONBOARD_OUTPUT" | grep "credential(s) rotated" || true + grep "credential(s) rotated" <<<"$ONBOARD_OUTPUT" || true fi - if echo "$ONBOARD_OUTPUT" | grep -q "credential(s) rotated:.*telegram-bridge"; then + if grep -q "credential(s) rotated:.*telegram-bridge" <<<"$ONBOARD_OUTPUT"; then fail "Rotation message unexpectedly named telegram-bridge (Telegram token did not change)" info "Onboard output:" - echo "$ONBOARD_OUTPUT" | grep "credential(s) rotated" || true + grep "credential(s) rotated" <<<"$ONBOARD_OUTPUT" || true else pass "Rotation message did not name telegram-bridge (Telegram unchanged)" fi - if echo "$ONBOARD_OUTPUT" | grep -q "credential(s) rotated:.*discord-bridge"; then + if grep -q "credential(s) rotated:.*discord-bridge" <<<"$ONBOARD_OUTPUT"; then fail "Rotation message unexpectedly named discord-bridge (Discord token did not change)" info "Onboard output:" - echo "$ONBOARD_OUTPUT" | grep "credential(s) rotated" || true + grep "credential(s) rotated" <<<"$ONBOARD_OUTPUT" || true else pass "Rotation message did not name discord-bridge (Discord unchanged)" fi - if echo "$ONBOARD_OUTPUT" | grep -q "Rebuilding sandbox"; then + if grep -q "Rebuilding sandbox" <<<"$ONBOARD_OUTPUT"; then pass "Sandbox rebuild triggered by Slack rotation" else fail "Sandbox rebuild not triggered" @@ -561,7 +561,7 @@ process.exit('SLACK_APP_TOKEN' in h ? 0 : 1); echo "$ONBOARD_OUTPUT" | tail -30 fi - if echo "$ONBOARD_OUTPUT" | grep -q "reusing it"; then + if grep -q "reusing it" <<<"$ONBOARD_OUTPUT"; then pass "Sandbox reused when tokens unchanged" else fail "Sandbox was not reused (unexpected rebuild)" From 8781bcb18689abf68c1a4ff4766890dc5acea336 Mon Sep 17 00:00:00 2001 From: Aaron Erickson Date: Fri, 22 May 2026 20:07:21 -0700 Subject: [PATCH 06/13] test: update tui chat repro protocol Signed-off-by: Aaron Erickson --- test/openclaw-tui-chat-correlation.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/openclaw-tui-chat-correlation.test.ts b/test/openclaw-tui-chat-correlation.test.ts index f0cfd5bb069..07f102a3a78 100644 --- a/test/openclaw-tui-chat-correlation.test.ts +++ b/test/openclaw-tui-chat-correlation.test.ts @@ -375,8 +375,8 @@ ws.on("error", (error) => { ws.on("open", async () => { try { await request("connect", { - minProtocol: 3, - maxProtocol: 3, + minProtocol: 4, + maxProtocol: 4, client: { id: "openclaw-control-ui", displayName: "issue2603-live-repro", From 36aa2cee58bbc00f6eea2794d5e55fa71213e723 Mon Sep 17 00:00:00 2001 From: Aaron Erickson Date: Fri, 22 May 2026 21:04:16 -0700 Subject: [PATCH 07/13] fix(openclaw): shim chat send empty finals Signed-off-by: Aaron Erickson --- Dockerfile | 19 +++- scripts/patch-openclaw-chat-send.js | 117 ++++++++++++++++++++ src/lib/sandbox/build-context.ts | 4 + test/fetch-guard-patch-regression.test.ts | 2 +- test/openclaw-chat-send-patch.test.ts | 120 +++++++++++++++++++++ test/openclaw-tui-chat-correlation.test.ts | 33 +++++- test/sandbox-build-context.test.ts | 4 + 7 files changed, 293 insertions(+), 6 deletions(-) create mode 100644 scripts/patch-openclaw-chat-send.js create mode 100644 test/openclaw-chat-send-patch.test.ts diff --git a/Dockerfile b/Dockerfile index 1bd6febe753..e1f87eee126 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,7 +76,9 @@ ENV NPM_CONFIG_AUDIT=false \ NPM_CONFIG_FETCH_TIMEOUT=300000 RUN npm ci --omit=dev COPY scripts/patch-openclaw-tool-catalog.js /usr/local/lib/nemoclaw/patch-openclaw-tool-catalog.js -RUN chmod 755 /usr/local/lib/nemoclaw/patch-openclaw-tool-catalog.js +COPY scripts/patch-openclaw-chat-send.js /usr/local/lib/nemoclaw/patch-openclaw-chat-send.js +RUN chmod 755 /usr/local/lib/nemoclaw/patch-openclaw-tool-catalog.js \ + /usr/local/lib/nemoclaw/patch-openclaw-chat-send.js # Upgrade OpenClaw if the base image is stale. # @@ -290,6 +292,21 @@ RUN set -eu; \ if grep -REq --include='*.js' 'DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS = (1e4|15e3)' "$OC_DIST"; then echo "ERROR: Patch 5 left a short handshake-timeout constant" >&2; exit 1; fi; \ if ! grep -REq --include='*.js' 'DEFAULT_PREAUTH_HANDSHAKE_TIMEOUT_MS = 6e4' "$OC_DIST"; then echo "ERROR: Patch 5 did not find patched 6e4 constant" >&2; exit 1; fi +# Patch OpenClaw chat.send gateway behavior for OpenClaw 2026.5.x. +# +# OpenClaw can accept rapid TUI/WebChat chat.send requests and then emit a +# terminal chat event with state="final" but no assistant message for the later +# submitted run. That makes clients treat the turn as complete even though no +# visible reply was delivered. The shim also correlates real agent run IDs back +# to the submitted chat.send run ID when OpenClaw starts an internal run with a +# different ID, and adds the submitted run ID as the transcript idempotency key. +# +# Removal criteria: drop when upstream OpenClaw fixes openclaw/openclaw#70164 +# and openclaw/openclaw#50298, or when NemoClaw no longer ships OpenClaw 2026.5.x. +# hadolint ignore=DL3059 +RUN node /usr/local/lib/nemoclaw/patch-openclaw-chat-send.js \ + /usr/local/lib/node_modules/openclaw/dist + # Patch OpenClaw's pinned 2026.5.18 compiled selection runtime to expose a # compact searchable tool catalog to the model while preserving the full # effective tool set behind tool_call. NEMOCLAW_TOOL_CATALOG=0 disables this diff --git a/scripts/patch-openclaw-chat-send.js b/scripts/patch-openclaw-chat-send.js new file mode 100644 index 00000000000..5ab1439f155 --- /dev/null +++ b/scripts/patch-openclaw-chat-send.js @@ -0,0 +1,117 @@ +#!/usr/bin/env node +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +/* + * Temporary NemoClaw compatibility shim for OpenClaw 2026.5.x chat.send + * gateway behavior. Remove this when upstream OpenClaw preserves submitted + * chat.send run lineage and stops emitting empty terminal chat events. + */ + +const fs = require("node:fs"); +const path = require("node:path"); + +const distDir = process.argv[2]; +if (!distDir) { + console.error("Usage: patch-openclaw-chat-send.js "); + process.exit(2); +} + +function fail(message) { + console.error(`ERROR: ${message}`); + process.exit(1); +} + +function listJsFiles(dir) { + return fs + .readdirSync(dir, { withFileTypes: true }) + .filter((entry) => entry.isFile() && entry.name.endsWith(".js")) + .map((entry) => path.join(dir, entry.name)); +} + +function patchChatSendFile(file) { + let source = fs.readFileSync(file, "utf8"); + const original = source; + + if (!source.includes("nemoclaw: correlate chat.send run ids")) { + const next = source.replace( + /(onAgentRunStart: \(runId\) => \{\n)(\s*)agentRunStarted = true;/, + (_match, prefix, indent) => + `${prefix}${indent}agentRunStarted = true;\n` + + `${indent}if (runId && runId !== clientRunId) context.addChatRun(runId, { sessionKey, clientRunId }); ` + + `// nemoclaw: correlate chat.send run ids (#2603, #3145)`, + ); + if (next === source) { + fail(`OpenClaw chat.send run-start shape not recognized in ${file}`); + } + source = next; + } + + if (!source.includes("idempotencyKey: clientRunId")) { + let inserted = false; + source = source.replace( + /(createIfMissing: true,\n)(\s*)(ttsSupplement: ttsSupplementMarker,)/g, + (match, prefix, indent, ttsLine, offset) => { + const preceding = source.slice(Math.max(0, offset - 300), offset); + if (preceding.includes("idempotencyKey:")) return match; + inserted = true; + return `${prefix}${indent}idempotencyKey: clientRunId,\n${indent}${ttsLine}`; + }, + ); + if (!inserted) { + fail(`OpenClaw chat.send transcript append shape not recognized in ${file}`); + } + } + + if (!source.includes("suppressing empty final event")) { + const next = source.replace( + /\n(\s*)broadcastChatFinal\(\{\n(\s*)context,\n\s*runId: clientRunId,\n\s*sessionKey,\n\s*message\n\s*\}\);/, + ( + _match, + outerIndent, + innerIndent, + ) => + `\n${outerIndent}if (message) broadcastChatFinal({\n` + + `${innerIndent}context,\n` + + `${innerIndent}runId: clientRunId,\n` + + `${innerIndent}sessionKey,\n` + + `${innerIndent}message\n` + + `${outerIndent}}); else context.logGateway.warn("webchat chat.send completed without visible assistant reply; suppressing empty final event (nemoclaw #2603/#3145)");`, + ); + if (next === source) { + fail(`OpenClaw chat.send empty-final shape not recognized in ${file}`); + } + source = next; + } + + if (source !== original) { + fs.writeFileSync(file, source); + return true; + } + return false; +} + +const candidates = listJsFiles(distDir).filter((file) => { + const source = fs.readFileSync(file, "utf8"); + return source.includes('"chat.send"') && source.includes("onAgentRunStart"); +}); + +if (candidates.length !== 1) { + fail(`expected exactly one OpenClaw chat.send runtime file, found ${candidates.length}`); +} + +const chatFile = candidates[0]; +patchChatSendFile(chatFile); + +const patched = fs.readFileSync(chatFile, "utf8"); +if (!patched.includes("nemoclaw: correlate chat.send run ids")) { + fail("chat.send run-id correlation patch did not apply"); +} +if (!patched.includes("idempotencyKey: clientRunId")) { + fail("chat.send transcript idempotency patch did not apply"); +} +if (!patched.includes("suppressing empty final event")) { + fail("chat.send empty-final suppression patch did not apply"); +} + +console.log(`INFO: patched OpenClaw chat.send compatibility in ${path.basename(chatFile)}`); diff --git a/src/lib/sandbox/build-context.ts b/src/lib/sandbox/build-context.ts index 1bdf2016339..f436ac923b9 100644 --- a/src/lib/sandbox/build-context.ts +++ b/src/lib/sandbox/build-context.ts @@ -142,6 +142,10 @@ function stageOptimizedSandboxBuildContext( path.join(rootDir, "scripts", "patch-openclaw-tool-catalog.js"), path.join(stagedScriptsDir, "patch-openclaw-tool-catalog.js"), ); + fs.copyFileSync( + path.join(rootDir, "scripts", "patch-openclaw-chat-send.js"), + path.join(stagedScriptsDir, "patch-openclaw-chat-send.js"), + ); return { buildCtx, stagedDockerfile }; } diff --git a/test/fetch-guard-patch-regression.test.ts b/test/fetch-guard-patch-regression.test.ts index f184daccfa0..418afcf3ee3 100644 --- a/test/fetch-guard-patch-regression.test.ts +++ b/test/fetch-guard-patch-regression.test.ts @@ -272,7 +272,7 @@ if (globalThis.proxyChecks.length !== 0) throw new Error('sandbox proxy validati const command = dockerRunCommandBetween( "# Patch OpenClaw media fetch for proxy-only sandbox", - "# Patch OpenClaw's pinned", + "# Patch OpenClaw chat.send gateway behavior", ).replaceAll("/usr/local/lib/node_modules/openclaw/dist", dist); const fakeBin = path.join(tmp, "bin"); fs.mkdirSync(fakeBin); diff --git a/test/openclaw-chat-send-patch.test.ts b/test/openclaw-chat-send-patch.test.ts new file mode 100644 index 00000000000..a39d40a401c --- /dev/null +++ b/test/openclaw-chat-send-patch.test.ts @@ -0,0 +1,120 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { spawnSync } from "node:child_process"; +import fs from "node:fs"; +import os from "node:os"; +import path from "node:path"; +import { describe, expect, it } from "vitest"; + +const PATCH_SCRIPT = path.join( + import.meta.dirname, + "..", + "scripts", + "patch-openclaw-chat-send.js", +); + +function writeChatSendFixture(dist: string): string { + const fixture = path.join(dist, "chat-fixture.js"); + fs.writeFileSync( + fixture, + [ + 'const chatHandlers = {', + ' "chat.send": async ({ params, respond, context, client }) => {', + " const p = params;", + " const clientRunId = p.idempotencyKey;", + ' const sessionKey = "issue2603";', + " let agentRunStarted = false;", + " measureDiagnosticsTimelineSpan(\"gateway.chat_send.dispatch_inbound\", () => dispatchInboundMessage({", + " replyOptions: {", + " runId: clientRunId,", + " onAgentRunStart: (runId) => {", + " agentRunStarted = true;", + " if (!hasBeforeAgentRunGate) emitUserTranscriptUpdate();", + " }", + " }", + " })).then(async () => {", + " if (!agentRunStarted) {", + " let message;", + " if (transcriptReply || persistedContentForAppend?.length || assistantContent?.length) {", + " const appended = await appendAssistantTranscriptMessage({", + " message: transcriptReply,", + " sessionId,", + " storePath: latestStorePath,", + " sessionFile: latestEntry?.sessionFile,", + " agentId,", + " createIfMissing: true,", + " ttsSupplement: ttsSupplementMarker,", + " cfg", + " });", + " message = appended.message;", + " }", + " broadcastChatFinal({", + " context,", + " runId: clientRunId,", + " sessionKey,", + " message", + " });", + " }", + " });", + " }", + "};", + "", + ].join("\n"), + ); + return fixture; +} + +function runPatch(dist: string) { + return spawnSync(process.execPath, [PATCH_SCRIPT, dist], { + encoding: "utf-8", + timeout: 5000, + }); +} + +describe("OpenClaw chat.send compatibility patch", () => { + it("correlates agent runs, idempotently appends transcripts, and suppresses empty finals", () => { + const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-openclaw-chat-send-")); + const dist = path.join(tmp, "dist"); + fs.mkdirSync(dist); + const fixture = writeChatSendFixture(dist); + + try { + const patch = runPatch(dist); + expect(patch.status, `${patch.stdout}${patch.stderr}`).toBe(0); + expect(patch.stdout).toContain("patched OpenClaw chat.send compatibility"); + + const patched = fs.readFileSync(fixture, "utf-8"); + expect(patched).toContain( + "context.addChatRun(runId, { sessionKey, clientRunId }); // nemoclaw: correlate chat.send run ids (#2603, #3145)", + ); + expect(patched).toContain("idempotencyKey: clientRunId"); + expect(patched).toContain("if (message) broadcastChatFinal({"); + expect(patched).toContain("suppressing empty final event"); + + const rerun = runPatch(dist); + expect(rerun.status, `${rerun.stdout}${rerun.stderr}`).toBe(0); + const rerunPatched = fs.readFileSync(fixture, "utf-8"); + expect(rerunPatched.match(/context\.addChatRun\(runId/g)).toHaveLength(1); + expect(rerunPatched.match(/idempotencyKey: clientRunId/g)).toHaveLength(1); + expect(rerunPatched.match(/suppressing empty final event/g)).toHaveLength(1); + } finally { + fs.rmSync(tmp, { recursive: true, force: true }); + } + }); + + it("fails closed when the OpenClaw chat.send source shape changes", () => { + const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-openclaw-chat-send-missing-")); + const dist = path.join(tmp, "dist"); + fs.mkdirSync(dist); + fs.writeFileSync(path.join(dist, "chat-fixture.js"), 'const handlers = { "chat.send": true };\n'); + + try { + const patch = runPatch(dist); + expect(patch.status).toBe(1); + expect(patch.stderr).toContain("expected exactly one OpenClaw chat.send runtime file"); + } finally { + fs.rmSync(tmp, { recursive: true, force: true }); + } + }); +}); diff --git a/test/openclaw-tui-chat-correlation.test.ts b/test/openclaw-tui-chat-correlation.test.ts index 07f102a3a78..9d36e5776dc 100644 --- a/test/openclaw-tui-chat-correlation.test.ts +++ b/test/openclaw-tui-chat-correlation.test.ts @@ -14,8 +14,9 @@ const LIVE_SCRIPT_NAME = "openclaw-issue2603-chat-correlation.cjs"; const ISSUE_2603_FIX_EXPECTATIONS = [ "no empty final event for a submitted chat.send run", + "each submitted prompt receives exactly one visible reply", "each visible reply remains correlated to the chat.send run that accepted the prompt", - "chat.history contains one user turn per submitted prompt", + "chat.history contains exactly one user turn per submitted prompt", ]; type ChatMessage = { @@ -72,7 +73,10 @@ type DuplicateUserTurn = { type Issue2603Analysis = { chatEvents: CompactChatEvent[]; emptyFinalsForSubmittedRuns: CompactChatEvent[]; + missingReplies: string[]; + duplicateReplies: { replyToken: string; count: number }[]; uncorrelatedReplies: UncorrelatedReply[]; + missingUserTurns: DuplicateUserTurn[]; duplicateUserTurns: DuplicateUserTurn[]; }; @@ -132,9 +136,11 @@ function analyzeIssue2603Trace({ sentRuns, events, historyMessages }: Issue2603T ); const uncorrelatedReplies: UncorrelatedReply[] = []; + const replyCounts = new Map(); for (const [replyToken, expectedRunId] of expectedRunByReplyToken) { for (const event of chatEvents) { if (!event.text.includes(replyToken)) continue; + replyCounts.set(replyToken, (replyCounts.get(replyToken) ?? 0) + 1); if (event.runId !== expectedRunId) { uncorrelatedReplies.push({ replyToken, @@ -145,6 +151,15 @@ function analyzeIssue2603Trace({ sentRuns, events, historyMessages }: Issue2603T } } } + const missingReplies = sentRuns + .map((entry) => entry.replyToken) + .filter((replyToken) => !replyCounts.has(replyToken)); + const duplicateReplies = sentRuns + .map((entry) => ({ + replyToken: entry.replyToken, + count: replyCounts.get(entry.replyToken) ?? 0, + })) + .filter((entry) => entry.count > 1); const userPromptCounts = countBy( historyMessages @@ -152,17 +167,21 @@ function analyzeIssue2603Trace({ sentRuns, events, historyMessages }: Issue2603T .map((message) => textFromMessage(message).trim()) .filter(Boolean), ); - const duplicateUserTurns = sentRuns + const userTurnCounts = sentRuns .map((entry) => ({ promptToken: entry.promptToken, count: userPromptCounts.get(entry.message) ?? 0, - })) - .filter((entry) => entry.count > 1); + })); + const missingUserTurns = userTurnCounts.filter((entry) => entry.count < 1); + const duplicateUserTurns = userTurnCounts.filter((entry) => entry.count > 1); return { chatEvents, emptyFinalsForSubmittedRuns, + missingReplies, + duplicateReplies, uncorrelatedReplies, + missingUserTurns, duplicateUserTurns, }; } @@ -172,7 +191,10 @@ function buildFailureSummary(analysis: Issue2603Analysis): string { { expectations: ISSUE_2603_FIX_EXPECTATIONS, emptyFinalsForSubmittedRuns: analysis.emptyFinalsForSubmittedRuns, + missingReplies: analysis.missingReplies, + duplicateReplies: analysis.duplicateReplies, uncorrelatedReplies: analysis.uncorrelatedReplies, + missingUserTurns: analysis.missingUserTurns, duplicateUserTurns: analysis.duplicateUserTurns, chatEvents: analysis.chatEvents, }, @@ -506,7 +528,10 @@ describe("OpenClaw TUI chat correlation regression (#2603)", () => { const analysis = analyzeIssue2603Trace(repro); const failureSummary = buildFailureSummary(analysis); expect(analysis.emptyFinalsForSubmittedRuns, failureSummary).toEqual([]); + expect(analysis.missingReplies, failureSummary).toEqual([]); + expect(analysis.duplicateReplies, failureSummary).toEqual([]); expect(analysis.uncorrelatedReplies, failureSummary).toEqual([]); + expect(analysis.missingUserTurns, failureSummary).toEqual([]); expect(analysis.duplicateUserTurns, failureSummary).toEqual([]); }, 190_000, diff --git a/test/sandbox-build-context.test.ts b/test/sandbox-build-context.test.ts index 12ff1a56c66..c71a2be0cc8 100644 --- a/test/sandbox-build-context.test.ts +++ b/test/sandbox-build-context.test.ts @@ -74,6 +74,7 @@ describe("sandbox build context staging", () => { writeFixture(path.join("scripts", "generate-openclaw-config.py")); writeFixture(path.join("scripts", "seed-wechat-accounts.py")); writeFixture(path.join("scripts", "patch-openclaw-tool-catalog.js")); + writeFixture(path.join("scripts", "patch-openclaw-chat-send.js")); } function expectStagedBlueprintModes(buildCtx: string) { @@ -201,6 +202,9 @@ describe("sandbox build context staging", () => { expect(fs.existsSync(path.join(buildCtx, "scripts", "patch-openclaw-tool-catalog.js"))).toBe( true, ); + expect(fs.existsSync(path.join(buildCtx, "scripts", "patch-openclaw-chat-send.js"))).toBe( + true, + ); expect(fs.existsSync(path.join(buildCtx, "scripts", "lib", "sandbox-init.sh"))).toBe(true); expect(fs.existsSync(path.join(buildCtx, "scripts", "setup.sh"))).toBe(false); } finally { From 2622726d36017a967eacf2e737c56ca921bd1da2 Mon Sep 17 00:00:00 2001 From: Aaron Erickson Date: Fri, 22 May 2026 21:24:21 -0700 Subject: [PATCH 08/13] fix(openclaw): preserve chat send run ids in queue Signed-off-by: Aaron Erickson --- scripts/patch-openclaw-chat-send.js | 58 +++++++++++++++++++--- test/openclaw-chat-send-patch.test.ts | 44 ++++++++++++++-- test/openclaw-tui-chat-correlation.test.ts | 55 ++++++++++++++++++-- 3 files changed, 144 insertions(+), 13 deletions(-) diff --git a/scripts/patch-openclaw-chat-send.js b/scripts/patch-openclaw-chat-send.js index 5ab1439f155..09e47b393d1 100644 --- a/scripts/patch-openclaw-chat-send.js +++ b/scripts/patch-openclaw-chat-send.js @@ -66,11 +66,7 @@ function patchChatSendFile(file) { if (!source.includes("suppressing empty final event")) { const next = source.replace( /\n(\s*)broadcastChatFinal\(\{\n(\s*)context,\n\s*runId: clientRunId,\n\s*sessionKey,\n\s*message\n\s*\}\);/, - ( - _match, - outerIndent, - innerIndent, - ) => + (_match, outerIndent, innerIndent) => `\n${outerIndent}if (message) broadcastChatFinal({\n` + `${innerIndent}context,\n` + `${innerIndent}runId: clientRunId,\n` + @@ -91,6 +87,30 @@ function patchChatSendFile(file) { return false; } +function patchFollowupRunnerFile(file) { + let source = fs.readFileSync(file, "utf8"); + const original = source; + + if (!source.includes("preserve chat.send run ids in followup queue")) { + const next = source.replace( + /(replyOperation = createReplyOperation\(\{\n\s*sessionId: run\.sessionId,\n\s*sessionKey: replySessionKey \?\? "",\n\s*resetTriggered: false,\n\s*upstreamAbortSignal: queued\.abortSignal \?\? opts\?\.abortSignal\n\s*\}\);\n\s*)const runId = crypto\.randomUUID\(\);/, + (_match, prefix) => + `${prefix}const runId = opts?.runId ?? crypto.randomUUID(); ` + + `// nemoclaw: preserve chat.send run ids in followup queue (#2603, #3145)`, + ); + if (next === source) { + fail(`OpenClaw followup runner run-id shape not recognized in ${file}`); + } + source = next; + } + + if (source !== original) { + fs.writeFileSync(file, source); + return true; + } + return false; +} + const candidates = listJsFiles(distDir).filter((file) => { const source = fs.readFileSync(file, "utf8"); return source.includes('"chat.send"') && source.includes("onAgentRunStart"); @@ -103,6 +123,25 @@ if (candidates.length !== 1) { const chatFile = candidates[0]; patchChatSendFile(chatFile); +const followupCandidates = listJsFiles(distDir).filter((file) => { + const source = fs.readFileSync(file, "utf8"); + return ( + source.includes("function createFollowupRunner") && + source.includes("replyOperation = createReplyOperation") && + (source.includes("const runId = crypto.randomUUID();") || + source.includes("preserve chat.send run ids in followup queue")) + ); +}); + +if (followupCandidates.length !== 1) { + fail( + `expected exactly one OpenClaw followup runner runtime file, found ${followupCandidates.length}`, + ); +} + +const followupFile = followupCandidates[0]; +patchFollowupRunnerFile(followupFile); + const patched = fs.readFileSync(chatFile, "utf8"); if (!patched.includes("nemoclaw: correlate chat.send run ids")) { fail("chat.send run-id correlation patch did not apply"); @@ -114,4 +153,11 @@ if (!patched.includes("suppressing empty final event")) { fail("chat.send empty-final suppression patch did not apply"); } -console.log(`INFO: patched OpenClaw chat.send compatibility in ${path.basename(chatFile)}`); +const patchedFollowup = fs.readFileSync(followupFile, "utf8"); +if (!patchedFollowup.includes("preserve chat.send run ids in followup queue")) { + fail("followup runner run-id patch did not apply"); +} + +console.log( + `INFO: patched OpenClaw chat.send compatibility in ${path.basename(chatFile)} and ${path.basename(followupFile)}`, +); diff --git a/test/openclaw-chat-send-patch.test.ts b/test/openclaw-chat-send-patch.test.ts index a39d40a401c..9a7ac619862 100644 --- a/test/openclaw-chat-send-patch.test.ts +++ b/test/openclaw-chat-send-patch.test.ts @@ -65,6 +65,34 @@ function writeChatSendFixture(dist: string): string { return fixture; } +function writeFollowupRunnerFixture(dist: string): string { + const fixture = path.join(dist, "agent-runner.fixture.js"); + fs.writeFileSync( + fixture, + [ + "function createFollowupRunner(params) {", + " return async function runQueuedFollowup(queued, opts, run) {", + " let replyOperation;", + " replyOperation = createReplyOperation({", + " sessionId: run.sessionId,", + ' sessionKey: replySessionKey ?? "",', + " resetTriggered: false,", + " upstreamAbortSignal: queued.abortSignal ?? opts?.abortSignal", + " });", + " const runId = crypto.randomUUID();", + " if (run.sessionKey) registerAgentRunContext(runId, {", + " sessionKey: run.sessionKey,", + " verboseLevel: run.verboseLevel", + " });", + " return runId;", + " }", + "}", + "", + ].join("\n"), + ); + return fixture; +} + function runPatch(dist: string) { return spawnSync(process.execPath, [PATCH_SCRIPT, dist], { encoding: "utf-8", @@ -77,14 +105,15 @@ describe("OpenClaw chat.send compatibility patch", () => { const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-openclaw-chat-send-")); const dist = path.join(tmp, "dist"); fs.mkdirSync(dist); - const fixture = writeChatSendFixture(dist); + const chatFixture = writeChatSendFixture(dist); + const followupFixture = writeFollowupRunnerFixture(dist); try { const patch = runPatch(dist); expect(patch.status, `${patch.stdout}${patch.stderr}`).toBe(0); expect(patch.stdout).toContain("patched OpenClaw chat.send compatibility"); - const patched = fs.readFileSync(fixture, "utf-8"); + const patched = fs.readFileSync(chatFixture, "utf-8"); expect(patched).toContain( "context.addChatRun(runId, { sessionKey, clientRunId }); // nemoclaw: correlate chat.send run ids (#2603, #3145)", ); @@ -92,12 +121,21 @@ describe("OpenClaw chat.send compatibility patch", () => { expect(patched).toContain("if (message) broadcastChatFinal({"); expect(patched).toContain("suppressing empty final event"); + const patchedFollowup = fs.readFileSync(followupFixture, "utf-8"); + expect(patchedFollowup).toContain( + "const runId = opts?.runId ?? crypto.randomUUID(); // nemoclaw: preserve chat.send run ids in followup queue (#2603, #3145)", + ); + const rerun = runPatch(dist); expect(rerun.status, `${rerun.stdout}${rerun.stderr}`).toBe(0); - const rerunPatched = fs.readFileSync(fixture, "utf-8"); + const rerunPatched = fs.readFileSync(chatFixture, "utf-8"); expect(rerunPatched.match(/context\.addChatRun\(runId/g)).toHaveLength(1); expect(rerunPatched.match(/idempotencyKey: clientRunId/g)).toHaveLength(1); expect(rerunPatched.match(/suppressing empty final event/g)).toHaveLength(1); + const rerunPatchedFollowup = fs.readFileSync(followupFixture, "utf-8"); + expect(rerunPatchedFollowup.match(/preserve chat\.send run ids in followup queue/g)).toHaveLength( + 1, + ); } finally { fs.rmSync(tmp, { recursive: true, force: true }); } diff --git a/test/openclaw-tui-chat-correlation.test.ts b/test/openclaw-tui-chat-correlation.test.ts index 9d36e5776dc..c7ef1604bd8 100644 --- a/test/openclaw-tui-chat-correlation.test.ts +++ b/test/openclaw-tui-chat-correlation.test.ts @@ -136,11 +136,15 @@ function analyzeIssue2603Trace({ sentRuns, events, historyMessages }: Issue2603T ); const uncorrelatedReplies: UncorrelatedReply[] = []; - const replyCounts = new Map(); + const visibleReplyCounts = new Map(); + const finalReplyCounts = new Map(); for (const [replyToken, expectedRunId] of expectedRunByReplyToken) { for (const event of chatEvents) { if (!event.text.includes(replyToken)) continue; - replyCounts.set(replyToken, (replyCounts.get(replyToken) ?? 0) + 1); + visibleReplyCounts.set(replyToken, (visibleReplyCounts.get(replyToken) ?? 0) + 1); + if (event.state === "final") { + finalReplyCounts.set(replyToken, (finalReplyCounts.get(replyToken) ?? 0) + 1); + } if (event.runId !== expectedRunId) { uncorrelatedReplies.push({ replyToken, @@ -153,11 +157,11 @@ function analyzeIssue2603Trace({ sentRuns, events, historyMessages }: Issue2603T } const missingReplies = sentRuns .map((entry) => entry.replyToken) - .filter((replyToken) => !replyCounts.has(replyToken)); + .filter((replyToken) => !visibleReplyCounts.has(replyToken)); const duplicateReplies = sentRuns .map((entry) => ({ replyToken: entry.replyToken, - count: replyCounts.get(entry.replyToken) ?? 0, + count: finalReplyCounts.get(entry.replyToken) ?? 0, })) .filter((entry) => entry.count > 1); @@ -518,6 +522,49 @@ describe("OpenClaw TUI chat correlation regression (#2603)", () => { ]); }); + it("does not classify a streamed delta plus final for the same run as a duplicate reply", () => { + const analysis = analyzeIssue2603Trace({ + sentRuns: [ + { + promptToken: "B2603", + replyToken: "B2603-REPLY", + runId: "a32dc5a4-9b45-4109-9b17-2fcd35787d0c", + message: "B2603: Second task. Reply exactly B2603-REPLY and nothing else.", + }, + ], + events: [ + { + event: "chat", + payload: { + runId: "a32dc5a4-9b45-4109-9b17-2fcd35787d0c", + state: "delta", + message: { role: "assistant", content: [{ type: "text", text: "B2603-REPLY" }] }, + }, + }, + { + event: "chat", + payload: { + runId: "a32dc5a4-9b45-4109-9b17-2fcd35787d0c", + state: "final", + message: { role: "assistant", content: [{ type: "text", text: "B2603-REPLY" }] }, + }, + }, + ], + historyMessages: [ + { + role: "user", + content: [ + { type: "text", text: "B2603: Second task. Reply exactly B2603-REPLY and nothing else." }, + ], + }, + ], + }); + + expect(analysis.missingReplies).toEqual([]); + expect(analysis.duplicateReplies).toEqual([]); + expect(analysis.uncorrelatedReplies).toEqual([]); + }); + it.runIf(process.env[LIVE_REPRO_ENV] === "1")( "keeps rapid live TUI/webchat sends correlated on a real OpenClaw sandbox", () => { From efe4ca78fb93bdbcca32a2392f0d13487e7298b9 Mon Sep 17 00:00:00 2001 From: Aaron Erickson Date: Fri, 22 May 2026 21:40:43 -0700 Subject: [PATCH 09/13] fix(openclaw): queue chat send turns separately Signed-off-by: Aaron Erickson --- Dockerfile | 3 +- scripts/patch-openclaw-chat-send.js | 90 ++++++++++++++++++++++++++- test/openclaw-chat-send-patch.test.ts | 54 +++++++++++++++- 3 files changed, 143 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index e1f87eee126..87d2ca20eb7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -299,7 +299,8 @@ RUN set -eu; \ # submitted run. That makes clients treat the turn as complete even though no # visible reply was delivered. The shim also correlates real agent run IDs back # to the submitted chat.send run ID when OpenClaw starts an internal run with a -# different ID, and adds the submitted run ID as the transcript idempotency key. +# different ID, carries that submitted ID through queued follow-up turns, and +# adds the submitted run ID as the transcript idempotency key. # # Removal criteria: drop when upstream OpenClaw fixes openclaw/openclaw#70164 # and openclaw/openclaw#50298, or when NemoClaw no longer ships OpenClaw 2026.5.x. diff --git a/scripts/patch-openclaw-chat-send.js b/scripts/patch-openclaw-chat-send.js index 09e47b393d1..8ff17744c58 100644 --- a/scripts/patch-openclaw-chat-send.js +++ b/scripts/patch-openclaw-chat-send.js @@ -91,11 +91,22 @@ function patchFollowupRunnerFile(file) { let source = fs.readFileSync(file, "utf8"); const original = source; + if ( + source.includes( + "const runId = opts?.runId ?? crypto.randomUUID(); // nemoclaw: preserve chat.send run ids in followup queue", + ) + ) { + source = source.replace( + "const runId = opts?.runId ?? crypto.randomUUID(); // nemoclaw: preserve chat.send run ids in followup queue", + "const runId = queued.runId ?? opts?.runId ?? crypto.randomUUID(); // nemoclaw: preserve chat.send run ids in followup queue", + ); + } + if (!source.includes("preserve chat.send run ids in followup queue")) { const next = source.replace( /(replyOperation = createReplyOperation\(\{\n\s*sessionId: run\.sessionId,\n\s*sessionKey: replySessionKey \?\? "",\n\s*resetTriggered: false,\n\s*upstreamAbortSignal: queued\.abortSignal \?\? opts\?\.abortSignal\n\s*\}\);\n\s*)const runId = crypto\.randomUUID\(\);/, (_match, prefix) => - `${prefix}const runId = opts?.runId ?? crypto.randomUUID(); ` + + `${prefix}const runId = queued.runId ?? opts?.runId ?? crypto.randomUUID(); ` + `// nemoclaw: preserve chat.send run ids in followup queue (#2603, #3145)`, ); if (next === source) { @@ -111,6 +122,57 @@ function patchFollowupRunnerFile(file) { return false; } +function patchGetReplyFile(file) { + let source = fs.readFileSync(file, "utf8"); + const original = source; + + if (!source.includes("carry chat.send run id into queued followup")) { + const next = source.replace( + /(const followupRun = \{\n)(\s*)prompt: queuedBody,/, + (_match, prefix, indent) => + `${prefix}${indent}runId: opts?.runId, ` + + `// nemoclaw: carry chat.send run id into queued followup (#2603, #3145)\n` + + `${indent}prompt: queuedBody,`, + ); + if (next === source) { + fail(`OpenClaw get-reply followup run shape not recognized in ${file}`); + } + source = next; + } + + if (!source.includes("force webchat chat.send queued turns")) { + if (source.includes("const resolvedQueue = useFastReplyRuntime ? {")) { + source = source.replace( + "const resolvedQueue = useFastReplyRuntime ? {", + "let resolvedQueue = useFastReplyRuntime ? {", + ); + } else if (!source.includes("let resolvedQueue = useFastReplyRuntime ? {")) { + fail(`OpenClaw get-reply queue settings shape not recognized in ${file}`); + } + + const next = source.replace( + /\n(\s*)const piRuntime = useFastReplyRuntime \? null : await traceRunPhase\("reply\.load_pi_runtime", \(\) => loadPiEmbeddedRuntime\(\)\);/, + (_match, indent) => + `\n${indent}if (opts?.runId && sessionCtx.Provider === "webchat" && resolvedQueue.mode === "steer") resolvedQueue = {\n` + + `${indent}\t...resolvedQueue,\n` + + `${indent}\tmode: "followup",\n` + + `${indent}\tdebounceMs: 0\n` + + `${indent}}; // nemoclaw: force webchat chat.send queued turns to keep per-message replies (#2603, #3145)\n` + + `${indent}const piRuntime = useFastReplyRuntime ? null : await traceRunPhase("reply.load_pi_runtime", () => loadPiEmbeddedRuntime());`, + ); + if (next === source) { + fail(`OpenClaw get-reply pi runtime shape not recognized in ${file}`); + } + source = next; + } + + if (source !== original) { + fs.writeFileSync(file, source); + return true; + } + return false; +} + const candidates = listJsFiles(distDir).filter((file) => { const source = fs.readFileSync(file, "utf8"); return source.includes('"chat.send"') && source.includes("onAgentRunStart"); @@ -123,6 +185,22 @@ if (candidates.length !== 1) { const chatFile = candidates[0]; patchChatSendFile(chatFile); +const getReplyCandidates = listJsFiles(distDir).filter((file) => { + const source = fs.readFileSync(file, "utf8"); + return ( + source.includes("resolveQueueSettings") && + (source.includes("const followupRun = {") || + source.includes("carry chat.send run id into queued followup")) + ); +}); + +if (getReplyCandidates.length !== 1) { + fail(`expected exactly one OpenClaw get-reply runtime file, found ${getReplyCandidates.length}`); +} + +const getReplyFile = getReplyCandidates[0]; +patchGetReplyFile(getReplyFile); + const followupCandidates = listJsFiles(distDir).filter((file) => { const source = fs.readFileSync(file, "utf8"); return ( @@ -153,11 +231,19 @@ if (!patched.includes("suppressing empty final event")) { fail("chat.send empty-final suppression patch did not apply"); } +const patchedGetReply = fs.readFileSync(getReplyFile, "utf8"); +if (!patchedGetReply.includes("carry chat.send run id into queued followup")) { + fail("get-reply queued run-id patch did not apply"); +} +if (!patchedGetReply.includes("force webchat chat.send queued turns")) { + fail("get-reply webchat queue mode patch did not apply"); +} + const patchedFollowup = fs.readFileSync(followupFile, "utf8"); if (!patchedFollowup.includes("preserve chat.send run ids in followup queue")) { fail("followup runner run-id patch did not apply"); } console.log( - `INFO: patched OpenClaw chat.send compatibility in ${path.basename(chatFile)} and ${path.basename(followupFile)}`, + `INFO: patched OpenClaw chat.send compatibility in ${path.basename(chatFile)}, ${path.basename(getReplyFile)}, and ${path.basename(followupFile)}`, ); diff --git a/test/openclaw-chat-send-patch.test.ts b/test/openclaw-chat-send-patch.test.ts index 9a7ac619862..4c84c7cba14 100644 --- a/test/openclaw-chat-send-patch.test.ts +++ b/test/openclaw-chat-send-patch.test.ts @@ -93,6 +93,42 @@ function writeFollowupRunnerFixture(dist: string): string { return fixture; } +function writeGetReplyFixture(dist: string): string { + const fixture = path.join(dist, "get-reply.fixture.js"); + fs.writeFileSync( + fixture, + [ + "async function getReplyFromConfig(params) {", + " const { cfg, opts, sessionCtx, sessionEntry, perMessageQueueMode, perMessageQueueOptions } = params;", + " const resolvedQueue = useFastReplyRuntime ? {", + ' mode: "collect",', + " debounceMs: 0,", + " cap: 1,", + ' dropPolicy: "summarize"', + " } : resolveQueueSettings({", + " cfg,", + " channel: sessionCtx.Provider,", + " sessionEntry,", + " inlineMode: perMessageQueueMode,", + " inlineOptions: perMessageQueueOptions", + " });", + ' const piRuntime = useFastReplyRuntime ? null : await traceRunPhase("reply.load_pi_runtime", () => loadPiEmbeddedRuntime());', + " const followupRun = {", + " prompt: queuedBody,", + " transcriptPrompt: transcriptCommandBody,", + " currentInboundEventKind: inboundEventKind,", + " currentInboundContext,", + " abortSignal: opts?.abortSignal,", + " run: { sessionId: preparedSessionState.sessionId }", + " };", + " return { resolvedQueue, piRuntime, followupRun };", + "}", + "", + ].join("\n"), + ); + return fixture; +} + function runPatch(dist: string) { return spawnSync(process.execPath, [PATCH_SCRIPT, dist], { encoding: "utf-8", @@ -107,6 +143,7 @@ describe("OpenClaw chat.send compatibility patch", () => { fs.mkdirSync(dist); const chatFixture = writeChatSendFixture(dist); const followupFixture = writeFollowupRunnerFixture(dist); + const getReplyFixture = writeGetReplyFixture(dist); try { const patch = runPatch(dist); @@ -123,7 +160,17 @@ describe("OpenClaw chat.send compatibility patch", () => { const patchedFollowup = fs.readFileSync(followupFixture, "utf-8"); expect(patchedFollowup).toContain( - "const runId = opts?.runId ?? crypto.randomUUID(); // nemoclaw: preserve chat.send run ids in followup queue (#2603, #3145)", + "const runId = queued.runId ?? opts?.runId ?? crypto.randomUUID(); // nemoclaw: preserve chat.send run ids in followup queue (#2603, #3145)", + ); + const patchedGetReply = fs.readFileSync(getReplyFixture, "utf-8"); + expect(patchedGetReply).toContain( + "runId: opts?.runId, // nemoclaw: carry chat.send run id into queued followup (#2603, #3145)", + ); + expect(patchedGetReply).toContain( + 'if (opts?.runId && sessionCtx.Provider === "webchat" && resolvedQueue.mode === "steer") resolvedQueue = {', + ); + expect(patchedGetReply).toContain( + "}; // nemoclaw: force webchat chat.send queued turns to keep per-message replies (#2603, #3145)", ); const rerun = runPatch(dist); @@ -136,6 +183,11 @@ describe("OpenClaw chat.send compatibility patch", () => { expect(rerunPatchedFollowup.match(/preserve chat\.send run ids in followup queue/g)).toHaveLength( 1, ); + const rerunPatchedGetReply = fs.readFileSync(getReplyFixture, "utf-8"); + expect(rerunPatchedGetReply.match(/carry chat\.send run id into queued followup/g)).toHaveLength( + 1, + ); + expect(rerunPatchedGetReply.match(/force webchat chat\.send queued turns/g)).toHaveLength(1); } finally { fs.rmSync(tmp, { recursive: true, force: true }); } From 93bedf29a16a919fc3716f91accb87ff8ef15c36 Mon Sep 17 00:00:00 2001 From: Aaron Erickson Date: Fri, 22 May 2026 22:22:07 -0700 Subject: [PATCH 10/13] ci: include new nightly jobs in aggregates Signed-off-by: Aaron Erickson --- .github/workflows/nightly-e2e.yaml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nightly-e2e.yaml b/.github/workflows/nightly-e2e.yaml index aba4e6e754d..17c4081bd78 100644 --- a/.github/workflows/nightly-e2e.yaml +++ b/.github/workflows/nightly-e2e.yaml @@ -83,6 +83,7 @@ on: skill-agent-e2e, docs-validation-e2e, messaging-providers-e2e, openclaw-slack-pairing-e2e, openclaw-tui-chat-correlation-e2e, + issue-3600-gpu-proof-optional-e2e, openclaw-discord-pairing-e2e, messaging-compatible-endpoint-e2e, kimi-inference-compat-e2e, @@ -414,7 +415,7 @@ jobs: ref: ${{ inputs.target_ref || github.ref }} - name: Setup Node.js - uses: actions/setup-node@v6 + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.0.0 with: node-version: "22" @@ -457,7 +458,7 @@ jobs: ref: ${{ inputs.target_ref || github.ref }} - name: Setup Node.js - uses: actions/setup-node@v6 + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.0.0 with: node-version: "22" @@ -1801,7 +1802,7 @@ jobs: ref: ${{ inputs.target_ref || github.ref }} - name: Setup Node - uses: actions/setup-node@v6 + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.0.0 with: node-version: "22" @@ -2444,6 +2445,8 @@ jobs: docs-validation-e2e, messaging-providers-e2e, openclaw-slack-pairing-e2e, + openclaw-tui-chat-correlation-e2e, + issue-3600-gpu-proof-optional-e2e, openclaw-discord-pairing-e2e, messaging-compatible-endpoint-e2e, channels-add-remove-e2e, @@ -2544,6 +2547,8 @@ jobs: docs-validation-e2e, messaging-providers-e2e, openclaw-slack-pairing-e2e, + openclaw-tui-chat-correlation-e2e, + issue-3600-gpu-proof-optional-e2e, openclaw-discord-pairing-e2e, messaging-compatible-endpoint-e2e, channels-add-remove-e2e, @@ -2701,6 +2706,8 @@ jobs: docs-validation-e2e, messaging-providers-e2e, openclaw-slack-pairing-e2e, + openclaw-tui-chat-correlation-e2e, + issue-3600-gpu-proof-optional-e2e, openclaw-discord-pairing-e2e, messaging-compatible-endpoint-e2e, channels-add-remove-e2e, From bc95dec6b5288d631cf16128485b65c79669b99c Mon Sep 17 00:00:00 2001 From: Aaron Erickson Date: Fri, 22 May 2026 22:29:03 -0700 Subject: [PATCH 11/13] fix: mark OpenClaw chat send patch executable Signed-off-by: Aaron Erickson --- scripts/patch-openclaw-chat-send.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/patch-openclaw-chat-send.js diff --git a/scripts/patch-openclaw-chat-send.js b/scripts/patch-openclaw-chat-send.js old mode 100644 new mode 100755 From bf94b84fa17b94dba51294362431ca9f25737209 Mon Sep 17 00:00:00 2001 From: Aaron Erickson Date: Fri, 22 May 2026 22:29:45 -0700 Subject: [PATCH 12/13] test: decouple gpu proof check from neighbor function Signed-off-by: Aaron Erickson --- .github/workflows/nightly-e2e.yaml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightly-e2e.yaml b/.github/workflows/nightly-e2e.yaml index 17c4081bd78..d222a0e6e10 100644 --- a/.github/workflows/nightly-e2e.yaml +++ b/.github/workflows/nightly-e2e.yaml @@ -468,10 +468,23 @@ jobs: const fs = require('node:fs'); const source = fs.readFileSync('src/lib/onboard.ts', 'utf8'); const start = source.indexOf('function verifyDirectSandboxGpu'); - const end = source.indexOf('\n}\n\nfunction upsertMessagingProviders', start) + 2; - if (start < 0 || end < 2) { + if (start < 0) { throw new Error('verifyDirectSandboxGpu function not found'); } + const bodyStart = source.indexOf('{', start); + let depth = 0; + let end = -1; + for (let i = bodyStart; i < source.length; i += 1) { + if (source[i] === '{') depth += 1; + if (source[i] === '}') depth -= 1; + if (depth === 0) { + end = i + 1; + break; + } + } + if (bodyStart < 0 || end < 0) { + throw new Error('verifyDirectSandboxGpu function body not found'); + } const fn = source.slice(start, end); const optional = fn.indexOf('if (proof.optional === true) return;'); const throwing = fn.indexOf('throw new Error(`GPU proof failed:'); From 1c6a7afb195be5424fb497c0bee6227b46829169 Mon Sep 17 00:00:00 2001 From: Aaron Erickson Date: Fri, 22 May 2026 22:40:46 -0700 Subject: [PATCH 13/13] chore: route new e2e review hints Signed-off-by: Aaron Erickson --- .coderabbit.yaml | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 8fe51f496e6..107b16e1b19 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -153,10 +153,12 @@ reviews: - `sandbox-survival-e2e` — gateway restart recovery - `hermes-e2e` — Hermes agent onboard + inference - `rebuild-openclaw-e2e` — workspace state survives rebuild + - `openclaw-tui-chat-correlation-e2e` — baked OpenClaw chat send + patch preserves user/assistant turn correlation To run selectively: ``` - gh workflow run nightly-e2e.yaml --ref -f jobs=cloud-e2e,sandbox-survival-e2e,hermes-e2e,rebuild-openclaw-e2e + gh workflow run nightly-e2e.yaml --ref -f jobs=cloud-e2e,sandbox-survival-e2e,hermes-e2e,rebuild-openclaw-e2e,openclaw-tui-chat-correlation-e2e ``` - path: "Dockerfile.base" @@ -197,10 +199,12 @@ reviews: - `hermes-slack-e2e` — Hermes Slack policy + Python placeholder egress - `openshell-gateway-upgrade-e2e` — stale Linux Docker-driver gateway process restart after OpenShell upgrade + - `issue-3600-gpu-proof-optional-e2e` — direct GPU verification remains + optional when CUDA probing fails before sandbox creation To run selectively: ``` - gh workflow run nightly-e2e.yaml --ref -f jobs=cloud-e2e,sandbox-operations-e2e,rebuild-openclaw-e2e,channels-stop-start-e2e,messaging-compatible-endpoint-e2e,bedrock-runtime-compatible-anthropic-e2e,hermes-discord-e2e,hermes-slack-e2e,openshell-gateway-upgrade-e2e + gh workflow run nightly-e2e.yaml --ref -f jobs=cloud-e2e,sandbox-operations-e2e,rebuild-openclaw-e2e,channels-stop-start-e2e,messaging-compatible-endpoint-e2e,bedrock-runtime-compatible-anthropic-e2e,hermes-discord-e2e,hermes-slack-e2e,openshell-gateway-upgrade-e2e,issue-3600-gpu-proof-optional-e2e ``` - path: "src/lib/onboard/bedrock-runtime.ts" @@ -377,6 +381,27 @@ reviews: gh workflow run nightly-e2e.yaml --ref -f jobs=hermes-slack-e2e ``` + - path: "scripts/patch-openclaw-chat-send.js" + instructions: &e2e-openclaw-tui-chat-correlation | + This helper patches OpenClaw chat send behavior inside the sandbox + image. Changes can affect TUI message ordering, duplicate sends, and + user/assistant turn correlation when OpenClaw is the active agent. + + **E2E test recommendation:** + - `openclaw-tui-chat-correlation-e2e` - hermetic TUI chat proof for + correlated user/assistant turns + + To run selectively: + ``` + gh workflow run nightly-e2e.yaml --ref -f jobs=openclaw-tui-chat-correlation-e2e + ``` + + - path: "test/e2e/test-openclaw-tui-chat-correlation.sh" + instructions: *e2e-openclaw-tui-chat-correlation + + - path: "test/openclaw-tui-chat-correlation.test.ts" + instructions: *e2e-openclaw-tui-chat-correlation + - path: "test/e2e/test-openclaw-slack-pairing.sh" instructions: | This script validates OpenClaw Slack DM pairing across the gateway