Skip to content

fix: verify Ollama model discovery after pull - #6075

Closed
HOYALIM wants to merge 2 commits into
NVIDIA:mainfrom
HOYALIM:codex/issue-6038-ollama-empty-onboard
Closed

fix: verify Ollama model discovery after pull#6075
HOYALIM wants to merge 2 commits into
NVIDIA:mainfrom
HOYALIM:codex/issue-6038-ollama-empty-onboard

Conversation

@HOYALIM

@HOYALIM HOYALIM commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Makes Ollama onboarding confirm that a just-pulled model is visible in local discovery before continuing, so a zero-exit pull that has not registered yet does not silently produce a broken route.
The current-main salvage also treats an omitted model tag as :latest and preserves the newer onboarding test structure.

Related Issue

Closes #6038

Changes

  • Poll Ollama discovery after a successful pull before accepting the selected model.
  • Return a clear reprompt message when a pulled model never appears in discovery.
  • Treat untagged model references as equivalent to Ollama's canonical :latest listing.
  • Add focused delayed-discovery, retry-budget, reference-normalization, pull-failure, and reprompt coverage.
  • Preserve current-main onboarding test refactors and ratchet the existing test-file budget downward.

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)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification: existing Ollama docs already state that onboarding pulls, loads, and validates the selected model before continuing; this change enforces that contract.
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging) — local Ollama onboarding and inference preparation.
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification:
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Verification

  • PR description includes the DCO sign-off declaration and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run check:diff passed when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — command/result or justification: npx vitest run --project cli src/lib/inference/ollama/proxy.test.ts passed 12/12; npx vitest run --project integration test/onboard-selection.test.ts -t "Ollama" passed 23/23 with 41 unrelated tests skipped; npm run typecheck:cli, Biome, test-size, and conditional scans passed.
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result:
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • 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: Ho Lim subhoya@gmail.com

Summary by CodeRabbit

  • New Features

    • Ollama onboarding now waits for newly pulled models to appear before continuing, reducing false “not installed” states.
    • Model detection is more flexible and now handles common tag variations more consistently.
  • Bug Fixes

    • Improved handling for cases where a model pull succeeds but the model is not immediately listed.
    • Added better failure feedback when onboarding cannot confirm the pulled model is available.

Copilot AI review requested due to automatic review settings June 30, 2026 23:45
@copy-pr-bot

copy-pr-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 341f1f11-706b-4c53-963e-a0d9f8eee737

📥 Commits

Reviewing files that changed from the base of the PR and between ba2211b and bd1ce43.

📒 Files selected for processing (3)
  • ci/test-file-size-budget.json
  • src/lib/inference/ollama/proxy.test.ts
  • src/lib/inference/ollama/proxy.ts
💤 Files with no reviewable changes (2)
  • src/lib/inference/ollama/proxy.ts
  • src/lib/inference/ollama/proxy.test.ts
✅ Files skipped from review due to trivial changes (1)
  • ci/test-file-size-budget.json

📝 Walkthrough

Walkthrough

Adds a post-pull verification step in Ollama model preparation that polls model discovery with exponential backoff and matches model references with tag normalization, updates prepareOllamaModel to use this check and return an error when unlisted, and updates related proxy and onboarding tests accordingly.

Changes

Ollama post-pull model registration check

Layer / File(s) Summary
Post-pull verification implementation in proxy
src/lib/inference/ollama/proxy.ts
Adds waitForPulledOllamaModel (exponential-backoff polling of getOllamaModelOptions()), model-ref normalization/matching helpers, wires the check into prepareOllamaModel after a successful pull, updates installed-model detection to use ref matching, adds a doc comment, and exports the new helper.
Proxy unit tests for waitForPulledOllamaModel
src/lib/inference/ollama/proxy.test.ts
Extends the mock harness with vi, conditional spawnSync mocking via pullStatus, dynamic installed-model lists, updated cleanup, and a new test suite covering delayed discovery, reference matching, retry exhaustion, and pull-failure precedence.
Onboard-selection test updates for post-pull listing
test/onboard-selection.test.ts, ci/test-file-size-budget.json
Removes an outdated starter-model pull test, adds pullLog-based conditional ollama list mocks across pull-failure, decline-confirmation, and NEMOCLAW_YES bypass flows, and lowers the legacy line-count budget.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant prepareOllamaModel
  participant pullOllamaModel
  participant waitForPulledOllamaModel
  participant getOllamaModelOptions

  prepareOllamaModel->>pullOllamaModel: pull(model)
  pullOllamaModel-->>prepareOllamaModel: pull success
  prepareOllamaModel->>waitForPulledOllamaModel: verify registration(model)
  loop retry with exponential backoff (up to 8 attempts)
    waitForPulledOllamaModel->>getOllamaModelOptions: poll installed models
    getOllamaModelOptions-->>waitForPulledOllamaModel: model list
  end
  alt model listed (ref match)
    waitForPulledOllamaModel-->>prepareOllamaModel: true
    prepareOllamaModel-->>prepareOllamaModel: ok: true
  else not listed after retries
    waitForPulledOllamaModel-->>prepareOllamaModel: false
    prepareOllamaModel-->>prepareOllamaModel: ok: false, "not listed yet"
  end
