Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 83 additions & 26 deletions .github/workflows/e2e-vitest-scenarios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -969,18 +969,40 @@ jobs:
needs: generate-matrix
if: ${{ (inputs.jobs == '' && inputs.scenarios == '') || contains(format(',{0},', inputs.jobs), ',hermes-inference-switch-vitest,') || contains(format(',{0},', inputs.scenarios), ',hermes-inference-switch,') }}
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 55
strategy:
fail-fast: false
matrix:
include:
- mode: hosted
sandbox_name: e2e-hermes-inference-switch
switch_provider: compatible-endpoint
switch_model: nvidia/nvidia/nemotron-3-super-v3
switch_inference_api: openai-completions
switch_mock_anthropic: "0"
- mode: anthropic
sandbox_name: e2e-hermes-anthropic-inference-switch
switch_provider: compatible-anthropic-endpoint
switch_model: mock-anthropic-model
switch_inference_api: anthropic-messages
switch_mock_anthropic: "1"
env:
FREE_STANDING_VITEST_JOB: "1"
FREE_STANDING_SCENARIO_ID: "hermes-inference-switch"
E2E_ARTIFACT_DIR: ${{ github.workspace }}/e2e-artifacts/vitest/hermes-inference-switch
E2E_ARTIFACT_DIR: ${{ github.workspace }}/e2e-artifacts/vitest/hermes-inference-switch/${{ matrix.mode }}
NEMOCLAW_CLI_BIN: ${{ github.workspace }}/bin/nemoclaw.js
NEMOCLAW_RUN_E2E_SCENARIOS: "1"
NEMOCLAW_E2E_USE_HOSTED_INFERENCE: "1"
NEMOCLAW_NON_INTERACTIVE: "1"
NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE: "1"
NEMOCLAW_AGENT: "hermes"
NEMOCLAW_SANDBOX_NAME: "e2e-hermes-inference-switch"
NEMOCLAW_SANDBOX_NAME: ${{ matrix.sandbox_name }}
NEMOCLAW_SWITCH_PROVIDER: ${{ matrix.switch_provider }}
NEMOCLAW_SWITCH_MODEL: ${{ matrix.switch_model }}
NEMOCLAW_SWITCH_INFERENCE_API: ${{ matrix.switch_inference_api }}
NEMOCLAW_SWITCH_MOCK_ANTHROPIC: ${{ matrix.switch_mock_anthropic }}
OPENSHELL_GATEWAY: "nemoclaw"
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
Expand Down Expand Up @@ -1009,8 +1031,8 @@ jobs:
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: e2e-vitest-scenarios-hermes-inference-switch
path: e2e-artifacts/vitest/hermes-inference-switch/
name: e2e-vitest-scenarios-hermes-inference-switch-${{ matrix.mode }}
path: e2e-artifacts/vitest/hermes-inference-switch/${{ matrix.mode }}/
include-hidden-files: false
if-no-files-found: ignore
retention-days: 14
Expand Down Expand Up @@ -4640,23 +4662,67 @@ jobs:
needs: generate-matrix
if: ${{ (inputs.jobs == '' && inputs.scenarios == '') || contains(format(',{0},', inputs.jobs), ',openclaw-inference-switch-vitest,') || contains(format(',{0},', inputs.scenarios), ',openclaw-inference-switch,') }}
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
include:
- mode: hosted
sandbox_name: e2e-openclaw-inference-switch
switch_provider: compatible-endpoint
switch_model: nvidia/nvidia/nemotron-3-super-v3
switch_inference_api: openai-completions
switch_mock_anthropic: "0"
- mode: anthropic
sandbox_name: e2e-openclaw-anthropic-inference-switch
switch_provider: compatible-anthropic-endpoint
switch_model: mock-anthropic-model
switch_inference_api: anthropic-messages
switch_mock_anthropic: "1"
env:
FREE_STANDING_VITEST_JOB: "1"
FREE_STANDING_SCENARIO_ID: "openclaw-inference-switch"
E2E_ARTIFACT_DIR: ${{ github.workspace }}/e2e-artifacts/vitest/openclaw-inference-switch
E2E_ARTIFACT_DIR: ${{ github.workspace }}/e2e-artifacts/vitest/openclaw-inference-switch/${{ matrix.mode }}
NEMOCLAW_CLI_BIN: ${{ github.workspace }}/bin/nemoclaw.js
NEMOCLAW_RUN_E2E_SCENARIOS: "1"
NEMOCLAW_E2E_USE_HOSTED_INFERENCE: "1"
NEMOCLAW_NON_INTERACTIVE: "1"
NEMOCLAW_ACCEPT_THIRD_PARTY_SOFTWARE: "1"
NEMOCLAW_SANDBOX_NAME: "e2e-openclaw-inference-switch"
NEMOCLAW_AGENT: "openclaw"
NEMOCLAW_SANDBOX_NAME: ${{ matrix.sandbox_name }}
NEMOCLAW_SWITCH_PROVIDER: ${{ matrix.switch_provider }}
NEMOCLAW_SWITCH_MODEL: ${{ matrix.switch_model }}
NEMOCLAW_SWITCH_INFERENCE_API: ${{ matrix.switch_inference_api }}
NEMOCLAW_SWITCH_MOCK_ANTHROPIC: ${{ matrix.switch_mock_anthropic }}
OPENSHELL_GATEWAY: "nemoclaw"
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false

- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.0.0
with:
node-version: 22
cache: npm

- name: Install root dependencies
run: npm ci --ignore-scripts

- name: Build CLI
run: npm run build:cli

- name: Configure isolated Docker auth directory
shell: bash
run: |
set -euo pipefail
docker_config="${RUNNER_TEMP}/docker-config-openclaw-inference-switch-${{ matrix.mode }}"
mkdir -p "${docker_config}"
chmod 700 "${docker_config}"
echo "DOCKER_CONFIG=${docker_config}" >> "${GITHUB_ENV}"

- name: Authenticate to Docker Hub
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
Expand All @@ -4683,18 +4749,6 @@ jobs:
echo "::warning::Docker Hub login failed after 3 attempts; continuing with anonymous pulls."
fi

- name: Set up Node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.0.0
with:
node-version: 22
cache: npm

- name: Install root dependencies
run: npm ci --ignore-scripts

- name: Build CLI
run: npm run build:cli

- name: Run OpenClaw inference switch live test
# Migrated from test/e2e/test-openclaw-inference-switch.sh. Preserves
# the real install.sh/OpenShell/Docker/live-provider boundary while
Expand All @@ -4708,24 +4762,27 @@ jobs:
test/e2e-scenario/live/openclaw-inference-switch.test.ts \
--silent=false --reporter=default

- name: Clean up Docker auth
if: always()
shell: bash
run: |
set -euo pipefail
docker_config="${DOCKER_CONFIG:-${RUNNER_TEMP}/docker-config-openclaw-inference-switch-${{ matrix.mode }}}"
DOCKER_CONFIG="${docker_config}" docker logout docker.io >/dev/null 2>&1 || true
rm -rf "${docker_config}"

- name: Upload OpenClaw inference switch artifacts
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: e2e-vitest-scenarios-openclaw-inference-switch
name: e2e-vitest-scenarios-openclaw-inference-switch-${{ matrix.mode }}
path: |
e2e-artifacts/vitest/openclaw-inference-switch/
e2e-artifacts/vitest/openclaw-inference-switch/${{ matrix.mode }}/
/tmp/nemoclaw-e2e-openclaw-inference-switch-install.log
include-hidden-files: false
if-no-files-found: ignore
retention-days: 14

- name: Clean up Docker auth
if: always()
shell: bash
run: |
docker logout docker.io >/dev/null 2>&1 || true

# Focused coverage slice for the Bedrock Runtime compatible Anthropic
# endpoint contract. The retained legacy bash lane remains the source for
# full closeout until #5098 Phase 11 shell retirement.
Expand Down
40 changes: 40 additions & 0 deletions test/e2e-scenario/fixtures/inference-switch-retry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import type { ShellProbeResult } from "./shell-probe.ts";

const TRANSIENT_INFERENCE_SET_FAILURE =
/timed? out|timeout|ETIMEDOUT|ECONNRESET|EAI_AGAIN|ENOTFOUND|failed to connect|error sending request|failed to verify inference endpoint|502|503|504|temporar/iu;

export function inferenceSetAttemptCount(raw: string | undefined, fallback = 3): number {
if (raw === undefined) return fallback;
const parsed = Number(raw);
if (!Number.isInteger(parsed) || parsed < 1) {
throw new Error(`NEMOCLAW_SWITCH_SET_ATTEMPTS must be a positive integer; got ${raw}`);
}
return parsed;
}

export function isTransientInferenceSetFailure(result: ShellProbeResult): boolean {
return TRANSIENT_INFERENCE_SET_FAILURE.test(`${result.stdout}\n${result.stderr}`);
}

export async function runInferenceSetWithRetry(options: {
attempts: number;
delay?: (milliseconds: number) => Promise<void>;
run: (attempt: number, verify: boolean) => Promise<ShellProbeResult>;
}): Promise<ShellProbeResult> {
const delay =
options.delay ??
((milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)));
for (let attempt = 1; attempt <= options.attempts; attempt += 1) {
const result = await options.run(attempt, true);
if (result.exitCode === 0 || !isTransientInferenceSetFailure(result)) return result;
if (attempt < options.attempts) {
await delay(attempt * 5_000);
continue;
}
return options.run(attempt, false);
}
throw new Error("Inference switch retry loop completed without running an attempt.");
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}
55 changes: 53 additions & 2 deletions test/e2e-scenario/live/hermes-inference-switch-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import {
validateSandboxName,
} from "../fixtures/clients/sandbox.ts";
import { expect } from "../fixtures/e2e-test.ts";
import { DEFAULT_HOSTED_INFERENCE_MODEL } from "../fixtures/hosted-inference.ts";
import {
inferenceSetAttemptCount,
runInferenceSetWithRetry,
} from "../fixtures/inference-switch-retry.ts";
import type { ShellProbeResult } from "../fixtures/shell-probe.ts";
import { isTransientProviderValidationFailure } from "./network-policy-transient-provider.ts";

Expand All @@ -40,6 +45,12 @@ interface MockAnthropicProvider {
close(): Promise<void>;
}

export function hostedInstallModel(runtimeEnv: NodeJS.ProcessEnv = process.env): string {
return (
runtimeEnv.NEMOCLAW_MODEL ?? runtimeEnv.NEMOCLAW_COMPAT_MODEL ?? DEFAULT_HOSTED_INFERENCE_MODEL
);
}

export function env(apiKey?: string, extra: NodeJS.ProcessEnv = {}): NodeJS.ProcessEnv {
const out: NodeJS.ProcessEnv = {
...buildAvailabilityProbeEnv(),
Expand All @@ -55,7 +66,8 @@ export function env(apiKey?: string, extra: NodeJS.ProcessEnv = {}): NodeJS.Proc
apiKey &&
Object.assign(out, {
COMPATIBLE_API_KEY: apiKey,
NEMOCLAW_COMPAT_MODEL: SWITCH_MODEL,
NEMOCLAW_MODEL: hostedInstallModel(),
NEMOCLAW_COMPAT_MODEL: hostedInstallModel(),
NEMOCLAW_ENDPOINT_URL:
process.env.NEMOCLAW_ENDPOINT_URL ?? "https://inference-api.nvidia.com/v1",
NEMOCLAW_PREFERRED_API: process.env.NEMOCLAW_PREFERRED_API ?? "openai-completions",
Expand Down Expand Up @@ -117,6 +129,13 @@ export async function cleanupHermesSwitch(
timeoutMs: 60_000,
}),
);
await bestEffort(() =>
sandbox.openshell(["gateway", "destroy", "-g", "nemoclaw"], {
artifactName: "cleanup-openshell-gateway-destroy",
env: env(),
timeoutMs: 120_000,
}),
);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

function jsonResponse(res: http.ServerResponse, status: number, payload: unknown): void {
Expand Down Expand Up @@ -279,7 +298,7 @@ export async function installHermes(
for (let attempt = 1; attempt <= INSTALL_ATTEMPTS; attempt += 1) {
install = await host.command(
"bash",
["install.sh", "--non-interactive", "--yes-i-accept-third-party-software"],
["install.sh", "--non-interactive", "--fresh", "--yes-i-accept-third-party-software"],
{
artifactName: attempt === 1 ? "install-hermes" : `install-hermes-attempt-${attempt}`,
cwd: REPO_ROOT,
Expand All @@ -300,6 +319,38 @@ export async function installHermes(
return install;
}

export async function runHermesInferenceSetWithRetry(
host: HostCliClient,
apiKey: string,
compatibleMetadataArgs: string[],
options: { attempts?: number; delay?: (milliseconds: number) => Promise<void> } = {},
): Promise<ShellProbeResult> {
const args = [
CLI,
"inference",
"set",
"--provider",
SWITCH_PROVIDER,
"--model",
SWITCH_MODEL,
...compatibleMetadataArgs,
];
return runInferenceSetWithRetry({
attempts:
options.attempts ?? inferenceSetAttemptCount(process.env.NEMOCLAW_SWITCH_SET_ATTEMPTS),
delay: options.delay,
run: (attempt, verify) =>
host.command("node", verify ? args : [...args, "--no-verify"], {
artifactName: verify
? `hermes-inference-set-${attempt}`
: "hermes-inference-set-no-verify-after-transient-failures",
env: env(apiKey),
redactionValues: [apiKey],
timeoutMs: 180_000,
}),
});
}

export async function hermesGatewayPid(
sandbox: SandboxClient,
artifactName: string,
Expand Down
22 changes: 2 additions & 20 deletions test/e2e-scenario/live/hermes-inference-switch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { expect, test } from "../fixtures/e2e-test.ts";
import { shouldRunLiveE2EScenarios } from "../fixtures/live-project-gate.ts";
import {
apiKeyShape,
CLI,
chatContent,
cleanupHermesSwitch,
ensureCompatibleAnthropicSwitchProvider,
Expand All @@ -27,6 +26,7 @@ import {
maybeAssertPidStable,
parseHermesModelBlock,
registryState,
runHermesInferenceSetWithRetry,
SANDBOX_NAME,
SWITCH_API,
SWITCH_MODEL,
Expand Down Expand Up @@ -80,25 +80,7 @@ test.skipIf(!shouldRunLiveE2EScenarios())(
SWITCH_API,
]
: [];
const switched = await host.command(
"node",
[
CLI,
"inference",
"set",
"--provider",
SWITCH_PROVIDER,
"--model",
SWITCH_MODEL,
...compatibleMetadataArgs,
],
{
artifactName: "hermes-inference-set",
env: env(apiKey),
redactionValues: [apiKey],
timeoutMs: 180_000,
},
);
const switched = await runHermesInferenceSetWithRetry(host, apiKey, compatibleMetadataArgs);
expect(switched.exitCode, resultText(switched)).toBe(0);

const pidAfter = await hermesGatewayPid(sandbox, "pid-after");
Expand Down
Loading
Loading