Skip to content

feat(onboard): pull Ollama models via HTTP when reaching Windows host - #2768

Merged
ericksoa merged 3 commits into
mainfrom
feat/wsl-ollama-http-pull
Apr 30, 2026
Merged

ericksoa merged 3 commits into
mainfrom
feat/wsl-ollama-http-pull

Conversation

@zyang-dev

@zyang-dev zyang-dev commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When Ollama runs on the Windows host (now detected from WSL via host.docker.internal after #2707), nemoclaw onboard could detect it but couldn't pull new models because pullOllamaModel shells out to the ollama CLI. This PR adds an HTTP /api/pull path that runs only when the resolved host is host.docker.internal. Native Linux/macOS keeps the existing CLI shell-out unchanged.

Changes

  • src/lib/onboard-ollama-proxy.ts:
    • Renamed existing pullOllamaModel to pullOllamaModelViaCli (no logic change).
    • Added pullOllamaModelViaHttp(model): streams POST /api/pull via curl with --connect-timeout 10 --max-time 600, parses NDJSON, renders an in-place progress bar with throttled status updates. Falls back to throttled per-line output when stdout is not a TTY.
    • Added async dispatcher pullOllamaModel: routes to HTTP only when getResolvedOllamaHost() ===OLLAMA_HOST_DOCKER_INTERNAL; otherwise CLI.
    • Made prepareOllamaModel async so the dispatcher can await.
    • Distinct timeout message on curl exit 28; resume hint on any non-zero exit (Already-downloaded layers are kept; re-running the pull resumes them.).
  • src/lib/onboard.ts: two prepareOllamaModel callers updated to await.

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)

Verification

  • npx prek run --all-files passes
  • npm test passes
  • Tests added or updated for new or changed behavior
  • No secrets, API keys, or credentials committed
  • Docs updated for user-facing behavior changes
  • make 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)

AI Disclosure

  • AI-assisted — tool: Claude Code

Signed-off-by: zyang-dev [email protected]

Summary by CodeRabbit

  • New Features

    • Asynchronous model pulling with real-time streamed progress and condensed non-interactive status updates.
    • Automatic selection of an HTTP-based pull strategy for Windows/Docker hosts to improve compatibility.
  • Bug Fixes

    • Pull results are now awaited before proceeding, ensuring accurate success/failure handling.
    • Improved error reporting that clearly distinguishes timeouts from other connection failures.

@coderabbitai

coderabbitai Bot commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

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: 6440074b-2ef3-4b1d-b0c4-6d6af2cc0fd0

📥 Commits

Reviewing files that changed from the base of the PR and between 36cbc1d and c003a34.

📒 Files selected for processing (1)
  • src/lib/onboard.ts

📝 Walkthrough

Walkthrough

Model-pull logic for Ollama is refactored: a new async pullOllamaModel dispatcher chooses between an HTTP streaming /api/pull path (for Windows/Docker-internal hosts) and the existing CLI ollama pull. Onboarding now awaits the pull result before proceeding.

Changes