Loading

Suggested reviewers: ericksoa

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: verifying Ollama model discovery after a pull.
Linked Issues check ✅ Passed The PR matches #6038 by pulling the selected Ollama model and waiting for it to appear before onboarding proceeds.
Out of Scope Changes check ✅ Passed The extra test and budget-file edits support the Ollama onboarding fix and regression coverage, with no unrelated scope visible.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@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/onboard-ollama-pull-registration.test.ts (1)

60-70: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate fake ollama binary script across both tests.

The fake ollama pull-stub script (lines 60-70 and 167-177) is byte-for-byte identical between the two test cases, while writeAlwaysOkCurl was already extracted as a shared helper for the analogous curl stub. Extracting an equivalent writeAlwaysOkOllama(fakeBin, pullLog) helper would keep the file consistent and reduce duplication.

♻️ Suggested helper extraction
+function writeAlwaysOkOllama(fakeBin: string, pullLog: string) {
+  fs.writeFileSync(
+    path.join(fakeBin, "ollama"),
+    `#!/usr/bin/env bash
+if [ "$1" = "pull" ]; then
+  echo "$2" >> ${JSON.stringify(pullLog)}
+  exit 0
+fi
+exit 0
+`,
+    { mode: 0o755 },
+  );
+}

Then replace both inline fs.writeFileSync(path.join(fakeBin, "ollama"), ...) blocks with writeAlwaysOkOllama(fakeBin, pullLog);.

Also applies to: 167-177

🤖 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/onboard-ollama-pull-registration.test.ts` around lines 60 - 70, The fake
ollama pull stub is duplicated in both test cases, so extract it into a shared
helper alongside writeAlwaysOkCurl. Add a writeAlwaysOkOllama(fakeBin, pullLog)
helper that writes the same executable ollama script used by both tests, then
replace each inline fs.writeFileSync(path.join(fakeBin, "ollama"), ...) block
with the helper call to keep the test file consistent and remove duplication.
🤖 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/onboard-ollama-pull-registration.test.ts`:
- Around line 60-70: The fake ollama pull stub is duplicated in both test cases,
so extract it into a shared helper alongside writeAlwaysOkCurl. Add a
writeAlwaysOkOllama(fakeBin, pullLog) helper that writes the same executable
ollama script used by both tests, then replace each inline
fs.writeFileSync(path.join(fakeBin, "ollama"), ...) block with the helper call
to keep the test file consistent and remove duplication.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 9a9fc8e1-ade9-4aaa-900e-e56cd3ac785d

📥 Commits

Reviewing files that changed from the base of the PR and between e4b9111 and 4b2a913.

📒 Files selected for processing (4)
  • ci/test-file-size-budget.json
  • src/lib/inference/ollama/proxy.ts
  • test/onboard-ollama-pull-registration.test.ts
  • test/onboard-selection.test.ts

@HOYALIM
HOYALIM force-pushed the codex/issue-6038-ollama-empty-onboard branch from 4b2a913 to b425d5a Compare June 30, 2026 23:54
@wscurran wscurran added area: local-models Local model providers, downloads, launch, or connectivity area: onboarding Onboarding FSM, provider setup, sandbox launch, or first-run flow bug-fix PR fixes a bug or regression provider: ollama Ollama local model provider behavior labels Jul 1, 2026
@wscurran

wscurran commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

✨ Thanks for the fix. Verifying Ollama model discovery after pull prevents silent broken routes during onboarding.


