-
Notifications
You must be signed in to change notification settings - Fork 3.1k
fix(onboard): gate Ollama auto-start behind --no-ollama-autostart #4212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ericksoa
merged 7 commits into
NVIDIA:main
from
TonyLuo-NV:fix/3751-ollama-autostart-gate
May 27, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f1eceac
fix(onboard): gate Ollama auto-start behind --no-ollama-autostart
TonyLuo-NV 3686f28
refactor(onboard): extract Ollama startup gate to dedicated module
TonyLuo-NV d534133
fix(onboard): keep onboard.ts within entrypoint budget
TonyLuo-NV 32e52ba
fix(onboard): register --no-ollama-autostart on the oclif onboard com…
TonyLuo-NV 1712b40
Merge branch 'main' into fix/3751-ollama-autostart-gate
TonyLuo-NV 9fcd45a
fix(onboard): narrow --no-ollama-autostart scope; abort on pinned pro…
TonyLuo-NV 3404c20
Merge branch 'main' into fix/3751-ollama-autostart-gate
ericksoa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| const runner: typeof import("../runner") = require("../runner"); | ||
| const wait: typeof import("../core/wait") = require("../core/wait"); | ||
| const localInference: typeof import("../inference/local") = require("../inference/local"); | ||
|
|
||
| let NO_OLLAMA_AUTOSTART = false; | ||
|
|
||
| export function setOllamaAutostartDisabled(value: boolean | undefined): void { | ||
| NO_OLLAMA_AUTOSTART = !!value; | ||
| } | ||
|
|
||
| export function isOllamaAutostartDisabled(): boolean { | ||
| return NO_OLLAMA_AUTOSTART || process.env.NEMOCLAW_OLLAMA_NO_AUTOSTART === "1"; | ||
| } | ||
|
|
||
| export type OllamaFallbackResult = { | ||
| provider: "ollama-local"; | ||
| credentialEnv: null; | ||
| endpointUrl: string; | ||
| model: string; | ||
| preferredInferenceApi: "openai-completions"; | ||
| }; | ||
|
|
||
| export type OllamaStartupOutcome = | ||
| | { kind: "ready" } | ||
| | { kind: "continue" } | ||
| | { kind: "fallback"; result: OllamaFallbackResult }; | ||
|
|
||
| export function runOllamaStartupOrGate(args: { | ||
| ollamaReady: boolean; | ||
| ollamaPort: number; | ||
| getLocalProviderBaseUrl: (provider: "ollama-local") => string | null; | ||
| isNonInteractive: () => boolean; | ||
| }): OllamaStartupOutcome { | ||
| const { ollamaReady, ollamaPort, getLocalProviderBaseUrl, isNonInteractive } = args; | ||
| if (ollamaReady) return { kind: "ready" }; | ||
| if (isOllamaAutostartDisabled()) { | ||
| console.log( | ||
| " ⚠ Ollama is not running on localhost:" + | ||
| `${ollamaPort} and --no-ollama-autostart is set; ` + | ||
| "skipping auto-start and falling back to the default model.", | ||
| ); | ||
| const endpointUrl = getLocalProviderBaseUrl("ollama-local"); | ||
| if (!endpointUrl) { | ||
| console.error(" Local Ollama base URL could not be determined."); | ||
| process.exit(1); | ||
| } | ||
| return { | ||
| kind: "fallback", | ||
| result: { | ||
| provider: "ollama-local", | ||
| credentialEnv: null, | ||
| endpointUrl, | ||
| model: localInference.DEFAULT_OLLAMA_MODEL, | ||
| preferredInferenceApi: "openai-completions", | ||
| }, | ||
| }; | ||
| } | ||
| console.log(" Starting Ollama..."); | ||
| runner.runShell(`OLLAMA_HOST=127.0.0.1:${ollamaPort} ollama serve > /dev/null 2>&1 &`, { | ||
| ignoreError: true, | ||
| }); | ||
| if (!wait.waitForHttp(`http://127.0.0.1:${ollamaPort}/`, 10)) { | ||
| console.error(` Ollama did not become ready on :${ollamaPort} within timeout.`); | ||
| const providerPinned = process.env.NEMOCLAW_PROVIDER === "ollama"; | ||
| if (isNonInteractive() || providerPinned) { | ||
| if (providerPinned) { | ||
| console.error( | ||
| " NEMOCLAW_PROVIDER=ollama is pinned but Ollama is unreachable; refusing to loop on provider selection.", | ||
| ); | ||
| } | ||
| process.exit(1); | ||
| } | ||
| return { kind: "continue" }; | ||
| } | ||
| return { kind: "ready" }; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.