Skip to content
Merged
44 changes: 44 additions & 0 deletions src/lib/onboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2041,6 +2041,46 @@
return Boolean(live && live.provider === provider && live.model === model);
}

function shouldSmokeOpenAiLikeOnboardRoute(provider: string): boolean {
if (provider === "nvidia-nim" || provider === "nvidia-router") return true;
return Object.values(REMOTE_PROVIDER_CONFIG).some(
(entry) => entry.providerName === provider && entry.providerType === "openai",
);
}

function verifyOnboardInferenceSmoke(options: {
provider: string;
model: string;
endpointUrl?: string | null;
credentialEnv?: string | null;
}): void {
if (!shouldSmokeOpenAiLikeOnboardRoute(options.provider)) return;
if (process.env.VITEST === "true") return;

const endpointUrl = options.endpointUrl || INFERENCE_ROUTE_URL;
const credentialEnv = options.credentialEnv || null;
const apiKey = credentialEnv
? hydrateCredentialEnv(credentialEnv) || getCredential(credentialEnv) || ""
: "";
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
const probe = probeOpenAiLikeEndpoint(endpointUrl, options.model, apiKey, {
authMode: getProbeAuthMode(options.provider),
skipResponsesProbe: true,
});

if (probe.ok) {
console.log(` ✓ Inference smoke passed: ${options.provider} / ${options.model}`);
return;
}

console.error(" Onboard inference smoke check failed.");
console.error(` Provider: ${options.provider}`);
console.error(` Model: ${options.model}`);
console.error(` API base: ${endpointUrl}`);
if (credentialEnv) console.error(` Credential env: ${credentialEnv}`);
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
console.error(` Upstream error: ${compactText(redact(probe.message || "unknown inference failure"))}`);
process.exit(1);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

function verifyCompatibleEndpointSandboxSmoke(options: {
sandboxName: string;
provider: string;
Expand Down Expand Up @@ -7708,6 +7748,7 @@
}

verifyInferenceRoute(provider, model);
verifyOnboardInferenceSmoke({ provider, model, endpointUrl, credentialEnv });

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Run the smoke probe on the resume fast-path too.

These probes run in setupInference, but onboard() can skip that function when resume && isInferenceRouteReady(provider, model), which allows a resumed run to report success without executing the new smoke validation.

Suggested fix
       if (isRoutedInferenceProvider(provider)) {
         try {
           await reconcileModelRouter();
         } catch (err) {
           console.error(
             `  ✗ Failed to reconcile model router: ${err instanceof Error ? err.message : String(err)}`,
           );
           process.exit(1);
         }
       }
       skippedStepMessage("inference", `${provider} / ${model}`);
+      verifyOnboardInferenceSmoke({ provider, model, endpointUrl, credentialEnv });
       if (nimContainer && sandboxName) {
         registry.updateSandbox(sandboxName, { nimContainer });
       }

Also applies to: 7989-7989

🤖 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 `@src/lib/onboard.ts` at line 7713, When the onboarding code takes the resume
fast-path (when resume && isInferenceRouteReady(provider, model)) it skips
setupInference and therefore skips the smoke probe; ensure
verifyOnboardInferenceSmoke({ provider, model, endpointUrl, credentialEnv }) is
invoked in the onboard resume fast-path before returning success (i.e., add the
same smoke validation call to the branch guarded by resume &&
isInferenceRouteReady in the onboard function), and mirror the same insertion
for the other resume-fast-path occurrence referenced (the other
isInferenceRouteReady/resume branch) so resumed runs run the smoke probe as
well.

if (sandboxName) {
registry.updateSandbox(sandboxName, { model, provider });
}
Expand Down Expand Up @@ -7983,6 +8024,7 @@
}

verifyInferenceRoute(provider, model);
verifyOnboardInferenceSmoke({ provider, model, endpointUrl, credentialEnv });
if (sandboxName) {
registry.updateSandbox(sandboxName, { model, provider });
}
Expand Down Expand Up @@ -10878,4 +10920,6 @@
checkTelegramReachability,
TELEGRAM_NETWORK_CURL_CODES,
verifyCompatibleEndpointSandboxSmoke,
verifyOnboardInferenceSmoke,
shouldSmokeOpenAiLikeOnboardRoute,
};
Loading