Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
2a8e3aa
fix(onboard): offer Ollama upgrade when host version too old
laitingsheng May 25, 2026
d6c7199
refactor(onboard): extract Ollama install menu to satisfy entrypoint …
laitingsheng May 25, 2026
c39e816
refactor(onboard): brew upgrade on macOS, extract Ollama version helpers
laitingsheng May 25, 2026
cd08178
fix(onboard): force system upgrade and verify Ollama version after in…
laitingsheng May 25, 2026
4be19f8
fix(onboard): verify upgrade via running daemon and reject user-local…
laitingsheng May 25, 2026
e7d34ed
fix(onboard): consider running daemon version when deciding Ollama up…
laitingsheng May 25, 2026
262bbea
fix(onboard): scope Ollama daemon upgrade check to local host and lab…
laitingsheng May 25, 2026
c5b23c1
fix(onboard): pin resolved Ollama host after install and label stale …
laitingsheng May 25, 2026
7612370
fix(onboard): start local Ollama daemon when only Windows-host probe …
laitingsheng May 25, 2026
5c43b26
fix(onboard): re-probe loopback fresh instead of trusting cached reso…
laitingsheng May 25, 2026
3f2b8b5
fix(onboard): guard env=system upgrade against missing sudo and unblo…
laitingsheng May 25, 2026
373b05f
fix(onboard): stop stale Ollama daemon on macOS upgrade; drop unused …
laitingsheng May 25, 2026
8497696
fix(onboard): stop stale Linux Ollama daemon before relaunch on non-s…
laitingsheng May 25, 2026
0ecfbc0
Merge branch 'main' into fix/4178-ollama-version-upgrade
cv May 25, 2026
74b8723
refactor(onboard): split Ollama Linux upgrade helpers
cv May 25, 2026
ba1b68f
Merge branch 'main' into fix/4178-ollama-version-upgrade
cv May 25, 2026
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
43 changes: 43 additions & 0 deletions src/lib/inference/local.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ import {
probeLocalProviderHealth,
validateOllamaModel,
validateLocalProvider,
getInstalledOllamaVersion,
isOllamaVersionAtLeast,
MIN_OLLAMA_VERSION,
} from "../../../dist/lib/inference/local";

describe("local inference helpers", () => {
Expand Down Expand Up @@ -950,4 +953,44 @@ describe("local inference helpers", () => {
expect(result.ok).toBe(true);
});

describe("Ollama version detection", () => {
it("parses 'ollama version is X.Y.Z' output", () => {
const capture = () => "ollama version is 0.6.2";
expect(getInstalledOllamaVersion(capture)).toBe("0.6.2");
});

it("returns null when ollama --version produces no output", () => {
const capture = () => "";
expect(getInstalledOllamaVersion(capture)).toBeNull();
});

it("returns null when ollama --version output has no version", () => {
const capture = () => "ollama: command not found";
expect(getInstalledOllamaVersion(capture)).toBeNull();
});

it("treats null/missing versions as below the minimum", () => {
expect(isOllamaVersionAtLeast(null, MIN_OLLAMA_VERSION)).toBe(false);
});

it("treats 0.6.2 as below the 0.7.0 floor", () => {
expect(isOllamaVersionAtLeast("0.6.2", "0.7.0")).toBe(false);
});

it("treats 0.7.0 as meeting the 0.7.0 floor", () => {
expect(isOllamaVersionAtLeast("0.7.0", "0.7.0")).toBe(true);
});

it("treats 0.24.0 as above the 0.7.0 floor", () => {
expect(isOllamaVersionAtLeast("0.24.0", "0.7.0")).toBe(true);
});

it("treats 1.0.0 as above the 0.7.0 floor", () => {
expect(isOllamaVersionAtLeast("1.0.0", "0.7.0")).toBe(true);
});

it("returns false for unparseable version components", () => {
expect(isOllamaVersionAtLeast("not-a-version", "0.7.0")).toBe(false);
});
});
});
37 changes: 37 additions & 0 deletions src/lib/inference/local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,43 @@ export const QWEN3_6_OLLAMA_MODEL = assertRegistryTag("qwen3.6:35b");

export type RunCaptureFn = (cmd: string | string[], opts?: { ignoreError?: boolean }) => string;

/**
* Minimum Ollama version NemoClaw expects when reusing an existing host
* Ollama. Older versions ship GGUF/runner internals that crash on newer
* starter models (e.g. Ollama 0.6.2 cannot load `qwen3.6:35b` — runner
* exits with INVALIDARGUMENT in `ggml.GraphSize`, see NVIDIA/NemoClaw#4178).
* Bump this when starter-model recipes adopt a newer GGUF feature.
*/
export const MIN_OLLAMA_VERSION = "0.7.0";

