Skip to content

fix(onboard): force chat completions API for Ollama#1315

Merged
cv merged 9 commits intoNVIDIA:mainfrom
yimoj:fix/ollama-force-chat-completions-api
Apr 3, 2026
Merged

fix(onboard): force chat completions API for Ollama#1315
cv merged 9 commits intoNVIDIA:mainfrom
yimoj:fix/ollama-force-chat-completions-api

Conversation

@yimoj
Copy link
Copy Markdown
Contributor

@yimoj yimoj commented Apr 2, 2026

Summary

Test plan

  • npx vitest run test/onboard-selection.test.js — all 26 tests pass
  • npx vitest run test/onboard.test.js — all 43 tests pass
  • Live repro with Ollama 0.19.0 + qwen2.5:0.5b confirms setupNim() now returns openai-completions
  • Manual TUI test: nemoclaw onboard with local Ollama, then send a tool-using prompt in the TUI

Closes #1211

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Local Ollama onboarding now consistently selects the OpenAI-style completions inference route; an informational message may be logged when a non-chat API is detected.
  • Tests

    • Onboarding tests updated to expect the enforced completions-route selection for local Ollama.

Signed-off-by: Yimo yimoj@nvidia.com

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 2026

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
📝 Walkthrough

Walkthrough

Local Ollama onboarding now stops propagating the validated API choice and instead always sets preferredInferenceApi to "openai-completions" after successful OpenAI-like validation; the onboard-selection test expectation was updated accordingly.

Changes

Cohort / File(s) Summary
Ollama API Selection Logic
bin/lib/onboard.js
In setupNim(gpu) for local Ollama, after validateOpenAiLikeSelection(...) succeeds the code may log when validation.api !== "openai-completions" and then unconditionally sets preferredInferenceApi = "openai-completions", altering the chosen inference API routing.
Test Expectations
test/onboard-selection.test.js
Updated test assertion to expect payload.result.preferredInferenceApi === "openai-completions" for the Ollama-local onboard-selection test (was "openai-responses").

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through lines at break of dawn,
Swapped responses for completions on the lawn,
A tiny change, a steady stride,
Ollama's route now picks a single guide,
The rabbit smiles, the logs hum on.

🚥 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 'fix(onboard): force chat completions API for Ollama' clearly and concisely describes the main change: forcing the openai-completions API for Ollama during onboarding to fix malformed tool call issues.
Linked Issues check ✅ Passed The code changes directly address issue #1211 by forcing preferredInferenceApi to 'openai-completions' for Ollama onboard paths, preventing malformed tool calls that occurred with the /v1/responses endpoint in Ollama 0.19.0.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing Ollama API selection in the onboarding flow and updating the corresponding test assertion; no unrelated changes are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Ollama 0.19.0 added a /v1/responses endpoint that passes the onboard
probe but produces malformed tool calls in the TUI. Force
openai-completions for both Ollama code paths, matching the existing
vLLM and NIM behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@yimoj yimoj force-pushed the fix/ollama-force-chat-completions-api branch from 4974cc8 to 2775cdd Compare April 2, 2026 10:18
Copy link
Copy Markdown
Contributor

@prekshivyas prekshivyas left a comment

Choose a reason for hiding this comment

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

Nice catch and clean fix — thanks @yimoj!

  • Root cause correctly identified: Ollama 0.19.0's /v1/responses endpoint passes the probe but produces malformed tool calls in practice ✓
  • Fix matches the existing vLLM/NIM override pattern ✓
  • Applied to both Ollama onboard paths (existing install + brew install) ✓
  • Test updated to assert the correct openai-completions value ✓
  • Informational log only when actually overriding — good UX ✓

Minor: the 7-line override block is duplicated across both paths, but that matches the existing code style and isn't worth blocking on.

LGTM.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
bin/lib/onboard.js (1)

2787-2794: Correct fix, though there's code duplication with the other Ollama path.

