From f52d60535bb4a499a2a1048f12d89e982877bf25 Mon Sep 17 00:00:00 2001 From: San Dang Date: Mon, 19 Oct 2026 12:39:41 +0700 Subject: [PATCH 1/8] test(e2e): use the native Ollama provider in GPU route checks OpenClaw Ollama onboarding attaches each sandbox to its own OpenShell provider behind the auth proxy and publishes no shared gateway route (#13293). The GPU Ollama and GPU double-onboard E2Es still required the shared route and sent requests to inference.local, which now returns "Not configured" and HTTP 503. Check the recorded native endpoint and send the sandbox requests to it with the supervisor-issued credential handle. The answer checks, proxy token checks, timeouts and cleanup are unchanged. Refs #13338. Signed-off-by: San Dang --- test/e2e/live/gpu-double-onboard.test.ts | 13 ++++++++++-- test/e2e/live/gpu-e2e.test.ts | 25 +++++++++++++----------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/test/e2e/live/gpu-double-onboard.test.ts b/test/e2e/live/gpu-double-onboard.test.ts index 03777ab4a0e..a2534d89e1a 100644 --- a/test/e2e/live/gpu-double-onboard.test.ts +++ b/test/e2e/live/gpu-double-onboard.test.ts @@ -4,6 +4,9 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; +import { NATIVE_LOCAL_AUTH_HEADER_SCRIPT } from "../../../src/lib/inference/native-local/agent-config.ts"; +import { normalizeNativeLocalProviderAttachment } from "../../../src/lib/inference/native-local/contract.ts"; +import { getSandbox } from "../../../src/lib/state/registry.ts"; import { containsAnswer } from "../../helpers/e2e-answer-assertions.ts"; import { execTimeout, testTimeout } from "../../helpers/timeouts.ts"; import { buildAvailabilityProbeEnv } from "../fixtures/availability-env.ts"; @@ -140,12 +143,18 @@ async function expectSandboxInference42( model: string, artifactName: string, ): Promise { + // OpenClaw local inference uses a sandbox-owned provider behind the auth proxy, not the shared + // gateway route (#13293). Re-read it after re-onboarding recreates the sandbox. A missing + // attachment yields an unresolvable host, which fails the request assertion below. + const endpoint = + normalizeNativeLocalProviderAttachment(getSandbox(SANDBOX_NAME)?.nativeLocalProviderAttachment) + ?.endpointUrl ?? "http://missing-native-local-attachment.invalid/v1"; const response = await sandbox.exec( SANDBOX_NAME, [ "sh", "-lc", - `curl -fsS --max-time 120 https://inference.local/v1/chat/completions -H 'Content-Type: application/json' --data '${chatRequest(model)}' | ${parseReplyCommand()}`, + `${NATIVE_LOCAL_AUTH_HEADER_SCRIPT}; curl -fsS --max-time 120 '${endpoint}/chat/completions' -H "$AUTH_HEADER" -H 'Content-Type: application/json' --data '${chatRequest(model)}' | ${parseReplyCommand()}`, ], { artifactName, @@ -192,7 +201,7 @@ test( "the persisted Ollama auth-proxy token works after first onboard", "nemoclaw onboard --non-interactive --yes recreates the sandbox", "the running proxy accepts the persisted token after re-onboard and rejects unauthenticated/wrong-token requests", - "sandbox inference.local reaches Ollama after re-onboard", + "the sandbox-owned native provider reaches Ollama after first onboard and re-onboard", ], }); diff --git a/test/e2e/live/gpu-e2e.test.ts b/test/e2e/live/gpu-e2e.test.ts index 0c0b895599d..73395398bec 100644 --- a/test/e2e/live/gpu-e2e.test.ts +++ b/test/e2e/live/gpu-e2e.test.ts @@ -7,8 +7,11 @@ import path from "node:path"; import { EXPORTED_VLLM_PROFILE_ID } from "../../../src/lib/config/model.ts"; import type { V1Alpha1OllamaProxyService } from "../../../src/lib/config/v1alpha1-export.ts"; import { cleanupLocalModelRuntimes } from "../../../src/lib/inference/local-model-profile/cleanup.ts"; +import { NATIVE_LOCAL_AUTH_HEADER_SCRIPT } from "../../../src/lib/inference/native-local/agent-config.ts"; +import { normalizeNativeLocalProviderAttachment } from "../../../src/lib/inference/native-local/contract.ts"; import { HOST_LOCAL_VLLM_CONTAINER_NAME } from "../../../src/lib/inference/serving/vllm-host-local-lifecycle.ts"; import { loadManagedVllmApiKey } from "../../../src/lib/inference/vllm-api-key.ts"; +import { getSandbox } from "../../../src/lib/state/registry.ts"; import { execTimeout, testTimeout } from "../../helpers/timeouts.ts"; import { buildAvailabilityProbeEnv } from "../fixtures/availability-env.ts"; import { resultText } from "../fixtures/clients/index.ts"; @@ -84,7 +87,7 @@ test( "install Ollama and GPU sandbox", "validate GPU runtime status", "validate Ollama proxy credential boundary", - "run sandbox inference.local chat", + "run sandbox native Ollama chat", "restart Ollama and recover agent inference", ], }, @@ -93,7 +96,7 @@ test( await artifacts.target.declare({ id: "gpu-e2e", boundary: - "GPU host + install.sh Ollama provider + OpenShell sandbox + auth proxy + inference.local", + "GPU host + install.sh Ollama provider + OpenShell sandbox + auth proxy + sandbox-owned native provider", credentialBoundary: "The proxy token remains host/OpenShell-owned and is absent from sandbox env.", remoteInstallerBoundary: @@ -191,12 +194,12 @@ test( expect(retainedSandboxContainer.State).toBe("running"); expect(retainedSandboxContainer.Status).toMatch(/\(healthy\)/i); - const route = await sandbox.openshell(["inference", "get"], { - artifactName: "openshell-inference-route", - env: env(), - timeoutMs: 30_000, - }); - expect(resultText(route)).toMatch(/ollama/i); + // OpenClaw local inference uses a sandbox-owned provider behind the auth proxy, not the + // shared gateway route (#13293). + const nativeEndpoint = normalizeNativeLocalProviderAttachment( + getSandbox(SANDBOX_NAME)?.nativeLocalProviderAttachment, + )?.endpointUrl; + expect(nativeEndpoint).toBe(`http://host.openshell.internal:${PROXY_PORT}/v1`); progress.phase("validate Ollama proxy credential boundary"); const tokenRecord = readTokenFileChecked(ollamaProxyTokenFile()); @@ -238,12 +241,12 @@ test( "OpenShell owns proxy authentication; the host proxy token must not enter sandbox env", ).toBe(""); - progress.phase("run sandbox inference.local chat"); + progress.phase("run sandbox native Ollama chat"); const model = await detectOllamaModel(host); const chat = await sandbox.execShell( SANDBOX_NAME, trustedSandboxShellScript( - `curl -sS --max-time 120 https://inference.local/v1/chat/completions -H 'Content-Type: application/json' --data '${JSON.stringify( + `${NATIVE_LOCAL_AUTH_HEADER_SCRIPT}; curl -sS --max-time 120 '${nativeEndpoint}/chat/completions' -H "$AUTH_HEADER" -H 'Content-Type: application/json' --data '${JSON.stringify( { model, messages: [{ role: "user", content: "Reply with exactly one word: PONG" }], @@ -255,7 +258,7 @@ test( }, )}'`, ), - { artifactName: "sandbox-inference-local-chat", env: env(), timeoutMs: 150_000 }, + { artifactName: "sandbox-native-ollama-chat", env: env(), timeoutMs: 150_000 }, ); expect(chatContent(chat.stdout)).toMatch(/pong/i); From b530292dbafc4212f1b883214543f3a183872e45 Mon Sep 17 00:00:00 2001 From: San Dang Date: Mon, 19 Oct 2026 13:01:06 +0700 Subject: [PATCH 2/8] test(e2e): cover the GPU native chat request in fast tests The mock/live parity check requires a mapped fast test whenever a live E2E changes. Move the sandbox chat request for the native Ollama provider into a shared fixture used by both GPU tests, and test it with a recording curl: it sends the OpenShell-issued credential handle to the recorded endpoint and refuses a raw or missing credential before calling curl. Map the fixture and the support test to both GPU live tests. Refs #13338. Signed-off-by: San Dang --- test/e2e/fixtures/native-local-chat.ts | 18 ++++++++ test/e2e/live/gpu-double-onboard.test.ts | 4 +- test/e2e/live/gpu-e2e.test.ts | 12 +++-- test/e2e/mock-parity.json | 5 +- test/e2e/support/gpu-e2e-helpers.test.ts | 59 ++++++++++++++++++++++++ 5 files changed, 90 insertions(+), 8 deletions(-) create mode 100644 test/e2e/fixtures/native-local-chat.ts diff --git a/test/e2e/fixtures/native-local-chat.ts b/test/e2e/fixtures/native-local-chat.ts new file mode 100644 index 00000000000..0fa4f80ce35 --- /dev/null +++ b/test/e2e/fixtures/native-local-chat.ts @@ -0,0 +1,18 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { NATIVE_LOCAL_AUTH_HEADER_SCRIPT } from "../../../src/lib/inference/native-local/agent-config.ts"; + +/** + * Sandbox shell command for a chat request to a sandbox-owned native local provider (#13293). + * The auth script accepts only the credential handle that OpenShell issues, so the raw local + * credential never enters the request. Callers pass a recorded endpoint and a JSON body without + * single quotes. + */ +export function nativeLocalChatCommand( + endpointUrl: string, + body: string, + curlFlags: "-fsS" | "-sS", +): string { + return `${NATIVE_LOCAL_AUTH_HEADER_SCRIPT}; curl ${curlFlags} --max-time 120 '${endpointUrl}/chat/completions' -H "$AUTH_HEADER" -H 'Content-Type: application/json' --data '${body}'`; +} diff --git a/test/e2e/live/gpu-double-onboard.test.ts b/test/e2e/live/gpu-double-onboard.test.ts index a2534d89e1a..786ee92beea 100644 --- a/test/e2e/live/gpu-double-onboard.test.ts +++ b/test/e2e/live/gpu-double-onboard.test.ts @@ -4,7 +4,6 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; -import { NATIVE_LOCAL_AUTH_HEADER_SCRIPT } from "../../../src/lib/inference/native-local/agent-config.ts"; import { normalizeNativeLocalProviderAttachment } from "../../../src/lib/inference/native-local/contract.ts"; import { getSandbox } from "../../../src/lib/state/registry.ts"; import { containsAnswer } from "../../helpers/e2e-answer-assertions.ts"; @@ -18,6 +17,7 @@ import { resultText } from "../fixtures/clients/command.ts"; import { type HostCliClient } from "../fixtures/clients/host.ts"; import { type SandboxClient, validateSandboxName } from "../fixtures/clients/sandbox.ts"; import { expect, test } from "../fixtures/e2e-test.ts"; +import { nativeLocalChatCommand } from "../fixtures/native-local-chat.ts"; import { CLI_ENTRYPOINT, REPO_ROOT } from "../fixtures/paths.ts"; import type { ShellProbeResult } from "../fixtures/shell-probe.ts"; @@ -154,7 +154,7 @@ async function expectSandboxInference42( [ "sh", "-lc", - `${NATIVE_LOCAL_AUTH_HEADER_SCRIPT}; curl -fsS --max-time 120 '${endpoint}/chat/completions' -H "$AUTH_HEADER" -H 'Content-Type: application/json' --data '${chatRequest(model)}' | ${parseReplyCommand()}`, + `${nativeLocalChatCommand(endpoint, chatRequest(model), "-fsS")} | ${parseReplyCommand()}`, ], { artifactName, diff --git a/test/e2e/live/gpu-e2e.test.ts b/test/e2e/live/gpu-e2e.test.ts index 73395398bec..e81a15feedd 100644 --- a/test/e2e/live/gpu-e2e.test.ts +++ b/test/e2e/live/gpu-e2e.test.ts @@ -7,7 +7,6 @@ import path from "node:path"; import { EXPORTED_VLLM_PROFILE_ID } from "../../../src/lib/config/model.ts"; import type { V1Alpha1OllamaProxyService } from "../../../src/lib/config/v1alpha1-export.ts"; import { cleanupLocalModelRuntimes } from "../../../src/lib/inference/local-model-profile/cleanup.ts"; -import { NATIVE_LOCAL_AUTH_HEADER_SCRIPT } from "../../../src/lib/inference/native-local/agent-config.ts"; import { normalizeNativeLocalProviderAttachment } from "../../../src/lib/inference/native-local/contract.ts"; import { HOST_LOCAL_VLLM_CONTAINER_NAME } from "../../../src/lib/inference/serving/vllm-host-local-lifecycle.ts"; import { loadManagedVllmApiKey } from "../../../src/lib/inference/vllm-api-key.ts"; @@ -18,6 +17,7 @@ import { resultText } from "../fixtures/clients/index.ts"; import { trustedSandboxShellScript } from "../fixtures/clients/sandbox.ts"; import { parseConfigExport } from "../fixtures/phases/config-export-validation.ts"; import { expect, test } from "../fixtures/e2e-test.ts"; +import { nativeLocalChatCommand } from "../fixtures/native-local-chat.ts"; import { assertAgentExecutionSucceeded, assertGpuInstallProofs, @@ -246,8 +246,9 @@ test( const chat = await sandbox.execShell( SANDBOX_NAME, trustedSandboxShellScript( - `${NATIVE_LOCAL_AUTH_HEADER_SCRIPT}; curl -sS --max-time 120 '${nativeEndpoint}/chat/completions' -H "$AUTH_HEADER" -H 'Content-Type: application/json' --data '${JSON.stringify( - { + nativeLocalChatCommand( + nativeEndpoint ?? "http://missing-native-local-attachment.invalid/v1", + JSON.stringify({ model, messages: [{ role: "user", content: "Reply with exactly one word: PONG" }], // Keep this assertion about routed inference, not the model's reasoning-token budget. @@ -255,8 +256,9 @@ test( seed: 0, temperature: 0, max_tokens: 32, - }, - )}'`, + }), + "-sS", + ), ), { artifactName: "sandbox-native-ollama-chat", env: env(), timeoutMs: 150_000 }, ); diff --git a/test/e2e/mock-parity.json b/test/e2e/mock-parity.json index 944c8ddccf2..2c8e2653ab3 100644 --- a/test/e2e/mock-parity.json +++ b/test/e2e/mock-parity.json @@ -602,9 +602,11 @@ }, { "live": "test/e2e/live/gpu-double-onboard.test.ts", + "liveSources": ["test/e2e/fixtures/native-local-chat.ts"], "fast": [ "test/e2e/support/e2e-cleanup-resources.test.ts", "test/e2e/support/e2e-clients.test.ts", + "test/e2e/support/gpu-e2e-helpers.test.ts", "test/helpers/e2e-answer-assertions.test.ts" ] }, @@ -612,7 +614,8 @@ "live": "test/e2e/live/gpu-e2e.test.ts", "liveSources": [ "test/e2e/live/gpu-e2e-helpers.ts", - "test/e2e/live/hermes-cli-adapter-live.ts" + "test/e2e/live/hermes-cli-adapter-live.ts", + "test/e2e/fixtures/native-local-chat.ts" ], "fast": [ "src/lib/adapters/config/live-export-source-ollama.test.ts", diff --git a/test/e2e/support/gpu-e2e-helpers.test.ts b/test/e2e/support/gpu-e2e-helpers.test.ts index 3eca30364b1..88c747de3ca 100644 --- a/test/e2e/support/gpu-e2e-helpers.test.ts +++ b/test/e2e/support/gpu-e2e-helpers.test.ts @@ -11,6 +11,7 @@ import path from "node:path"; import { describe, expect, it, vi } from "vitest"; +import { nativeLocalChatCommand } from "../fixtures/native-local-chat.ts"; import { HostCliClient } from "../fixtures/clients/host.ts"; import type { SandboxClient } from "../fixtures/clients/sandbox.ts"; import { CleanupRegistry } from "../fixtures/cleanup.ts"; @@ -854,3 +855,61 @@ describe("GPU E2E helpers", () => { } }); }); + +describe("GPU native local chat command", () => { + const endpointUrl = "http://host.openshell.internal:11435/v1"; + const body = JSON.stringify({ model: GPU_MODEL, messages: [{ role: "user", content: "hi" }] }); + + function runWithRecordingCurl(token: string, curlFlags: "-fsS" | "-sS") { + const root = mkdtempSync(path.join(tmpdir(), "gpu-native-chat-")); + try { + const bin = path.join(root, "bin"); + mkdirSync(bin); + writeShellCommands(bin, [["curl", 'for arg in "$@"; do printf "%s\\n" "$arg"; done\n']]); + try { + const stdout = execFileSync( + "sh", + ["-c", nativeLocalChatCommand(endpointUrl, body, curlFlags)], + { + ...SYNC_E2E_CHILD_OPTIONS, + encoding: "utf8", + env: { + PATH: `${bin}:${process.env.PATH ?? ""}`, + NEMOCLAW_LOCAL_INFERENCE_TOKEN: token, + }, + }, + ); + return { status: 0, args: stdout.split("\n").filter(Boolean) }; + } catch (error) { + return { status: (error as { status?: number }).status, args: [] as string[] }; + } + } finally { + rmSync(root, { recursive: true, force: true }); + } + } + + it("sends the OpenShell-issued handle to the recorded endpoint", () => { + const handle = "openshell:resolve:env:v7_NEMOCLAW_LOCAL_INFERENCE_TOKEN"; + expect(runWithRecordingCurl(handle, "-fsS")).toEqual({ + status: 0, + args: [ + "-fsS", + "--max-time", + "120", + `${endpointUrl}/chat/completions`, + "-H", + `Authorization: Bearer ${handle}`, + "-H", + "Content-Type: application/json", + "--data", + body, + ], + }); + expect(runWithRecordingCurl(handle, "-sS").args[0]).toBe("-sS"); + }); + + it("refuses a raw or missing credential before calling curl", () => { + expect(runWithRecordingCurl("raw-proxy-token-value", "-fsS")).toEqual({ status: 2, args: [] }); + expect(runWithRecordingCurl("", "-fsS")).toEqual({ status: 2, args: [] }); + }); +}); From bed88f901bd024b7895c49156ce1ef5d8fbddde1 Mon Sep 17 00:00:00 2001 From: San Dang Date: Mon, 19 Oct 2026 13:43:54 +0700 Subject: [PATCH 3/8] test(e2e): shell-quote the native chat request arguments The native chat command put the endpoint and JSON body inside literal single quotes. A single quote in request data, such as a model name, would end the argument and run the rest as sandbox shell syntax. Quote both values with the shared shellQuote helper. The new support test fails on the previous command and passes now. Refs #13338. Signed-off-by: San Dang --- test/e2e/fixtures/native-local-chat.ts | 7 ++++--- test/e2e/support/gpu-e2e-helpers.test.ts | 12 ++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/test/e2e/fixtures/native-local-chat.ts b/test/e2e/fixtures/native-local-chat.ts index 0fa4f80ce35..0fd7183e2b3 100644 --- a/test/e2e/fixtures/native-local-chat.ts +++ b/test/e2e/fixtures/native-local-chat.ts @@ -2,17 +2,18 @@ // SPDX-License-Identifier: Apache-2.0 import { NATIVE_LOCAL_AUTH_HEADER_SCRIPT } from "../../../src/lib/inference/native-local/agent-config.ts"; +import { shellQuote } from "./clients/command.ts"; /** * Sandbox shell command for a chat request to a sandbox-owned native local provider (#13293). * The auth script accepts only the credential handle that OpenShell issues, so the raw local - * credential never enters the request. Callers pass a recorded endpoint and a JSON body without - * single quotes. + * credential never enters the request. The endpoint and body are shell-quoted, so request data + * stays one curl argument. */ export function nativeLocalChatCommand( endpointUrl: string, body: string, curlFlags: "-fsS" | "-sS", ): string { - return `${NATIVE_LOCAL_AUTH_HEADER_SCRIPT}; curl ${curlFlags} --max-time 120 '${endpointUrl}/chat/completions' -H "$AUTH_HEADER" -H 'Content-Type: application/json' --data '${body}'`; + return `${NATIVE_LOCAL_AUTH_HEADER_SCRIPT}; curl ${curlFlags} --max-time 120 ${shellQuote(`${endpointUrl}/chat/completions`)} -H "$AUTH_HEADER" -H 'Content-Type: application/json' --data ${shellQuote(body)}`; } diff --git a/test/e2e/support/gpu-e2e-helpers.test.ts b/test/e2e/support/gpu-e2e-helpers.test.ts index 88c747de3ca..8ce1227225b 100644 --- a/test/e2e/support/gpu-e2e-helpers.test.ts +++ b/test/e2e/support/gpu-e2e-helpers.test.ts @@ -860,7 +860,7 @@ describe("GPU native local chat command", () => { const endpointUrl = "http://host.openshell.internal:11435/v1"; const body = JSON.stringify({ model: GPU_MODEL, messages: [{ role: "user", content: "hi" }] }); - function runWithRecordingCurl(token: string, curlFlags: "-fsS" | "-sS") { + function runWithRecordingCurl(token: string, curlFlags: "-fsS" | "-sS", requestBody = body) { const root = mkdtempSync(path.join(tmpdir(), "gpu-native-chat-")); try { const bin = path.join(root, "bin"); @@ -869,7 +869,7 @@ describe("GPU native local chat command", () => { try { const stdout = execFileSync( "sh", - ["-c", nativeLocalChatCommand(endpointUrl, body, curlFlags)], + ["-c", nativeLocalChatCommand(endpointUrl, requestBody, curlFlags)], { ...SYNC_E2E_CHILD_OPTIONS, encoding: "utf8", @@ -912,4 +912,12 @@ describe("GPU native local chat command", () => { expect(runWithRecordingCurl("raw-proxy-token-value", "-fsS")).toEqual({ status: 2, args: [] }); expect(runWithRecordingCurl("", "-fsS")).toEqual({ status: 2, args: [] }); }); + + it("keeps request data with shell syntax as one curl argument", () => { + const handle = "openshell:resolve:env:v7_NEMOCLAW_LOCAL_INFERENCE_TOKEN"; + const hostileBody = JSON.stringify({ model: "x'; echo injected; '$(echo also)", messages: [] }); + const result = runWithRecordingCurl(handle, "-fsS", hostileBody); + expect(result.status).toBe(0); + expect(result.args.slice(-2)).toEqual(["--data", hostileBody]); + }); }); From 26943f1cdd28733476d13c29c1aa1b0035f24621 Mon Sep 17 00:00:00 2001 From: San Dang Date: Mon, 19 Oct 2026 14:21:36 +0700 Subject: [PATCH 4/8] fix(inference): keep native local probes on the recorded provider Status, connect, and start health checks omitted the agent for OpenClaw native local sandboxes. The request builder then fell back to the shared inference.local route, which OpenShell answers with HTTP 503 when no shared route is configured, while status displayed the native endpoint. Use the agent recorded on the native local attachment when the caller omits it, reject a contradicting agent or an attachment that would not select its recorded endpoint before sending a request, pass the registry agent from status and readiness health, and report the endpoint that was requested. Refs #13338 Signed-off-by: San Dang --- src/lib/actions/sandbox/connect.ts | 13 +- .../inference-invocation-probe.test.ts | 128 ++++++++++++++++++ .../sandbox/inference-invocation-probe.ts | 28 +++- .../actions/sandbox/inference-route-health.ts | 19 ++- .../launch-readiness-gateway-health.test.ts | 91 +++++++++++++ .../sandbox/launch-readiness/health.ts | 2 +- .../status-snapshot-inference-health.test.ts | 54 ++++++++ src/lib/actions/sandbox/status-snapshot.ts | 7 +- test/helpers/native-local-probe-shell.ts | 83 ++++++++++++ 9 files changed, 413 insertions(+), 12 deletions(-) create mode 100644 test/helpers/native-local-probe-shell.ts diff --git a/src/lib/actions/sandbox/connect.ts b/src/lib/actions/sandbox/connect.ts index 5a3c4d274a9..5f6fcc1cd6f 100644 --- a/src/lib/actions/sandbox/connect.ts +++ b/src/lib/actions/sandbox/connect.ts @@ -1606,11 +1606,16 @@ function printUnrecoverableInferenceRoute( sandboxName: string, route: string, detail: string, - { repairAttempted = true }: { repairAttempted?: boolean } = {}, + { + repairAttempted = true, + nativeProvider = false, + }: { repairAttempted?: boolean; nativeProvider?: boolean } = {}, ): void { const reason = repairAttempted ? `inference.local is still unavailable inside '${sandboxName}' after DNS and route repair.` - : `the authoritative inference.local probe inside '${sandboxName}' did not return a trusted result.`; + : nativeProvider + ? `the attached native provider inference probe inside '${sandboxName}' did not return a trusted result.` + : `the authoritative inference.local probe inside '${sandboxName}' did not return a trusted result.`; const boundedDetail = sanitizeRouteValueForDisplay(redact(detail)) .replace(/\s+/g, " ") .trim() @@ -1708,6 +1713,7 @@ async function ensureSandboxInferenceRouteUnlocked( ): Promise { let sb: SandboxEntry | null = null; let inference: ReturnType | null = null; + let nativeProvider = false; try { sb = readConnectSandbox(sandboxName); if (!sb) return { sandbox: null, routeHealthy: null }; @@ -1719,6 +1725,7 @@ async function ensureSandboxInferenceRouteUnlocked( const gatewayName = getPersistedSandboxTargetGatewayName(sb); const nativeAttachment = getNativeProviderAttachment(sb); if (nativeAttachment || sb.nativeLocalProviderAttachment !== undefined) { + nativeProvider = true; await requireNativeInferenceHealth({ sandboxName, gatewayName, @@ -1863,7 +1870,7 @@ async function ensureSandboxInferenceRouteUnlocked( sandboxName, `${sanitizeRouteValueForDisplay(inference.provider)}/${sanitizeRouteValueForDisplay(inference.model)}`, detail, - { repairAttempted: false }, + { repairAttempted: false, nativeProvider }, ); } return { sandbox: sb, routeHealthy: false }; diff --git a/src/lib/actions/sandbox/inference-invocation-probe.test.ts b/src/lib/actions/sandbox/inference-invocation-probe.test.ts index d4b028e5e50..f2537eea898 100644 --- a/src/lib/actions/sandbox/inference-invocation-probe.test.ts +++ b/src/lib/actions/sandbox/inference-invocation-probe.test.ts @@ -27,6 +27,11 @@ import { READINESS_INFERENCE_INVOCATION_TIMEOUT_MS, type SandboxInferenceInvocationInput, } from "./inference-invocation-probe"; +import { + NATIVE_LOCAL_CREDENTIAL_HANDLE, + nativeLocalReceipt, + recordingProbeShell, +} from "../../../../test/helpers/native-local-probe-shell"; const input = { sandboxName: "dcode-workspace", @@ -977,3 +982,126 @@ it.each([true, undefined])( ).toEqual({ ok: true }); }, ); + +describe("OpenClaw native local probe routing (#13338)", () => { + const PROVIDERS = [ + ["vllm-local", "http://host.openshell.internal:18000/v1"], + ["llama-cpp-local", "http://host.openshell.internal:8081/v1"], + ["ollama-local", "http://host.openshell.internal:11435/v1"], + ] as const; + const okBody = '{"choices":[{"message":{"content":"OK"}}]}'; + + function openClawInput( + provider: (typeof PROVIDERS)[number][0], + endpointUrl: string, + agentName: string | null | undefined, + agent: "openclaw" | null = "openclaw", + ): SandboxInferenceInvocationInput { + return { + sandboxName: "alpha", + gatewayName: "nemoclaw", + ...(agentName === undefined ? {} : { agentName }), + provider, + model: "local-model", + preferredInferenceApi: "openai-completions", + nativeLocalProviderAttachment: nativeLocalReceipt({ + provider, + ...(agent ? { agent } : {}), + endpointUrl, + credentialEnv: "NEMOCLAW_LOCAL_INFERENCE_TOKEN", + authMode: "authenticated", + gatewayName: "nemoclaw", + sandboxName: "alpha", + }), + }; + } + + it.each( + PROVIDERS.flatMap(([provider, endpointUrl]) => + [undefined, null, "openclaw"].map((agentName) => ({ provider, endpointUrl, agentName })), + ), + )( + "sends $provider to the recorded endpoint when agentName is $agentName", + async ({ provider, endpointUrl, agentName }) => { + const selected = openClawInput(provider, endpointUrl, agentName); + const shell = recordingProbeShell("200", okBody); + await expect( + probeSandboxInferenceInvocation(selected, { execute: shell.execute }), + ).resolves.toEqual({ ok: true }); + expect(shell.destinations()).toEqual([`${endpointUrl}/chat/completions`]); + expect(shell.requests[0]).toContain( + `Authorization: Bearer ${NATIVE_LOCAL_CREDENTIAL_HANDLE}`, + ); + expect(shell.requests[0].join("\n")).not.toContain("inference.local"); + }, + ); + + it("reports the endpoint that actually failed", async () => { + const [provider, endpointUrl] = PROVIDERS[0]; + const shell = recordingProbeShell("503"); + const result = await probeSandboxInferenceInvocation( + openClawInput(provider, endpointUrl, null), + { + execute: shell.execute, + }, + ); + expect(result).toMatchObject({ ok: false, httpStatus: 503 }); + assert(!result.ok); + expect(result.endpoint).toBe(shell.destinations()[0]); + expect(result.endpoint).toBe(`${endpointUrl}/chat/completions`); + }); + + it.each([ + { name: "a different supplied agent", agentName: "hermes", agent: "openclaw" as const }, + { name: "an untagged attachment without an agent", agentName: undefined, agent: null }, + ])("rejects $name before sending a request", async ({ agentName, agent }) => { + const [provider, endpointUrl] = PROVIDERS[1]; + const selected = openClawInput(provider, endpointUrl, agentName, agent); + const shell = recordingProbeShell("200", okBody); + expect(() => buildSandboxInferenceInvocationCommand(selected)).toThrow(/native local/i); + await expect( + probeSandboxInferenceInvocation(selected, { execute: shell.execute }), + ).rejects.toThrow(/native local/i); + expect(shell.requests).toEqual([]); + }); + + it("refuses a raw credential before calling curl", async () => { + const [provider, endpointUrl] = PROVIDERS[2]; + const shell = recordingProbeShell("200", okBody, { + NEMOCLAW_LOCAL_INFERENCE_TOKEN: "raw-local-secret", + }); + const result = await probeSandboxInferenceInvocation( + openClawInput(provider, endpointUrl, null), + { + execute: shell.execute, + }, + ); + expect(result.ok).toBe(false); + expect(shell.requests).toEqual([]); + }); + + it.each([ + ["ollama-local", undefined], + ["ollama-local", "openclaw"], + ["vllm-local", "openclaw"], + ] as const)( + "keeps a %s selection without native authority (agent %s) on the shared route", + async (provider, agentName) => { + const shell = recordingProbeShell("200", okBody, {}); + await expect( + probeSandboxInferenceInvocation( + { + sandboxName: "alpha", + ...(agentName ? { agentName } : {}), + provider, + model: "local-model", + preferredInferenceApi: "openai-completions", + }, + { execute: shell.execute }, + ), + ).resolves.toEqual({ ok: true }); + expect(shell.destinations()).toEqual(["https://inference.local/v1/chat/completions"]); + expect(shell.requests[0].join("\n")).not.toContain("Authorization"); + }, + ); +}); diff --git a/src/lib/actions/sandbox/inference-invocation-probe.ts b/src/lib/actions/sandbox/inference-invocation-probe.ts index 3577a75280b..9f5c397e540 100644 --- a/src/lib/actions/sandbox/inference-invocation-probe.ts +++ b/src/lib/actions/sandbox/inference-invocation-probe.ts @@ -109,6 +109,22 @@ function nativeProbeDefinition(input: SandboxInferenceInvocationInput) { return hostedNativeProvider(input.provider, input.nativeEndpointUrl); } +/** + * A native local attachment records the agent that owns it. Callers that omit + * the agent, such as OpenClaw's legacy null session agent, use that recorded + * agent. A supplied agent that contradicts it is rejected before any request. + */ +function probeAgentName( + input: SandboxInferenceInvocationInput, + local: NativeLocalProviderAttachment | undefined, +): string | null | undefined { + if (!local) return input.agentName; + const supplied = input.agentName ?? undefined; + if (local.agent && supplied && supplied !== local.agent) + throw new Error("Native local inference probe agent does not match the recorded attachment."); + return supplied ?? local.agent; +} + /** Build the protocol-specific request used to verify sandbox inference. */ function buildProbeRequest(input: SandboxInferenceInvocationInput): { endpoint: string; @@ -130,8 +146,11 @@ function buildProbeRequest(input: SandboxInferenceInvocationInput): { input.preferredInferenceApi, input.nativeProvider ?? Boolean(local), local?.endpointUrl ?? input.nativeEndpointUrl ?? null, - input.agentName, + probeAgentName(input, local), ); + // A native local attachment never falls back to the shared inference.local route. + if (local && config.inferenceBaseUrl !== local.endpointUrl) + throw new Error("Native local inference probe has no agent that owns the recorded attachment."); const useNativeNvidia = input.nativeProvider === true && isNativeNvidiaProvider(input.provider); const hosted = nativeProbeDefinition(input); const nativeHosted = input.nativeProvider === true ? hosted : undefined; @@ -331,15 +350,14 @@ export async function probeSandboxInferenceInvocation( const statusText = (separator >= 0 ? result.stdout.slice(0, separator) : result.stdout).trim(); const httpStatus = /^2\d\d$/.test(statusText) ? Number.parseInt(statusText, 10) : null; const body = separator >= 0 ? result.stdout.slice(separator + 1) : ""; + const local = normalizeNativeLocalProviderAttachment(input.nativeLocalProviderAttachment); const inferenceApi = getSandboxInferenceConfig( input.model, input.provider, input.preferredInferenceApi, input.nativeProvider ?? Boolean(input.nativeLocalProviderAttachment), - normalizeNativeLocalProviderAttachment(input.nativeLocalProviderAttachment)?.endpointUrl ?? - input.nativeEndpointUrl ?? - null, - input.agentName, + local?.endpointUrl ?? input.nativeEndpointUrl ?? null, + probeAgentName(input, local), ).inferenceApi; if (httpStatus !== null && validateInferenceResponseBody(inferenceApi, body).ok) { return { ok: true }; diff --git a/src/lib/actions/sandbox/inference-route-health.ts b/src/lib/actions/sandbox/inference-route-health.ts index d9fe85ddecf..34fc1d36c7f 100644 --- a/src/lib/actions/sandbox/inference-route-health.ts +++ b/src/lib/actions/sandbox/inference-route-health.ts @@ -438,7 +438,11 @@ export function buildSandboxInferenceRouteHealth( ok: invocation?.ok === true, probed: invocation !== null, providerLabel: "Native local inference", - endpoint: `${context.nativeLocalEndpoint}/chat/completions`, + // Report the request that actually failed, not only the recorded label. + endpoint: + invocation && !invocation.ok && invocation.endpoint + ? invocation.endpoint + : `${context.nativeLocalEndpoint}/chat/completions`, detail: invocation?.ok ? "The attached provider served a native local inference request." : invocation @@ -569,11 +573,22 @@ export async function runSandboxInferenceInvocationProbe( // An abnormal probe still failed against the selected API family's path. // Without this the row falls back to the models route and misdirects // recovery to a request that never ran (#10879). - endpoint: resolveSandboxInferenceInvocationEndpoint(input), + ...attemptedInvocationEndpoint(input), }; } } +// A probe rejected before building its request has no attempted endpoint. +function attemptedInvocationEndpoint(input: SandboxInferenceInvocationInput): { + endpoint?: string; +} { + try { + return { endpoint: resolveSandboxInferenceInvocationEndpoint(input) }; + } catch { + return {}; + } +} + export function readNativeStatusSelection(entry: SandboxEntry | null | undefined) { let attachment: NativeProviderAttachment | undefined; let failure: string | null = null; diff --git a/src/lib/actions/sandbox/launch-readiness-gateway-health.test.ts b/src/lib/actions/sandbox/launch-readiness-gateway-health.test.ts index fcd20301d5f..50a76e28522 100644 --- a/src/lib/actions/sandbox/launch-readiness-gateway-health.test.ts +++ b/src/lib/actions/sandbox/launch-readiness-gateway-health.test.ts @@ -16,6 +16,13 @@ import { requireNativeInferenceHealth, type LaunchReadinessHealthDeps, } from "./launch-readiness/health"; +import { probeSandboxInferenceInvocation } from "./inference-invocation-probe"; +import { runSandboxInferenceInvocationProbe } from "./inference-route-health"; +import { + NATIVE_LOCAL_CREDENTIAL_HANDLE, + nativeLocalReceipt, + recordingProbeShell, +} from "../../../../test/helpers/native-local-probe-shell"; import { isSandboxGatewayRunningForStatus, waitForStartedHermesGatewayProcess, @@ -448,3 +455,87 @@ describe("Hermes native-local readiness authority", () => { ); }); }); + +describe("OpenClaw native-local readiness identity (#13338)", () => { + it.each([ + { agentName: undefined, agent: "openclaw" }, + { agentName: undefined, agent: undefined }, + { agentName: "openclaw", agent: "openclaw" }, + ])( + "sends the health request to the recorded endpoint (selected $agentName, recorded $agent)", + async ({ agentName, agent }) => { + const receipt = nativeLocalReceipt({ + provider: "llama-cpp-local", + agent: "openclaw", + endpointUrl: "http://host.openshell.internal:8081/v1", + credentialEnv: "NEMOCLAW_LOCAL_INFERENCE_TOKEN", + authMode: "authenticated", + gatewayName: "selected", + sandboxName: "alpha", + }); + const shell = recordingProbeShell("200", '{"choices":[{"message":{"content":"OK"}}]}'); + await expect( + requireNativeInferenceHealth({ + sandboxName: "alpha", + gatewayName: "selected", + ...(agentName ? { agentName } : {}), + entry: { + name: "alpha", + ...(agent ? { agent } : {}), + provider: "llama-cpp-local", + model: "local-model", + nativeLocalProviderAttachment: receipt, + }, + deps: { + verifyNativeLocalAttachment: vi.fn(async () => {}), + inferenceInvocationProbe: (input) => + runSandboxInferenceInvocationProbe(input, (selected, _deps, timeoutMs) => + probeSandboxInferenceInvocation(selected, { execute: shell.execute }, timeoutMs), + ), + }, + }), + ).resolves.toBe(true); + expect(shell.destinations()).toEqual([ + "http://host.openshell.internal:8081/v1/chat/completions", + ]); + expect(shell.requests[0]).toContain( + `Authorization: Bearer ${NATIVE_LOCAL_CREDENTIAL_HANDLE}`, + ); + }, + ); + + it("rejects a selected agent that contradicts the recorded attachment before any request", async () => { + const receipt = nativeLocalReceipt({ + provider: "llama-cpp-local", + agent: "openclaw", + endpointUrl: "http://host.openshell.internal:8081/v1", + credentialEnv: "NEMOCLAW_LOCAL_INFERENCE_TOKEN", + authMode: "authenticated", + gatewayName: "selected", + sandboxName: "alpha", + }); + const shell = recordingProbeShell("200", '{"choices":[{"message":{"content":"OK"}}]}'); + await expect( + requireNativeInferenceHealth({ + sandboxName: "alpha", + gatewayName: "selected", + agentName: "pi", + entry: { + name: "alpha", + agent: "pi", + provider: "llama-cpp-local", + model: "local-model", + nativeLocalProviderAttachment: receipt, + }, + deps: { + verifyNativeLocalAttachment: vi.fn(async () => {}), + inferenceInvocationProbe: (input) => + runSandboxInferenceInvocationProbe(input, (selected, _deps, timeoutMs) => + probeSandboxInferenceInvocation(selected, { execute: shell.execute }, timeoutMs), + ), + }, + }), + ).rejects.toBeInstanceOf(LaunchReadinessObservationError); + expect(shell.requests).toEqual([]); + }); +}); diff --git a/src/lib/actions/sandbox/launch-readiness/health.ts b/src/lib/actions/sandbox/launch-readiness/health.ts index c583574a6f4..14308619368 100644 --- a/src/lib/actions/sandbox/launch-readiness/health.ts +++ b/src/lib/actions/sandbox/launch-readiness/health.ts @@ -250,7 +250,7 @@ export async function requireNativeInferenceHealth(input: { )({ sandboxName: input.sandboxName, gatewayName: input.gatewayName, - agentName: input.agentName, + agentName: input.agentName ?? input.entry.agent ?? undefined, provider: expected.provider, model: input.entry.model, preferredInferenceApi: "openai-completions", diff --git a/src/lib/actions/sandbox/status-snapshot-inference-health.test.ts b/src/lib/actions/sandbox/status-snapshot-inference-health.test.ts index b00f917e64e..95a1cc5d938 100644 --- a/src/lib/actions/sandbox/status-snapshot-inference-health.test.ts +++ b/src/lib/actions/sandbox/status-snapshot-inference-health.test.ts @@ -9,6 +9,11 @@ import type { SandboxEntry } from "../../state/registry"; import type { SandboxInferenceInvocationResult } from "./inference-invocation-probe"; import type { SandboxInferenceRouteHealth } from "./inference-route-health"; import { collectSandboxStatusSnapshot } from "./status-snapshot"; +import { probeSandboxInferenceInvocation } from "./inference-invocation-probe"; +import { + nativeLocalReceipt, + recordingProbeShell, +} from "../../../../test/helpers/native-local-probe-shell"; // Direct, unmocked coverage of `buildSandboxInferenceRouteHealth` through the // exported `collectSandboxStatusSnapshot` entry point (it is not itself @@ -1158,3 +1163,52 @@ describe("collectSandboxStatusSnapshot inference route health", () => { expect(snapshot.inferenceHealth).toMatchObject({ ok: false, failureLabel: "unhealthy" }); }); }); + +describe("status native local request identity (#13338)", () => { + it.each(["openclaw", undefined] as const)( + "probes and reports the recorded OpenClaw endpoint when the registry agent is %s", + async (agent) => { + const receipt = nativeLocalReceipt({ + provider: "vllm-local", + agent: "openclaw", + endpointUrl: "http://host.openshell.internal:18000/v1", + credentialEnv: "NEMOCLAW_LOCAL_INFERENCE_TOKEN", + authMode: "sentinel", + gatewayName: "nemoclaw", + sandboxName: "alpha", + }); + const options = snapshotDeps( + null, + null, + { ok: true }, + { + agent, + provider: "vllm-local", + model: "local-model", + gatewayName: "nemoclaw", + nativeLocalProviderAttachment: receipt, + }, + ); + const shell = recordingProbeShell("503"); + const snapshot = await collectSandboxStatusSnapshot("alpha", { + ...options, + deps: { + ...options.deps, + inferenceRouteObserver: { observeInferenceRoute: vi.fn() }, + verifyNativeLocalProviderAttachmentImpl: async () => undefined, + probeSandboxInferenceInvocationImpl: (input, _deps, timeoutMs) => + probeSandboxInferenceInvocation(input, { execute: shell.execute }, timeoutMs), + delayInferenceRecoveryProbe: async () => undefined, + }, + }); + expect(shell.destinations().length).toBeGreaterThan(0); + expect(new Set(shell.destinations())).toEqual( + new Set(["http://host.openshell.internal:18000/v1/chat/completions"]), + ); + expect(snapshot.inferenceHealth).toMatchObject({ + ok: false, + endpoint: shell.destinations()[0], + }); + }, + ); +}); diff --git a/src/lib/actions/sandbox/status-snapshot.ts b/src/lib/actions/sandbox/status-snapshot.ts index 95197f7cd5a..df181653804 100644 --- a/src/lib/actions/sandbox/status-snapshot.ts +++ b/src/lib/actions/sandbox/status-snapshot.ts @@ -768,7 +768,12 @@ export async function collectSandboxStatusSnapshot( { sandboxName, gatewayName: gatewayName ?? undefined, - ...(sb?.agent === "langchain-deepagents-code" ? { agentName: sb.agent } : {}), + // A native local request keeps the recorded agent identity. + ...(sb?.agent && + (sb.agent === "langchain-deepagents-code" || + sb.nativeLocalProviderAttachment !== undefined) + ? { agentName: sb.agent } + : {}), provider: invocationProvider, model: invocationModel, preferredInferenceApi: invocationRoute.preferredInferenceApi, diff --git a/test/helpers/native-local-probe-shell.ts b/test/helpers/native-local-probe-shell.ts new file mode 100644 index 00000000000..d3003befcc7 --- /dev/null +++ b/test/helpers/native-local-probe-shell.ts @@ -0,0 +1,83 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { spawnSync } from "node:child_process"; +import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import path from "node:path"; + +import { + nativeLocalIdentity, + type NativeLocalBinding, + type NativeLocalProviderAttachment, +} from "../../src/lib/inference/native-local/contract"; +import type { SandboxInferenceInvocationDeps } from "../../src/lib/actions/sandbox/inference-invocation-probe"; + +/** The shape OpenShell issues for an attached native local provider credential. */ +export const NATIVE_LOCAL_CREDENTIAL_HANDLE = + "openshell:resolve:env:v7_NEMOCLAW_LOCAL_INFERENCE_TOKEN"; + +export function nativeLocalReceipt(binding: NativeLocalBinding): NativeLocalProviderAttachment { + return { + ...binding, + ...nativeLocalIdentity(binding), + schemaVersion: 1, + providerId: "fixture-local-provider", + }; +} + +/** + * Run each generated probe command in a real shell whose curl records its + * arguments and answers with a fixed HTTP status and body. The recorded + * arguments show the actual request destination and headers. + */ +export function recordingProbeShell( + code: string, + body = "", + environment: NodeJS.ProcessEnv = { + NEMOCLAW_LOCAL_INFERENCE_TOKEN: NATIVE_LOCAL_CREDENTIAL_HANDLE, + }, +) { + const requests: string[][] = []; + const execute: NonNullable = async ( + _sandboxName, + command, + ) => { + const dir = mkdtempSync(path.join(tmpdir(), "nemoclaw-probe-route-")); + try { + const bin = path.join(dir, "bin"); + const argv = path.join(dir, "argv.txt"); + mkdirSync(bin); + writeFileSync(path.join(dir, "body.txt"), body); + writeFileSync( + path.join(bin, "curl"), + [ + "#!/bin/sh", + `printf '%s\\n' "$@" > ${JSON.stringify(argv)}`, + 'out=""; prev=""', + 'for a in "$@"; do [ "$prev" = "-o" ] && out="$a"; prev="$a"; done', + `cat ${JSON.stringify(path.join(dir, "body.txt"))} > "$out"`, + `printf '%s' ${JSON.stringify(code)}`, + ].join("\n"), + { mode: 0o755 }, + ); + const run = spawnSync("/bin/sh", ["-c", command], { + encoding: "utf8", + env: { PATH: `${bin}:${process.env.PATH ?? ""}`, ...environment }, + }); + try { + requests.push(readFileSync(argv, "utf8").trimEnd().split("\n")); + } catch { + /* curl was not reached */ + } + return { status: run.status ?? 1, stdout: run.stdout ?? "", stderr: run.stderr ?? "" }; + } finally { + rmSync(dir, { recursive: true, force: true }); + } + }; + return { + execute, + requests, + destinations: () => requests.map((argv) => argv.at(-1)), + }; +} From f98bff81e9f624563aeec8bb21aa201d6e7ab426 Mon Sep 17 00:00:00 2001 From: San Dang Date: Mon, 19 Oct 2026 14:58:14 +0700 Subject: [PATCH 5/8] test(e2e): select GPU targets for the native chat fixture Changes to the shared native-local chat fixture now select gpu-e2e and gpu-double-onboard. The platform matrix now says that new OpenClaw Ollama, vLLM, and llama.cpp selections use sandbox-attached providers. Refs #13338 Signed-off-by: San Dang --- ci/platform-matrix.json | 2 +- docs/reference/platform-support.mdx | 2 +- test/e2e/support/workflow-plan.test.ts | 12 ++++++++++++ tools/e2e/target-catalogue.mts | 2 ++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ci/platform-matrix.json b/ci/platform-matrix.json index cc84f687305..43e548bb33e 100644 --- a/ci/platform-matrix.json +++ b/ci/platform-matrix.json @@ -208,7 +208,7 @@ { "name": "Managed inference", "status": "tested", - "notes": "Provider-routed model calls through OpenShell, transparent to the agent. NVIDIA Endpoints and supported fixed hosted providers use native endpoints through sandbox-attached OpenShell providers. New Deep Agents Code selections of Ollama, standalone vLLM, llama.cpp, and qualifying local compatible endpoints use sandbox-attached providers for their qualified host-local endpoints. Hermes implements the same attachment path, with live qualification for its new local lifecycle pending. OpenClaw, Pi, owned Local NVIDIA NIM, and other custom or local selections retain the shared `inference.local` route. OpenShell keeps provider credentials outside the sandbox. Supports every entry in the Providers table." + "notes": "Provider-routed model calls through OpenShell, transparent to the agent. NVIDIA Endpoints and supported fixed hosted providers use native endpoints through sandbox-attached OpenShell providers. New Deep Agents Code selections of Ollama, standalone vLLM, llama.cpp, and qualifying local compatible endpoints use sandbox-attached providers for their qualified host-local endpoints. Hermes implements the same attachment path, with live qualification for its new local lifecycle pending. New OpenClaw selections of Ollama, standalone vLLM, and llama.cpp also use sandbox-attached providers, and their `status`, `connect`, and `start` health checks send requests to the recorded provider endpoint. Earlier OpenClaw sandboxes without a sandbox-attached provider, Pi, owned Local NVIDIA NIM, and other custom or local selections retain the shared `inference.local` route. OpenShell keeps provider credentials outside the sandbox. Supports every entry in the Providers table." }, { "name": "Declarative network policy", diff --git a/docs/reference/platform-support.mdx b/docs/reference/platform-support.mdx index 43fef04e495..434c76ff542 100644 --- a/docs/reference/platform-support.mdx +++ b/docs/reference/platform-support.mdx @@ -135,7 +135,7 @@ Each row below is a launch-facing capability claim that NemoClaw makes in docs, |------------|--------|-------| | Guided onboarding | Tested | Single-command interactive wizard (`$$nemoclaw onboard`) that walks the user through inference provider selection, credential setup, and sandbox creation or update. It opens the agent dashboard when the selected runtime provides one. Non-interactive mode is supported with `--non-interactive` and `NEMOCLAW_*` environment variables for CI and scripted installs. | | Sandboxed execution | Tested with limitations | Landlock, seccomp, network namespace isolation, no-new-privileges, privilege dropping, and process limits (nproc 512 at `scripts/lib/sandbox-rlimits.sh:8`) are tested and on by default. OpenShell owns capability enforcement for managed entrypoints, exec processes, and connect shells; those paths do not call NemoClaw capability handling. Direct container runtimes that explicitly override the image user to root retain the existing compatibility drop and required `setpriv` transition. Direct container launches must configure capabilities at the container runtime. | -| Managed inference | Tested | Provider-routed model calls through OpenShell, transparent to the agent. NVIDIA Endpoints and supported fixed hosted providers use native endpoints through sandbox-attached OpenShell providers. New Deep Agents Code selections of Ollama, standalone vLLM, llama.cpp, and qualifying local compatible endpoints use sandbox-attached providers for their qualified host-local endpoints. Hermes implements the same attachment path, with live qualification for its new local lifecycle pending. OpenClaw, Pi, owned Local NVIDIA NIM, and other custom or local selections retain the shared `inference.local` route. OpenShell keeps provider credentials outside the sandbox. Supports every entry in the Providers table. | +| Managed inference | Tested | Provider-routed model calls through OpenShell, transparent to the agent. NVIDIA Endpoints and supported fixed hosted providers use native endpoints through sandbox-attached OpenShell providers. New Deep Agents Code selections of Ollama, standalone vLLM, llama.cpp, and qualifying local compatible endpoints use sandbox-attached providers for their qualified host-local endpoints. Hermes implements the same attachment path, with live qualification for its new local lifecycle pending. New OpenClaw selections of Ollama, standalone vLLM, and llama.cpp also use sandbox-attached providers, and their `status`, `connect`, and `start` health checks send requests to the recorded provider endpoint. Earlier OpenClaw sandboxes without a sandbox-attached provider, Pi, owned Local NVIDIA NIM, and other custom or local selections retain the shared `inference.local` route. OpenShell keeps provider credentials outside the sandbox. Supports every entry in the Providers table. | | Declarative network policy | Tested | YAML-defined egress with policy presets. Presets include `slack`, `discord`, `telegram`, `weather`, `openclaw-pricing`, `huggingface`, `npm`, `pypi`, `brew`, and others. Hot-reloadable at runtime with `$$nemoclaw policy add`. | | State persistence and rebuild transfer | Tested | OpenShell preserves the native agent home during routine lifecycle operations. Before destructive replacement, NemoClaw archives and integrity-checks the complete native home/workspace, then restores it into the replacement sandbox. | | Agent skills | Tested | Packaged agent skills are discoverable by Cursor, Claude Code, and other coding assistants under `.agents/skills/`. Skills also install into the sandbox with `$$nemoclaw skill install`. | diff --git a/test/e2e/support/workflow-plan.test.ts b/test/e2e/support/workflow-plan.test.ts index 3b739488ea3..60273f28ed8 100644 --- a/test/e2e/support/workflow-plan.test.ts +++ b/test/e2e/support/workflow-plan.test.ts @@ -696,6 +696,18 @@ describe("E2E workflow plan", () => { expect(selectedWorkflowJobs(plan)).toEqual(["catalogue-standard", "jetson-nvmap-gpu"]); }); + it("selects both GPU native-provider consumers when their chat fixture changes", () => { + const changedFile = "test/e2e/fixtures/native-local-chat.ts"; + const plan = buildE2eWorkflowPlan({}, { changedFiles: [changedFile] }); + + expect(catalogueTargetsForChangedFiles([changedFile]).map((target) => target.id)).toEqual( + expect.arrayContaining(["gpu-double-onboard", "gpu-e2e"]), + ); + expect(plan.catalogueMatrices.standard.map((row) => row.id)).toEqual( + expect.arrayContaining(["gpu-double-onboard", "gpu-e2e"]), + ); + }); + it("selects Hermes GPU startup when its output proof changes", () => { const plan = buildE2eWorkflowPlan( {}, diff --git a/tools/e2e/target-catalogue.mts b/tools/e2e/target-catalogue.mts index 894ea84cd39..35651d84de3 100644 --- a/tools/e2e/target-catalogue.mts +++ b/tools/e2e/target-catalogue.mts @@ -816,6 +816,7 @@ export const E2E_TARGET_CATALOGUE: readonly E2eCatalogueTarget[] = [ installMode: "authenticated", restoreCli: true, exposeCliBin: true, + owningPaths: ["test/e2e/fixtures/native-local-chat.ts"], environment: { ...nonInteractive, NEMOCLAW_MODEL: "qwen3.5:9b", @@ -836,6 +837,7 @@ export const E2E_TARGET_CATALOGUE: readonly E2eCatalogueTarget[] = [ exposeCliBin: true, owningPaths: [ "test/e2e/live/gpu-e2e-helpers.ts", + "test/e2e/fixtures/native-local-chat.ts", "test/e2e/live/hermes-cli-adapter-live.ts", "src/lib/inference/ollama/proxy.ts", "src/lib/inference/ollama/proxy-observation.ts", From 80b30c80878498e425d55020b4c452192efc14c2 Mon Sep 17 00:00:00 2001 From: San Dang Date: Mon, 19 Oct 2026 15:52:18 +0700 Subject: [PATCH 6/8] test(e2e): select native OpenClaw E2E for its probe controls Changes to connect, status, readiness health, and the inference probe now select inference-routing-openclaw-native, which exercises the native local start, rebuild, restart, and isolation path. Refs #13338 Signed-off-by: San Dang --- test/e2e/support/workflow-plan.test.ts | 22 ++++++++++++++-------- tools/e2e/target-catalogue.mts | 5 +++++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/test/e2e/support/workflow-plan.test.ts b/test/e2e/support/workflow-plan.test.ts index 60273f28ed8..661e4f6e08c 100644 --- a/test/e2e/support/workflow-plan.test.ts +++ b/test/e2e/support/workflow-plan.test.ts @@ -696,15 +696,21 @@ describe("E2E workflow plan", () => { expect(selectedWorkflowJobs(plan)).toEqual(["catalogue-standard", "jetson-nvmap-gpu"]); }); - it("selects both GPU native-provider consumers when their chat fixture changes", () => { - const changedFile = "test/e2e/fixtures/native-local-chat.ts"; - const plan = buildE2eWorkflowPlan({}, { changedFiles: [changedFile] }); - + it.each<[string, string[]]>([ + ["test/e2e/fixtures/native-local-chat.ts", ["gpu-double-onboard", "gpu-e2e"]], + ...[ + "connect.ts", + "inference-invocation-probe.ts", + "inference-route-health.ts", + "launch-readiness/health.ts", + "status-snapshot.ts", + ].map((file): [string, string[]] => [ + `src/lib/actions/sandbox/${file}`, + ["inference-routing-openclaw-native"], + ]), + ])("selects the live owners of %s", (changedFile, targets) => { expect(catalogueTargetsForChangedFiles([changedFile]).map((target) => target.id)).toEqual( - expect.arrayContaining(["gpu-double-onboard", "gpu-e2e"]), - ); - expect(plan.catalogueMatrices.standard.map((row) => row.id)).toEqual( - expect.arrayContaining(["gpu-double-onboard", "gpu-e2e"]), + expect.arrayContaining(targets), ); }); diff --git a/tools/e2e/target-catalogue.mts b/tools/e2e/target-catalogue.mts index 35651d84de3..94ba154ebb1 100644 --- a/tools/e2e/target-catalogue.mts +++ b/tools/e2e/target-catalogue.mts @@ -1060,6 +1060,11 @@ export const E2E_TARGET_CATALOGUE: readonly E2eCatalogueTarget[] = [ "src/lib/onboard/openclaw/initial-inference-route.ts", "src/lib/onboard/setup-inference.ts", "src/lib/actions/sandbox/rebuild-preflight-guards.ts", + "src/lib/actions/sandbox/connect.ts", + "src/lib/actions/sandbox/inference-invocation-probe.ts", + "src/lib/actions/sandbox/inference-route-health.ts", + "src/lib/actions/sandbox/launch-readiness/health.ts", + "src/lib/actions/sandbox/status-snapshot.ts", "test/e2e/fixtures/inference-routing-openclaw-native.ts", "tools/e2e/onboard-timeout-contract.mts", ], From 93f0f4eb72df9f89775fd0c86b169e98d229fe2e Mon Sep 17 00:00:00 2001 From: San Dang Date: Mon, 19 Oct 2026 16:22:16 +0700 Subject: [PATCH 7/8] refactor(inference): use the native local endpoint directly in probes A native local attachment already identifies the provider endpoint, so the probe uses it whenever the attachment is present. This removes the agent derivation, mismatch rejection, and caller changes in status, connect, and readiness health. Status still reports the endpoint of a failed request. Refs #13338 Signed-off-by: San Dang --- src/lib/actions/sandbox/connect.ts | 13 ++----- .../inference-invocation-probe.test.ts | 14 -------- .../sandbox/inference-invocation-probe.ts | 31 ++++------------ .../actions/sandbox/inference-route-health.ts | 19 ++-------- .../launch-readiness-gateway-health.test.ts | 35 ------------------- .../sandbox/launch-readiness/health.ts | 2 +- src/lib/actions/sandbox/status-snapshot.ts | 7 +--- test/e2e/support/workflow-plan.test.ts | 13 +++---- tools/e2e/target-catalogue.mts | 3 -- 9 files changed, 19 insertions(+), 118 deletions(-) diff --git a/src/lib/actions/sandbox/connect.ts b/src/lib/actions/sandbox/connect.ts index 5f6fcc1cd6f..5a3c4d274a9 100644 --- a/src/lib/actions/sandbox/connect.ts +++ b/src/lib/actions/sandbox/connect.ts @@ -1606,16 +1606,11 @@ function printUnrecoverableInferenceRoute( sandboxName: string, route: string, detail: string, - { - repairAttempted = true, - nativeProvider = false, - }: { repairAttempted?: boolean; nativeProvider?: boolean } = {}, + { repairAttempted = true }: { repairAttempted?: boolean } = {}, ): void { const reason = repairAttempted ? `inference.local is still unavailable inside '${sandboxName}' after DNS and route repair.` - : nativeProvider - ? `the attached native provider inference probe inside '${sandboxName}' did not return a trusted result.` - : `the authoritative inference.local probe inside '${sandboxName}' did not return a trusted result.`; + : `the authoritative inference.local probe inside '${sandboxName}' did not return a trusted result.`; const boundedDetail = sanitizeRouteValueForDisplay(redact(detail)) .replace(/\s+/g, " ") .trim() @@ -1713,7 +1708,6 @@ async function ensureSandboxInferenceRouteUnlocked( ): Promise { let sb: SandboxEntry | null = null; let inference: ReturnType | null = null; - let nativeProvider = false; try { sb = readConnectSandbox(sandboxName); if (!sb) return { sandbox: null, routeHealthy: null }; @@ -1725,7 +1719,6 @@ async function ensureSandboxInferenceRouteUnlocked( const gatewayName = getPersistedSandboxTargetGatewayName(sb); const nativeAttachment = getNativeProviderAttachment(sb); if (nativeAttachment || sb.nativeLocalProviderAttachment !== undefined) { - nativeProvider = true; await requireNativeInferenceHealth({ sandboxName, gatewayName, @@ -1870,7 +1863,7 @@ async function ensureSandboxInferenceRouteUnlocked( sandboxName, `${sanitizeRouteValueForDisplay(inference.provider)}/${sanitizeRouteValueForDisplay(inference.model)}`, detail, - { repairAttempted: false, nativeProvider }, + { repairAttempted: false }, ); } return { sandbox: sb, routeHealthy: false }; diff --git a/src/lib/actions/sandbox/inference-invocation-probe.test.ts b/src/lib/actions/sandbox/inference-invocation-probe.test.ts index f2537eea898..015d2c7d50a 100644 --- a/src/lib/actions/sandbox/inference-invocation-probe.test.ts +++ b/src/lib/actions/sandbox/inference-invocation-probe.test.ts @@ -1051,20 +1051,6 @@ describe("OpenClaw native local probe routing (#13338)", () => { expect(result.endpoint).toBe(`${endpointUrl}/chat/completions`); }); - it.each([ - { name: "a different supplied agent", agentName: "hermes", agent: "openclaw" as const }, - { name: "an untagged attachment without an agent", agentName: undefined, agent: null }, - ])("rejects $name before sending a request", async ({ agentName, agent }) => { - const [provider, endpointUrl] = PROVIDERS[1]; - const selected = openClawInput(provider, endpointUrl, agentName, agent); - const shell = recordingProbeShell("200", okBody); - expect(() => buildSandboxInferenceInvocationCommand(selected)).toThrow(/native local/i); - await expect( - probeSandboxInferenceInvocation(selected, { execute: shell.execute }), - ).rejects.toThrow(/native local/i); - expect(shell.requests).toEqual([]); - }); - it("refuses a raw credential before calling curl", async () => { const [provider, endpointUrl] = PROVIDERS[2]; const shell = recordingProbeShell("200", okBody, { diff --git a/src/lib/actions/sandbox/inference-invocation-probe.ts b/src/lib/actions/sandbox/inference-invocation-probe.ts index 9f5c397e540..60d5031707b 100644 --- a/src/lib/actions/sandbox/inference-invocation-probe.ts +++ b/src/lib/actions/sandbox/inference-invocation-probe.ts @@ -109,22 +109,6 @@ function nativeProbeDefinition(input: SandboxInferenceInvocationInput) { return hostedNativeProvider(input.provider, input.nativeEndpointUrl); } -/** - * A native local attachment records the agent that owns it. Callers that omit - * the agent, such as OpenClaw's legacy null session agent, use that recorded - * agent. A supplied agent that contradicts it is rejected before any request. - */ -function probeAgentName( - input: SandboxInferenceInvocationInput, - local: NativeLocalProviderAttachment | undefined, -): string | null | undefined { - if (!local) return input.agentName; - const supplied = input.agentName ?? undefined; - if (local.agent && supplied && supplied !== local.agent) - throw new Error("Native local inference probe agent does not match the recorded attachment."); - return supplied ?? local.agent; -} - /** Build the protocol-specific request used to verify sandbox inference. */ function buildProbeRequest(input: SandboxInferenceInvocationInput): { endpoint: string; @@ -146,11 +130,8 @@ function buildProbeRequest(input: SandboxInferenceInvocationInput): { input.preferredInferenceApi, input.nativeProvider ?? Boolean(local), local?.endpointUrl ?? input.nativeEndpointUrl ?? null, - probeAgentName(input, local), + input.agentName, ); - // A native local attachment never falls back to the shared inference.local route. - if (local && config.inferenceBaseUrl !== local.endpointUrl) - throw new Error("Native local inference probe has no agent that owns the recorded attachment."); const useNativeNvidia = input.nativeProvider === true && isNativeNvidiaProvider(input.provider); const hosted = nativeProbeDefinition(input); const nativeHosted = input.nativeProvider === true ? hosted : undefined; @@ -164,7 +145,8 @@ function buildProbeRequest(input: SandboxInferenceInvocationInput): { ? nativeHosted.endpoint : isNativeNvidiaProvider(input.provider) || hosted ? "https://inference.local/v1" - : config.inferenceBaseUrl + : // A native local attachment is the route, whichever agent the caller names. + (local?.endpointUrl ?? config.inferenceBaseUrl) ).replace(/\/+$/u, ""); // Gemini's existing OpenAI-compatible API ends in /v1beta/openai, not /v1. const apiBaseUrl = @@ -350,14 +332,15 @@ export async function probeSandboxInferenceInvocation( const statusText = (separator >= 0 ? result.stdout.slice(0, separator) : result.stdout).trim(); const httpStatus = /^2\d\d$/.test(statusText) ? Number.parseInt(statusText, 10) : null; const body = separator >= 0 ? result.stdout.slice(separator + 1) : ""; - const local = normalizeNativeLocalProviderAttachment(input.nativeLocalProviderAttachment); const inferenceApi = getSandboxInferenceConfig( input.model, input.provider, input.preferredInferenceApi, input.nativeProvider ?? Boolean(input.nativeLocalProviderAttachment), - local?.endpointUrl ?? input.nativeEndpointUrl ?? null, - probeAgentName(input, local), + normalizeNativeLocalProviderAttachment(input.nativeLocalProviderAttachment)?.endpointUrl ?? + input.nativeEndpointUrl ?? + null, + input.agentName, ).inferenceApi; if (httpStatus !== null && validateInferenceResponseBody(inferenceApi, body).ok) { return { ok: true }; diff --git a/src/lib/actions/sandbox/inference-route-health.ts b/src/lib/actions/sandbox/inference-route-health.ts index 34fc1d36c7f..21ac8025a76 100644 --- a/src/lib/actions/sandbox/inference-route-health.ts +++ b/src/lib/actions/sandbox/inference-route-health.ts @@ -438,11 +438,9 @@ export function buildSandboxInferenceRouteHealth( ok: invocation?.ok === true, probed: invocation !== null, providerLabel: "Native local inference", - // Report the request that actually failed, not only the recorded label. endpoint: - invocation && !invocation.ok && invocation.endpoint - ? invocation.endpoint - : `${context.nativeLocalEndpoint}/chat/completions`, + (invocation?.ok === false && invocation.endpoint) || + `${context.nativeLocalEndpoint}/chat/completions`, detail: invocation?.ok ? "The attached provider served a native local inference request." : invocation @@ -573,22 +571,11 @@ export async function runSandboxInferenceInvocationProbe( // An abnormal probe still failed against the selected API family's path. // Without this the row falls back to the models route and misdirects // recovery to a request that never ran (#10879). - ...attemptedInvocationEndpoint(input), + endpoint: resolveSandboxInferenceInvocationEndpoint(input), }; } } -// A probe rejected before building its request has no attempted endpoint. -function attemptedInvocationEndpoint(input: SandboxInferenceInvocationInput): { - endpoint?: string; -} { - try { - return { endpoint: resolveSandboxInferenceInvocationEndpoint(input) }; - } catch { - return {}; - } -} - export function readNativeStatusSelection(entry: SandboxEntry | null | undefined) { let attachment: NativeProviderAttachment | undefined; let failure: string | null = null; diff --git a/src/lib/actions/sandbox/launch-readiness-gateway-health.test.ts b/src/lib/actions/sandbox/launch-readiness-gateway-health.test.ts index 50a76e28522..da314b9f95d 100644 --- a/src/lib/actions/sandbox/launch-readiness-gateway-health.test.ts +++ b/src/lib/actions/sandbox/launch-readiness-gateway-health.test.ts @@ -503,39 +503,4 @@ describe("OpenClaw native-local readiness identity (#13338)", () => { ); }, ); - - it("rejects a selected agent that contradicts the recorded attachment before any request", async () => { - const receipt = nativeLocalReceipt({ - provider: "llama-cpp-local", - agent: "openclaw", - endpointUrl: "http://host.openshell.internal:8081/v1", - credentialEnv: "NEMOCLAW_LOCAL_INFERENCE_TOKEN", - authMode: "authenticated", - gatewayName: "selected", - sandboxName: "alpha", - }); - const shell = recordingProbeShell("200", '{"choices":[{"message":{"content":"OK"}}]}'); - await expect( - requireNativeInferenceHealth({ - sandboxName: "alpha", - gatewayName: "selected", - agentName: "pi", - entry: { - name: "alpha", - agent: "pi", - provider: "llama-cpp-local", - model: "local-model", - nativeLocalProviderAttachment: receipt, - }, - deps: { - verifyNativeLocalAttachment: vi.fn(async () => {}), - inferenceInvocationProbe: (input) => - runSandboxInferenceInvocationProbe(input, (selected, _deps, timeoutMs) => - probeSandboxInferenceInvocation(selected, { execute: shell.execute }, timeoutMs), - ), - }, - }), - ).rejects.toBeInstanceOf(LaunchReadinessObservationError); - expect(shell.requests).toEqual([]); - }); }); diff --git a/src/lib/actions/sandbox/launch-readiness/health.ts b/src/lib/actions/sandbox/launch-readiness/health.ts index 14308619368..c583574a6f4 100644 --- a/src/lib/actions/sandbox/launch-readiness/health.ts +++ b/src/lib/actions/sandbox/launch-readiness/health.ts @@ -250,7 +250,7 @@ export async function requireNativeInferenceHealth(input: { )({ sandboxName: input.sandboxName, gatewayName: input.gatewayName, - agentName: input.agentName ?? input.entry.agent ?? undefined, + agentName: input.agentName, provider: expected.provider, model: input.entry.model, preferredInferenceApi: "openai-completions", diff --git a/src/lib/actions/sandbox/status-snapshot.ts b/src/lib/actions/sandbox/status-snapshot.ts index df181653804..95197f7cd5a 100644 --- a/src/lib/actions/sandbox/status-snapshot.ts +++ b/src/lib/actions/sandbox/status-snapshot.ts @@ -768,12 +768,7 @@ export async function collectSandboxStatusSnapshot( { sandboxName, gatewayName: gatewayName ?? undefined, - // A native local request keeps the recorded agent identity. - ...(sb?.agent && - (sb.agent === "langchain-deepagents-code" || - sb.nativeLocalProviderAttachment !== undefined) - ? { agentName: sb.agent } - : {}), + ...(sb?.agent === "langchain-deepagents-code" ? { agentName: sb.agent } : {}), provider: invocationProvider, model: invocationModel, preferredInferenceApi: invocationRoute.preferredInferenceApi, diff --git a/test/e2e/support/workflow-plan.test.ts b/test/e2e/support/workflow-plan.test.ts index 661e4f6e08c..6a4e9879a0a 100644 --- a/test/e2e/support/workflow-plan.test.ts +++ b/test/e2e/support/workflow-plan.test.ts @@ -698,16 +698,11 @@ describe("E2E workflow plan", () => { it.each<[string, string[]]>([ ["test/e2e/fixtures/native-local-chat.ts", ["gpu-double-onboard", "gpu-e2e"]], - ...[ - "connect.ts", - "inference-invocation-probe.ts", - "inference-route-health.ts", - "launch-readiness/health.ts", - "status-snapshot.ts", - ].map((file): [string, string[]] => [ - `src/lib/actions/sandbox/${file}`, + [ + "src/lib/actions/sandbox/inference-invocation-probe.ts", ["inference-routing-openclaw-native"], - ]), + ], + ["src/lib/actions/sandbox/inference-route-health.ts", ["inference-routing-openclaw-native"]], ])("selects the live owners of %s", (changedFile, targets) => { expect(catalogueTargetsForChangedFiles([changedFile]).map((target) => target.id)).toEqual( expect.arrayContaining(targets), diff --git a/tools/e2e/target-catalogue.mts b/tools/e2e/target-catalogue.mts index 94ba154ebb1..e8546a80e1d 100644 --- a/tools/e2e/target-catalogue.mts +++ b/tools/e2e/target-catalogue.mts @@ -1060,11 +1060,8 @@ export const E2E_TARGET_CATALOGUE: readonly E2eCatalogueTarget[] = [ "src/lib/onboard/openclaw/initial-inference-route.ts", "src/lib/onboard/setup-inference.ts", "src/lib/actions/sandbox/rebuild-preflight-guards.ts", - "src/lib/actions/sandbox/connect.ts", "src/lib/actions/sandbox/inference-invocation-probe.ts", "src/lib/actions/sandbox/inference-route-health.ts", - "src/lib/actions/sandbox/launch-readiness/health.ts", - "src/lib/actions/sandbox/status-snapshot.ts", "test/e2e/fixtures/inference-routing-openclaw-native.ts", "tools/e2e/onboard-timeout-contract.mts", ], From 65d6e4c45d35cd3c6fc975adaa1859277cd9a2b5 Mon Sep 17 00:00:00 2001 From: San Dang Date: Mon, 19 Oct 2026 16:55:12 +0700 Subject: [PATCH 8/8] test(inference): reuse the native local receipt fixture Extend the existing nativeLocalTestReceipt helper with binding overrides and remove the duplicate receipt builder. Update the OpenClaw quickstart: new Ollama, vLLM, and llama.cpp selections use sandbox-attached providers. Refs #13338 Signed-off-by: San Dang --- docs/get-started/quickstart.mdx | 3 ++- .../inference-invocation-probe.test.ts | 12 ++++------ .../launch-readiness-gateway-health.test.ts | 19 ++++++++------- .../status-snapshot-inference-health.test.ts | 23 ++++++++----------- test/helpers/inference-set.ts | 2 ++ test/helpers/native-local-probe-shell.ts | 14 ----------- 6 files changed, 27 insertions(+), 46 deletions(-) diff --git a/docs/get-started/quickstart.mdx b/docs/get-started/quickstart.mdx index 03d8b724438..3b98b3e215d 100644 --- a/docs/get-started/quickstart.mdx +++ b/docs/get-started/quickstart.mdx @@ -382,7 +382,8 @@ Use these details when your first-run path needs more control. After confirmation, NemoClaw registers the selected provider with OpenShell. NVIDIA Endpoints and supported fixed hosted providers use native endpoints through sandbox-attached OpenShell providers. - Custom and local providers retain the shared `inference.local` route. + New Ollama, standalone vLLM, and llama.cpp selections also use sandbox-attached providers for their host-local endpoints. + Local NVIDIA NIM, custom endpoints, and earlier local selections without a sandbox-attached provider retain the shared `inference.local` route. The wizard asks whether to enable web search and offers Brave Search or Tavily Search. Provide `BRAVE_API_KEY` for Brave Search or `TAVILY_API_KEY` for Tavily Search when prompted. NemoClaw validates the selected key before it creates the sandbox, registers a sandbox-scoped OpenShell provider, and writes only an OpenShell resolver placeholder into the OpenClaw configuration. diff --git a/src/lib/actions/sandbox/inference-invocation-probe.test.ts b/src/lib/actions/sandbox/inference-invocation-probe.test.ts index 015d2c7d50a..b2a5f35fd23 100644 --- a/src/lib/actions/sandbox/inference-invocation-probe.test.ts +++ b/src/lib/actions/sandbox/inference-invocation-probe.test.ts @@ -29,9 +29,9 @@ import { } from "./inference-invocation-probe"; import { NATIVE_LOCAL_CREDENTIAL_HANDLE, - nativeLocalReceipt, recordingProbeShell, } from "../../../../test/helpers/native-local-probe-shell"; +import { nativeLocalTestReceipt } from "../../../../test/helpers/inference-set"; const input = { sandboxName: "dcode-workspace", @@ -1004,15 +1004,11 @@ describe("OpenClaw native local probe routing (#13338)", () => { provider, model: "local-model", preferredInferenceApi: "openai-completions", - nativeLocalProviderAttachment: nativeLocalReceipt({ + nativeLocalProviderAttachment: nativeLocalTestReceipt( provider, - ...(agent ? { agent } : {}), endpointUrl, - credentialEnv: "NEMOCLAW_LOCAL_INFERENCE_TOKEN", - authMode: "authenticated", - gatewayName: "nemoclaw", - sandboxName: "alpha", - }), + agent ? { agent } : {}, + ), }; } diff --git a/src/lib/actions/sandbox/launch-readiness-gateway-health.test.ts b/src/lib/actions/sandbox/launch-readiness-gateway-health.test.ts index da314b9f95d..3425592de11 100644 --- a/src/lib/actions/sandbox/launch-readiness-gateway-health.test.ts +++ b/src/lib/actions/sandbox/launch-readiness-gateway-health.test.ts @@ -20,9 +20,9 @@ import { probeSandboxInferenceInvocation } from "./inference-invocation-probe"; import { runSandboxInferenceInvocationProbe } from "./inference-route-health"; import { NATIVE_LOCAL_CREDENTIAL_HANDLE, - nativeLocalReceipt, recordingProbeShell, } from "../../../../test/helpers/native-local-probe-shell"; +import { nativeLocalTestReceipt } from "../../../../test/helpers/inference-set"; import { isSandboxGatewayRunningForStatus, waitForStartedHermesGatewayProcess, @@ -464,15 +464,14 @@ describe("OpenClaw native-local readiness identity (#13338)", () => { ])( "sends the health request to the recorded endpoint (selected $agentName, recorded $agent)", async ({ agentName, agent }) => { - const receipt = nativeLocalReceipt({ - provider: "llama-cpp-local", - agent: "openclaw", - endpointUrl: "http://host.openshell.internal:8081/v1", - credentialEnv: "NEMOCLAW_LOCAL_INFERENCE_TOKEN", - authMode: "authenticated", - gatewayName: "selected", - sandboxName: "alpha", - }); + const receipt = nativeLocalTestReceipt( + "llama-cpp-local", + "http://host.openshell.internal:8081/v1", + { + agent: "openclaw", + gatewayName: "selected", + }, + ); const shell = recordingProbeShell("200", '{"choices":[{"message":{"content":"OK"}}]}'); await expect( requireNativeInferenceHealth({ diff --git a/src/lib/actions/sandbox/status-snapshot-inference-health.test.ts b/src/lib/actions/sandbox/status-snapshot-inference-health.test.ts index 95a1cc5d938..bc75e1b0608 100644 --- a/src/lib/actions/sandbox/status-snapshot-inference-health.test.ts +++ b/src/lib/actions/sandbox/status-snapshot-inference-health.test.ts @@ -10,10 +10,8 @@ import type { SandboxInferenceInvocationResult } from "./inference-invocation-pr import type { SandboxInferenceRouteHealth } from "./inference-route-health"; import { collectSandboxStatusSnapshot } from "./status-snapshot"; import { probeSandboxInferenceInvocation } from "./inference-invocation-probe"; -import { - nativeLocalReceipt, - recordingProbeShell, -} from "../../../../test/helpers/native-local-probe-shell"; +import { recordingProbeShell } from "../../../../test/helpers/native-local-probe-shell"; +import { nativeLocalTestReceipt } from "../../../../test/helpers/inference-set"; // Direct, unmocked coverage of `buildSandboxInferenceRouteHealth` through the // exported `collectSandboxStatusSnapshot` entry point (it is not itself @@ -1168,15 +1166,14 @@ describe("status native local request identity (#13338)", () => { it.each(["openclaw", undefined] as const)( "probes and reports the recorded OpenClaw endpoint when the registry agent is %s", async (agent) => { - const receipt = nativeLocalReceipt({ - provider: "vllm-local", - agent: "openclaw", - endpointUrl: "http://host.openshell.internal:18000/v1", - credentialEnv: "NEMOCLAW_LOCAL_INFERENCE_TOKEN", - authMode: "sentinel", - gatewayName: "nemoclaw", - sandboxName: "alpha", - }); + const receipt = nativeLocalTestReceipt( + "vllm-local", + "http://host.openshell.internal:18000/v1", + { + agent: "openclaw", + authMode: "sentinel", + }, + ); const options = snapshotDeps( null, null, diff --git a/test/helpers/inference-set.ts b/test/helpers/inference-set.ts index 1e6945e61a6..ca4af828f4d 100644 --- a/test/helpers/inference-set.ts +++ b/test/helpers/inference-set.ts @@ -292,6 +292,7 @@ export type CaptureOpenshell = ( export function nativeLocalTestReceipt( provider: NativeLocalBinding["provider"] = "ollama-local", endpointUrl = "http://host.openshell.internal:11435/v1", + overrides: Partial = {}, ) { const binding: NativeLocalBinding = { provider, @@ -300,6 +301,7 @@ export function nativeLocalTestReceipt( gatewayName: "nemoclaw", credentialEnv: "NEMOCLAW_LOCAL_INFERENCE_TOKEN", authMode: "authenticated", + ...overrides, }; return { ...binding, diff --git a/test/helpers/native-local-probe-shell.ts b/test/helpers/native-local-probe-shell.ts index d3003befcc7..977d7ac5576 100644 --- a/test/helpers/native-local-probe-shell.ts +++ b/test/helpers/native-local-probe-shell.ts @@ -6,26 +6,12 @@ import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "nod import { tmpdir } from "node:os"; import path from "node:path"; -import { - nativeLocalIdentity, - type NativeLocalBinding, - type NativeLocalProviderAttachment, -} from "../../src/lib/inference/native-local/contract"; import type { SandboxInferenceInvocationDeps } from "../../src/lib/actions/sandbox/inference-invocation-probe"; /** The shape OpenShell issues for an attached native local provider credential. */ export const NATIVE_LOCAL_CREDENTIAL_HANDLE = "openshell:resolve:env:v7_NEMOCLAW_LOCAL_INFERENCE_TOKEN"; -export function nativeLocalReceipt(binding: NativeLocalBinding): NativeLocalProviderAttachment { - return { - ...binding, - ...nativeLocalIdentity(binding), - schemaVersion: 1, - providerId: "fixture-local-provider", - }; -} - /** * Run each generated probe command in a real shell whose curl records its * arguments and answers with a fixed HTTP status and body. The recorded