export function getInstalledOllamaVersion(
runCaptureImpl?: RunCaptureFn,
): string | null {
const capture = runCaptureImpl ?? runCapture;
const out = capture(["ollama", "--version"], { ignoreError: true });
if (!out) return null;
const match = out.match(/(\d+)\.(\d+)\.(\d+)/);
return match ? match[0] : null;
}

export function isOllamaVersionAtLeast(
version: string | null,
minimum: string,
): boolean {
if (!version) return false;
const parts = version.split(".").map((v) => Number.parseInt(v, 10));
const min = minimum.split(".").map((v) => Number.parseInt(v, 10));
const len = Math.max(parts.length, min.length);
for (let i = 0; i < len; i += 1) {
const a = parts[i] ?? 0;
const b = min[i] ?? 0;
if (Number.isNaN(a) || Number.isNaN(b)) return false;
if (a > b) return true;
if (a < b) return false;
}
return true;
}

export type RunCaptureExFn = (cmd: string[]) => CaptureResult;

// Hosts that the WSL-side onboard CLI tries when probing Ollama. Native Linux
Expand Down
36 changes: 31 additions & 5 deletions src/lib/onboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ const {
validateOllamaPortConfiguration,
validateOllamaModel,
validateLocalProvider,
getInstalledOllamaVersion,
isOllamaVersionAtLeast,
MIN_OLLAMA_VERSION,
} = localInference;
const {
ensureOllamaAuthProxy,
Expand Down Expand Up @@ -4219,7 +4222,14 @@ async function selectAndValidateOllamaModel(
},
);
if (validation.retry === "selection") return { outcome: "back-to-selection" };
if (!validation.ok) continue;
if (!validation.ok) {
// Non-interactive callers (express setup, NEMOCLAW_NON_INTERACTIVE=1)
// cannot escape this loop by picking another model. Surface the
// diagnostic the validator already printed and exit so the runner
// doesn't spin forever on the same starter list (#4178).
if (isNonInteractive()) process.exit(1);
continue;
}
// Ollama's /v1/responses endpoint does not produce correctly formatted
// tool calls — force chat completions like vLLM/NIM.
if (validation.api !== "openai-completions") {
Expand Down Expand Up @@ -4261,6 +4271,9 @@ async function setupNim(
// (#2674).
const localProbeCurlArgs = ["--connect-timeout", "2", "--max-time", "5"] as const;
const hasOllama = hostCommandExists("ollama");
const installedOllamaVersion = hasOllama ? getInstalledOllamaVersion() : null;
const hasUpgradableOllama =
hasOllama && !isOllamaVersionAtLeast(installedOllamaVersion, MIN_OLLAMA_VERSION);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
// run and consumed by the Ollama lifecycle helpers in inference/local.ts.
const ollamaHost = findReachableOllamaHost();
const ollamaRunning = ollamaHost !== null;
Expand Down Expand Up @@ -4377,14 +4390,27 @@ async function setupNim(
}
// Without any Ollama, offer to install one locally as a fallback (e.g. when
// the NVIDIA API server is down and cloud keys are unavailable).
if (!hasOllama && !ollamaRunning && !hasWindowsOllama) {
// Also offer when an existing Ollama is too old for the starter models
// NemoClaw ships, so the upgrade path runs the official `install.sh` and
// the user doesn't end up looping on a probe that the daemon can never
// pass (NVIDIA/NemoClaw#4178).
const showInstallOllama =
(!hasOllama && !ollamaRunning && !hasWindowsOllama) || hasUpgradableOllama;
if (showInstallOllama) {
const upgradeSuffix = hasUpgradableOllama
? ` — upgrade installed ${installedOllamaVersion ?? "unknown"} to ≥ ${MIN_OLLAMA_VERSION}`
: "";
const labelPrefix = hasUpgradableOllama ? "Upgrade Ollama" : "Install Ollama";
if (process.platform === "darwin") {
options.push({ key: "install-ollama", label: "Install Ollama (macOS)" });
options.push({ key: "install-ollama", label: `${labelPrefix} (macOS)${upgradeSuffix}` });
} else if (process.platform === "linux") {
if (isWsl()) {
options.push({ key: "install-ollama", label: "Install Ollama (WSL Linux)" });
options.push({
key: "install-ollama",
label: `${labelPrefix} (WSL Linux)${upgradeSuffix}`,
});
} else {
options.push({ key: "install-ollama", label: "Install Ollama (Linux)" });
options.push({ key: "install-ollama", label: `${labelPrefix} (Linux)${upgradeSuffix}` });
}
}
}
Expand Down
Loading