Related open issues:

@HOYALIM
HOYALIM force-pushed the codex/issue-6038-ollama-empty-onboard branch from b425d5a to 78ecae5 Compare July 6, 2026 14:53
Signed-off-by: Ho Lim <subhoya@gmail.com>
@HOYALIM
HOYALIM force-pushed the codex/issue-6038-ollama-empty-onboard branch from 78ecae5 to ba2211b Compare July 6, 2026 15:00
@cv cv added the v0.0.76 label Jul 7, 2026

@cv cv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please rebase or port the narrow post-pull discovery fix onto current main. This branch conflicts, and its stale 253-line test reshuffle would overwrite newer onboarding test-performance refactors from #6276 and #6336. Preserve those mainline changes and submit only the behavior needed for #6038; CI and advisor must then run.

@cjagwani

cjagwani commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Current-main replacement opened as #6481.

It preserves Ho Lim as the signed commit author and ports only the #6038 behavior: bounded post-pull discovery, a clear retry path when the model never appears, focused wait tests, and net-zero updates to the existing onboarding fixtures. The stale 253-line test reshuffle and conflicts with current test-performance work are not carried forward.

Local replacement-head validation: build/typecheck, 7 proxy tests, all 64 onboarding-selection tests, Biome, and the test-size guard passed. I will close this conflicted branch once #6481's exact-head CI settles.

Port the verified contributor change onto current main without the stale test split.

Add delayed-discovery, retry, and implicit latest-tag coverage.

Signed-off-by: Carlos Villela <cvillela@nvidia.com>
@cv

cv commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cjagwani

cjagwani commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Superseded for v0.0.78 by #6481, which preserves Ho Lim's original fix and attribution while adding bounded discovery polling, canonical implicit-latest matching, fail-closed timeout behavior, typed preparation isolation, exact status coverage, and current-main integration. Replacement exact signed head 80b5734862f53bc1545af3951ce72fae9e384e12 is fully green and independently review-ready; continuing release review there.

@cjagwani cjagwani closed this Jul 8, 2026
cv added a commit that referenced this pull request Jul 8, 2026
<!-- markdownlint-disable MD041 -->
## Summary

Confirms that Ollama exposes a newly pulled model before onboarding
accepts the route. This is a current-main replacement for #6075 that
preserves Ho Lim's original authorship without carrying the conflicted
test reshuffle.

## Related Issue

Fixes #6038.

## Changes

- Poll Ollama model discovery with bounded exponential backoff after a
successful pull.
- Return to model selection with a clear error when the daemon never
lists the pulled model.
- Treat omitted model tags as Ollama's canonical `:latest` form across
pull authorization and post-pull discovery.
- Keep model-reference, pull-readiness, and bounded discovery logic in a
focused typed module.\n- Remove the legacy `@ts-nocheck` from `proxy.ts`
while shrinking that hotspot below its main-branch line count.
- Add deterministic wait success/exhaustion tests plus integrated
delayed-registration and zero-exit/unlisted reprompt coverage.
- Update existing successful-pull onboarding fixtures without growing
the legacy test file.

## Type of Change

- [x] Code change (bug fix)
- [ ] Code change with doc updates
- [ ] Doc only

## Quality Gates

- [x] Tests added or updated for changed behavior
- [x] Docs not applicable — this corrects existing onboarding behavior
and error handling
- [x] Sensitive paths changed — local Ollama onboarding and inference
preparation.
- [x] No secrets, API keys, or credentials committed

## Notes

The registration-wait status and post-pull failure message make an
existing onboarding contract explicit. The current Ollama docs already
describe pull, load, and validation, so this reliability fix adds no new
command, option, or workflow.

## Verification

- [x] `npm run build:cli`
- [x] `npm run typecheck:cli`
- [x] `model-discovery.test.ts` + `proxy.test.ts` — 18/18 passed
- [x] `test/onboard-selection.test.ts` — 64/64 passed
- [x] Biome format and lint on all touched files
- [x] `proxy.ts` shrank from 972 to 969 lines and now passes CLI
type-checking without `@ts-nocheck`\n- [x] `npm run
test-conditionals:scan -- --top 25`\n- [x] `npm run test-size:check`
- [x] All commits are signed and the original contributor remains the
first commit author

