Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
60 changes: 59 additions & 1 deletion src/lib/onboard/command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
import { getCredential } from "../credentials/store";
import { loadServingCatalog } from "../inference/serving/catalog-loader";
import { servingProfileProvenance } from "../inference/serving/profile-provenance";
import { resolveOnboardOptions, runOnboardCommand } from "./command";
import { resolveOnboardOptions, runOnboardCommand, servingProfileProviderKey } from "./command";
import type { OnboardFlags } from "./command-support";
import { PortableInferenceDescriptorError } from "./experimental/portable-inference-descriptor";
import { invalidGatewayManagementDeclarationError } from "./gateway-management";
Expand All @@ -20,6 +20,7 @@ import {
LOCAL_MODEL_PROFILE_RUNTIME_ENV,
} from "./local-model-profile/plan";
import { OnboardResumeIntentError, OnboardResumeIntentRaceError } from "./session-bootstrap";
import { MANAGED_VLLM_PROVIDER_KEY } from "./vllm-menu";

afterEach(() => {
vi.unstubAllEnvs();
Expand Down Expand Up @@ -747,6 +748,63 @@ describe("onboard command options", () => {
expect(env.NEMOCLAW_SERVING_PRESET).toBeUndefined();
});

it("selects the profile's backend provider so onboarding skips the menu (#9313)", async () => {
// The preset alone only picks the model once a provider is chosen. Without
// a provider the run fell through to the interactive provider menu with the
// requested profile never applied.
const vllmProfile = {
...COMPATIBLE_NANO_PROFILE,
id: "vllm.dgx-spark-gb10.single.muse-glimmer-30b-nvfp4-w4a4",
displayName: "Muse Glimmer 30B NVFP4 W4A4 on one DGX Spark",
backend: "vllm",
};
const env: NodeJS.ProcessEnv = {};
let observedProvider: string | undefined;
let observedPreset: string | undefined;
await runOnboardCommand({
flags: { profile: vllmProfile.id },
env,
listServingProfiles: () => [vllmProfile],
runOnboard: async () => {
observedProvider = env.NEMOCLAW_PROVIDER;
observedPreset = env.NEMOCLAW_SERVING_PRESET;
},
});

expect(observedProvider).toBe("install-vllm");
expect(observedPreset).toBe(vllmProfile.id);
// Scoped to the run, like the preset itself.
expect(env.NEMOCLAW_PROVIDER).toBeUndefined();
expect(env.NEMOCLAW_SERVING_PRESET).toBeUndefined();
});

it("selects the managed llama.cpp provider for a llama-cpp profile (#9313)", async () => {
const env: NodeJS.ProcessEnv = {};
let observedProvider: string | undefined;
await runOnboardCommand({
flags: { profile: COMPATIBLE_NANO_PROFILE.id },
env,
listServingProfiles: () => [COMPATIBLE_NANO_PROFILE],
runOnboard: async () => {
observedProvider = env.NEMOCLAW_PROVIDER;
},
});

expect(observedProvider).toBe("install-llama-cpp");
expect(env.NEMOCLAW_PROVIDER).toBeUndefined();
});

it("maps each serving backend to the provider that can run it (#9313)", () => {
// A backend with no provider returns null, which `resolveServingProfile`
// reports instead of accepting the flag and then asking for a provider.
const withBackend = (backend: string) => ({ recipe: { backend } }) as never;

// Pinned against the provider menu's own key so the two cannot drift.
expect(servingProfileProviderKey(withBackend("vllm"))).toBe(MANAGED_VLLM_PROVIDER_KEY);
expect(servingProfileProviderKey(withBackend("install-llama-cpp"))).toBe("install-llama-cpp");
expect(servingProfileProviderKey(withBackend("future-backend"))).toBeNull();
});

it("records an installer profile without activating the disabled generic preset", async () => {
const env: NodeJS.ProcessEnv = {
[LOCAL_MODEL_PROFILE_ENABLED_ENV]: "1",
Expand Down
48 changes: 47 additions & 1 deletion src/lib/onboard/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,16 @@ function resolveServingProfile(
throw error;
}
validateServingProfileConflicts(selectedProfileId, deps);
return servingProfileProvenance(catalog, selectedProfileId);
const provenance = servingProfileProvenance(catalog, selectedProfileId);
if (!servingProfileProviderKey(provenance)) {
// Reporting this beats the old behaviour of accepting the flag and then
// asking which provider to use, which left the profile silently unapplied.
fail(
deps,
` Serving profile '${selectedProfileId}' uses backend '${provenance.recipe.backend}', which onboarding cannot configure with --profile.`,
);
}
return provenance;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

function resolveInstallerServingProfile(
Expand Down Expand Up @@ -323,6 +332,29 @@ function activeServingProfileId(provenance: ServingProfileProvenance | null): st
return provenance.preset.id;
}

/**
* Provider the requested serving profile has to run through.
*
* The preset alone only tells provider selection *which* profile to serve once
* a local-inference provider has been chosen; it never chooses the provider.
* Because `--profile` also rejects an explicit `NEMOCLAW_PROVIDER`, leaving
* this unset dropped onboarding into the interactive provider menu with the
* requested profile unusable (#9313). Returns null for a backend that has no
* provider wired up, which the caller reports rather than silently ignoring.
*/
export function servingProfileProviderKey(provenance: ServingProfileProvenance): string | null {
switch (provenance.recipe.backend) {
// Kept as literals so this module does not take a dependency on the
// provider menu; `command.test.ts` asserts they match its exported keys.
case "vllm":
return "install-vllm";
case "install-llama-cpp":
return "install-llama-cpp";
default:
return null;
}
}

function resolveResumedServingProfile(
requested: ServingProfileProvenance | null,
deps: ResolveOnboardOptionsDeps,
Expand Down Expand Up @@ -477,9 +509,23 @@ function applyServingProfileEnvironment(
if (!options.servingProfile) return () => {};
const previous = env[NEMOCLAW_SERVING_PRESET_ENV];
env[NEMOCLAW_SERVING_PRESET_ENV] = options.servingProfile;
// The preset selects the model once a provider is chosen; the profile's
// backend is what selects the provider. Setting only the former left the
// provider unresolved and onboarding fell back to the menu (#9313).
// `validateServingProfileConflicts` already rejected an operator-supplied
// NEMOCLAW_PROVIDER, so nothing of the caller's is being overwritten here.
const providerKey = options.servingProfileProvenance
? servingProfileProviderKey(options.servingProfileProvenance)
: null;
const previousProvider = env.NEMOCLAW_PROVIDER;
if (providerKey) env.NEMOCLAW_PROVIDER = providerKey;
return () => {
if (previous === undefined) delete env[NEMOCLAW_SERVING_PRESET_ENV];
else env[NEMOCLAW_SERVING_PRESET_ENV] = previous;
if (providerKey) {
if (previousProvider === undefined) delete env.NEMOCLAW_PROVIDER;
else env.NEMOCLAW_PROVIDER = previousProvider;
}
};
}

Expand Down
Loading