This block is identical to lines 2735–2742. The entire Ollama model selection loop is duplicated between the "existing Ollama" and "brew install" paths, so this follows the existing pattern. Consider extracting the shared Ollama onboarding logic into a helper function in a future cleanup to reduce duplication.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bin/lib/onboard.js` around lines 2787 - 2794, The Ollama onboarding logic
that forces chat completions (checks validation.api !== "openai-completions",
logs the message, and sets preferredInferenceApi = "openai-completions") is
duplicated between the "existing Ollama" and "brew install" code paths; refactor
by extracting that shared block into a helper function (e.g.,
ensureOllamaUsesChatCompletions or setPreferredOllamaInference) and call it from
both places, moving the validation.api check, console.log message, and
preferredInferenceApi assignment into the new helper to eliminate duplication
while preserving behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@bin/lib/onboard.js`:
- Around line 2787-2794: The Ollama onboarding logic that forces chat
completions (checks validation.api !== "openai-completions", logs the message,
and sets preferredInferenceApi = "openai-completions") is duplicated between the
"existing Ollama" and "brew install" code paths; refactor by extracting that
shared block into a helper function (e.g., ensureOllamaUsesChatCompletions or
setPreferredOllamaInference) and call it from both places, moving the
validation.api check, console.log message, and preferredInferenceApi assignment
into the new helper to eliminate duplication while preserving behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 854a3254-511a-4689-b136-1b1392e3b87c

📥 Commits

Reviewing files that changed from the base of the PR and between c619514 and 3dfb30b.

📒 Files selected for processing (1)
  • bin/lib/onboard.js

@cv cv enabled auto-merge (squash) April 2, 2026 23:23
@wscurran wscurran added bug Something isn't working Local Models Running NemoClaw with local models Provider: OpenAI Use this label to identify issues with the OpenAI provider integration. labels Apr 3, 2026
@cv cv merged commit 1120c2b into NVIDIA:main Apr 3, 2026
8 checks passed
quanticsoul4772 added a commit to quanticsoul4772/NemoClaw that referenced this pull request Apr 4, 2026
…ions API

Two upstream bug fixes backported from NVIDIA/NemoClaw:
- preflight.js: `port || 18789` → `port ?? 18789` so port=0 (OS-assigned)
  is not incorrectly replaced by the default (upstream NVIDIA#1304)
- onboard.js: Force openai-completions for Ollama regardless of probe result.
  Ollama 0.19.0 /v1/responses endpoint passes probe but produces malformed
  tool calls in the TUI. Matches existing vLLM/NIM override pattern.
  Update test assertion that was asserting the buggy value (upstream NVIDIA#1315)
lakamsani pushed a commit to lakamsani/NemoClaw that referenced this pull request Apr 4, 2026
## Summary
- Ollama 0.19.0 added a `/v1/responses` endpoint that passes the onboard
probe but produces malformed tool calls in the TUI, causing schema
validation failures and nonsensical fallback text (NVIDIA#1211)
- Force `preferredInferenceApi` to `openai-completions` for both Ollama
onboard paths (existing install and brew install), matching the existing
vLLM and NIM override pattern
- Fix test assertion that was asserting the buggy `openai-responses`
value since the validation feature was first added in NVIDIA#648

## Test plan
- [x] `npx vitest run test/onboard-selection.test.js` — all 26 tests
pass
- [x] `npx vitest run test/onboard.test.js` — all 43 tests pass
- [x] Live repro with Ollama 0.19.0 + qwen2.5:0.5b confirms `setupNim()`
now returns `openai-completions`
- [ ] Manual TUI test: `nemoclaw onboard` with local Ollama, then send a
tool-using prompt in the TUI

Closes NVIDIA#1211

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

* **Bug Fixes**
* Local Ollama onboarding now consistently selects the OpenAI-style
completions inference route; an informational message may be logged when
a non-chat API is detected.

* **Tests**
* Onboarding tests updated to expect the enforced completions-route
selection for local Ollama.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Signed-off-by: Yimo <yimoj@nvidia.com>

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Prekshi Vyas <34834085+prekshivyas@users.noreply.github.com>
@yimoj yimoj deleted the fix/ollama-force-chat-completions-api branch April 7, 2026 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Local Models Running NemoClaw with local models Provider: OpenAI Use this label to identify issues with the OpenAI provider integration.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openclaw tui emits malformed tool calls on local Ollama (macOS) even when health checks and one-shot agent runs succeed

4 participants