---
Signed-off-by: Ho Lim <subhoya@gmail.com>
Signed-off-by: cjagwani <cjagwani@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>


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

* **New Features**
* Enhanced Ollama model recognition to handle implied or differently
formatted tags (e.g., `latest`) during selection and onboarding.
* Added a post-pull discovery retry flow that waits for a newly pulled
model to become available before proceeding.

* **Bug Fixes**
* Fixed cases where onboarding could continue before the model appeared
in Ollama, leading to “model not found” and inconsistent recovery
behavior.

* **Tests**
* Expanded coverage for pull completion, discovery retries, and
deterministic onboarding scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Ho Lim <subhoya@gmail.com>
Signed-off-by: cjagwani <cjagwani@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Co-authored-by: Ho Lim <subhoya@gmail.com>
Co-authored-by: Carlos Villela <cvillela@nvidia.com>
Hadar301 pushed a commit to Hadar301/NemoClaw-OpenShift that referenced this pull request Jul 12, 2026
<!-- markdownlint-disable MD041 -->
## Summary

Confirms that Ollama exposes a newly pulled model before onboarding
accepts the route. This is a current-main replacement for NVIDIA#6075 that
preserves Ho Lim's original authorship without carrying the conflicted
test reshuffle.

## Related Issue

Fixes NVIDIA#6038.

## Changes

- Poll Ollama model discovery with bounded exponential backoff after a
successful pull.
- Return to model selection with a clear error when the daemon never
lists the pulled model.
- Treat omitted model tags as Ollama's canonical `:latest` form across
pull authorization and post-pull discovery.
- Keep model-reference, pull-readiness, and bounded discovery logic in a
focused typed module.\n- Remove the legacy `@ts-nocheck` from `proxy.ts`
while shrinking that hotspot below its main-branch line count.
- Add deterministic wait success/exhaustion tests plus integrated
delayed-registration and zero-exit/unlisted reprompt coverage.
- Update existing successful-pull onboarding fixtures without growing
the legacy test file.

## Type of Change

- [x] Code change (bug fix)
- [ ] Code change with doc updates
- [ ] Doc only

## Quality Gates

- [x] Tests added or updated for changed behavior
- [x] Docs not applicable — this corrects existing onboarding behavior
and error handling
- [x] Sensitive paths changed — local Ollama onboarding and inference
preparation.
- [x] No secrets, API keys, or credentials committed

## Notes

The registration-wait status and post-pull failure message make an
existing onboarding contract explicit. The current Ollama docs already
describe pull, load, and validation, so this reliability fix adds no new
command, option, or workflow.

## Verification

- [x] `npm run build:cli`
- [x] `npm run typecheck:cli`
- [x] `model-discovery.test.ts` + `proxy.test.ts` — 18/18 passed
- [x] `test/onboard-selection.test.ts` — 64/64 passed
- [x] Biome format and lint on all touched files
- [x] `proxy.ts` shrank from 972 to 969 lines and now passes CLI
type-checking without `@ts-nocheck`\n- [x] `npm run
test-conditionals:scan -- --top 25`\n- [x] `npm run test-size:check`
- [x] All commits are signed and the original contributor remains the
first commit author

---
Signed-off-by: Ho Lim <subhoya@gmail.com>
Signed-off-by: cjagwani <cjagwani@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>


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

* **New Features**
* Enhanced Ollama model recognition to handle implied or differently
formatted tags (e.g., `latest`) during selection and onboarding.
* Added a post-pull discovery retry flow that waits for a newly pulled
model to become available before proceeding.

* **Bug Fixes**
* Fixed cases where onboarding could continue before the model appeared
in Ollama, leading to “model not found” and inconsistent recovery
behavior.

* **Tests**
* Expanded coverage for pull completion, discovery retries, and
deterministic onboarding scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Ho Lim <subhoya@gmail.com>
Signed-off-by: cjagwani <cjagwani@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Co-authored-by: Ho Lim <subhoya@gmail.com>
Co-authored-by: Carlos Villela <cvillela@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: local-models Local model providers, downloads, launch, or connectivity area: onboarding Onboarding FSM, provider setup, sandbox launch, or first-run flow bug-fix PR fixes a bug or regression provider: ollama Ollama local model provider behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Multiple Platforms][Onboard] NemoClaw does not pull Ollama model during onboard when no models are present

6 participants