Cohort / File(s) Summary
Ollama Model Pulling Refactor
src/lib/onboard-ollama-proxy.ts
Reworked pullOllamaModel into an async dispatcher that selects pullOllamaModelViaHttp (HTTP POST to http://<host>:<OLLAMA_PORT>/api/pull with streamed JSON event parsing, TTY-aware progress, and curl exit-code handling including timeout 28) or pullOllamaModelViaCli (existing ollama pull). prepareOllamaModel now awaits the pull attempt before returning failure.
Awaiting Pull in Onboarding
src/lib/onboard.ts
Updated setupNim paths to await prepareOllamaModel(...) so callers evaluate the resolved { ok, message, ... } probe result before continuing.

Sequence Diagram(s)

sequenceDiagram
    participant Onboard as Onboarding
    participant Dispatcher as pullOllamaModel
    participant HTTP as "Ollama HTTP API"
    participant CLI as "ollama CLI"
    participant TTY as "Output / TTY"

    Onboard->>Dispatcher: prepareOllamaModel(host, model)
    alt host resolves to Windows/Docker-internal
        Dispatcher->>HTTP: POST /api/pull (stream)
        HTTP->>HTTP: stream JSON events (progress/status/error)
        HTTP->>TTY: emit TTY/non-TTY updates
        TTY-->>Dispatcher: progress/status events -> final {ok,message}
    else other hosts
        Dispatcher->>CLI: run `ollama pull` (subprocess)
        CLI->>TTY: capture stdout/stderr
        TTY-->>Dispatcher: CLI output -> final {ok,message}
    end
    Dispatcher-->>Onboard: Promise resolves {ok, message}
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped between stream and shell with glee,

HTTP hummed for Windows, CLI for the spree,
Progress blinked on TTY, status softly told,
Async paws waited till success took hold,
A carrot cheer for pulls, neat and bold! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and accurately summarizes the main feature: adding HTTP-based model pulling when Ollama is on the Windows host, while preserving CLI behavior elsewhere.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/wsl-ollama-http-pull

Review rate limit: 9/10 reviews remaining, refill in 6 minutes.

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

@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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/lib/onboard-ollama-proxy.ts`:
- Around line 329-353: In pullOllamaModelViaHttp, the request body currently
uses { name: model } which is invalid for Ollama's /api/pull; change the payload
to use { model: model, stream: true } (or shorthand { model, stream: true })
when constructing the `body` passed to JSON.stringify so the API identifies the
model correctly; keep all other options (TIMEOUT_MS, curl args, etc.) unchanged.
- Around line 440-458: The handler currently attached to proc.on("exit", ...)
should be switched to proc.on("close", ...) so the promise resolves only after
the child process's stdio is fully drained; replace the "exit" listener with a
"close" listener while keeping the same logic that calls finishLine(), checks
sawError, inspects code (using TIMEOUT_MS and the code === 28 branch) and
resolves with sawSuccess, ensuring you preserve references to proc, finishLine,
sawError, sawSuccess and TIMEOUT_MS.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d8c89e14-5e7e-41f8-a1ee-272a081cf9b7

📥 Commits

Reviewing files that changed from the base of the PR and between 4b36acf and bf9bec8.

📒 Files selected for processing (2)
  • src/lib/onboard-ollama-proxy.ts
  • src/lib/onboard.ts

Comment thread src/lib/onboard-ollama-proxy.ts Resolved
Comment thread src/lib/onboard-ollama-proxy.ts Resolved
@cv cv added the v0.0.32 label Apr 30, 2026

@ericksoa ericksoa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed final diff and validated build/typecheck plus focused onboard/Ollama tests locally. Earlier CodeRabbit comments are addressed in 36cbc1d. No blocking findings.

@ericksoa
ericksoa merged commit a8a0b89 into main Apr 30, 2026
17 checks passed
@zyang-dev
zyang-dev deleted the feat/wsl-ollama-http-pull branch April 30, 2026 17:31
@miyoungc miyoungc mentioned this pull request Apr 30, 2026
5 of 13 tasks
cv pushed a commit that referenced this pull request Apr 30, 2026
## Summary
Updates NemoClaw documentation for the v0.0.32 release candidate,
covering user-facing changes that landed since v0.0.31 and promoting the
docs version switcher to 0.0.32.

## Changes
- Document Windows-host Ollama support from WSL, including HTTP model
pulls and avoiding duplicate Ollama instances on port 11434. Matches dev
PR #2768.
- Add Ollama GPU memory cleanup behavior for provider switches, service
stops, and sandbox destroy. Matches dev PR #2651.
- Document Hugging Face token forwarding for remote deploy workflows
that pull gated model repositories. Matches dev PR #2729.
- Add runtime sandbox and policy context injection to the architecture
reference. Matches dev PR #2751.
- Bump `docs/versions1.json` and regenerated `docs/project.json` to
0.0.32 for release prep. No separate dev PR.

## Type of Change
- [ ] Code change (feature, bug fix, or refactor)
- [ ] Code change with doc updates
- [ ] Doc only (prose changes, no code sample modifications)
- [x] Doc only (includes code sample changes)

## Verification
- [ ] `npx prek run --all-files` passes
- [ ] `npm test` passes
- [ ] Tests added or updated for new or changed behavior
- [x] No secrets, API keys, or credentials committed
- [x] Docs updated for user-facing behavior changes
- [ ] `make docs` builds without warnings (doc changes only)
- [x] Doc pages follow the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md)
(doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages only)

## AI Disclosure
- [x] AI-assisted — tool: Cursor

---
Signed-off-by: Miyoung Choi <[email protected]>

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

## Summary by CodeRabbit

* **Documentation**
  * Added guidance for deploying with Hugging Face gated models
  * Improved Windows/WSL Ollama configuration instructions
  * Documented GPU memory cleanup behavior during model transitions
  * Enhanced architecture and command reference documentation
  * Version bumped to 0.0.32

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@wscurran wscurran added the feature PR adds or expands user-visible functionality label Jun 8, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Jul 6, 2026
8 of 21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature PR adds or expands user-visible functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants