Skip to content

Remove the Ollama-native inference path: drive Ollama through its OpenAI-compatible endpoint #1793

Closed

Description

@malibio

Overview

Repurposed. This issue originally proposed adding a request timeout to OllamaInferenceEngine's reqwest::Client. That fix is superseded: we have decided to drive Ollama through its OpenAI-compatible endpoint rather than its native API, so the client being hardened is one we intend to delete. Adding a timeout would harden code on its way out.

The original defect is real and stated below for the record — it disappears with the removal.

Decision

Ollama exposes an OpenAI-compatible API (/v1). OpenAiCompatInferenceEngine already exists, is wired into production, and covers that protocol. Maintaining a second, Ollama-native client duplicates the same capability against a bespoke wire format.

Per the greenfield rule in CLAUDE.md — no deprecation, no feature flags for compatibility, delete replaced patterns outright — the native path is removed rather than flagged.

Scope

Delete (~1,130 lines production):

  • packages/agent/src/local_agent/ollama_inference.rs (495)
  • packages/agent/src/local_agent/ollama_ndjson.rs (183) — NDJSON streaming, specific to Ollama's native format
  • packages/agent/src/local_agent/ollama_model_manager.rs (453)

Delete (~1,843 lines test):

  • packages/agent/tests/ollama_integration.rs
  • Ollama-specific paths in packages/agent/tests/search_skills_latency.rs:40,81,90

Rework, do not delete:

  • packages/agent/src/local_agent/composite_model_manager.rs:13,32 — holds Arc<OllamaModelManager> as a field; the composite needs restructuring, not just an import removed
  • packages/daemon/src/services/local_agent_service.rs:1054,1189 — the branch selecting OllamaInferenceEngine::with_base_url collapses into the existing OpenAiCompatInferenceEngine branch at :1117
  • packages/agent/src/local_agent/model_manager.rs:396 — ModelFamily::Ollama | ModelFamily::OpenAiCompat arm loses one variant
  • packages/agent/src/agent_types.rs:253 — ModelFamily::Ollama variant

Frontend (coupling is thin):

  • packages/desktop-app/src/lib/types/agent-types.ts:19 — ModelFamily union drops 'ollama'
  • Display/selector strings in model-store.svelte.ts, model-manager.svelte, ai-chat-model-selector.svelte, tauri-commands.ts, ai-chat-node.ts
  • Corresponding test updates in src/tests/components/ai-chat-model-selector.test.ts, src/tests/services/tauri-commands.test.ts

Also check: packages/core/src/models/ai_chat_node.rs, packages/core/src/behaviors/mod.rs, packages/nodespace-types/src/convert.rs, packages/agent/src/prompt_assembler.rs, packages/agent/src/agent_guidance.rs — all reference Ollama; confirm whether each is a family variant, a display string, or dead.

Open question to resolve first

OllamaModelManager provides model discovery (is_available(), base-url handling, progress callbacks) that OpenAiCompatInferenceEngine does not — the latter has no listing surface at all. Before deleting, decide how a user picks an Ollama model:

  • via /v1/models on the OpenAI-compatible endpoint (likely sufficient — it is part of the OpenAI protocol), or
  • users configure the model identifier by hand, as with any other OpenAI-compatible server

Verify /v1/models against a real Ollama instance before deleting the manager. If discovery regresses, the model selector gets worse for Ollama users even though inference still works.

Prerequisite

Confirm OpenAiCompatInferenceEngine actually works end-to-end against a live Ollama /v1 endpoint — tool calls included, not just plain completion. Removing the native path before verifying makes this a bet rather than a cleanup. Ollama's OpenAI-compat layer has historically had gaps around tool/function calling.

Acceptance Criteria

  • /v1 path verified against a live Ollama instance, including a tool-calling turn
  • Model discovery for Ollama works via the OpenAI-compatible path, or is a documented manual-configuration step
  • The three native modules and the Ollama integration test are deleted
  • ModelFamily::Ollama removed from both Rust and the TS union; no orphan match arms or display strings
  • composite_model_manager.rs restructured, not left holding a vestigial field
  • No --no-verify; the pre-push gate passes with the full suite
  • grep -ri ollama across packages/ returns only intentional references (e.g. a doc note that Ollama is reached via the OpenAI-compatible endpoint)

Original defect (for the record)

OllamaInferenceEngine built its HTTP client with reqwest::Client::new(), applying no request timeout (packages/agent/src/local_agent/ollama_inference.rs:22,31). An endpoint that accepts the TCP connection then stalls leaves the call hung indefinitely — reqwest surfaces an error only on transport failure, and a connected-but-silent server is not one.

If OpenAiCompatInferenceEngine has the same gap, fix it there — that client is staying. Check its constructor for a .timeout(..) before closing this issue.

Activity

  1. changed the title [-]Ollama engine's HTTP client has no timeout: a stalled endpoint can hang a turn[/-] [+]Remove the Ollama-native inference path: drive Ollama through its OpenAI-compatible endpoint[/+] on Jul 29, 2026
  2. malibio commented on Jul 29, 2026

    @malibio
    CollaboratorAuthor

    Checked the surviving client: the timeout defect exists there too.

    packages/agent/src/local_agent/openai_compat_inference.rs:53 builds http_client: reqwest::Client::new() — same missing .timeout(..), same hang risk from a connected-but-silent endpoint.

    So the original defect does not disappear with the removal; it relocates to the client we are keeping. That makes it more important, not less: after this change every remote inference call goes through OpenAiCompatInferenceEngine, so a stalled endpoint hangs the only remote path there is.

    Added to the acceptance criteria in spirit — whoever implements this should set an explicit request timeout on OpenAiCompatInferenceEngine's client as part of the same change. It is a two-line fix in code that is staying, and skipping it would mean deleting the buggy client while leaving the bug.

  3. malibio commented on Jul 29, 2026

    @malibio
    CollaboratorAuthor

    Baseline (worktree issue-1793-ollama-openai-compat): Frontend: 170 test files, 4106 tests passed.

    Prerequisite verification against live Ollama 0.32.1 — both green:

    • /v1/models returns the same catalog as native /api/tags (mistral:7b, ornith:9b, gemma4:e4b)
    • /v1/chat/completions tool calling works non-streaming and streaming (finish_reason: tool_calls, well-formed tool_calls deltas)

    Two findings that shape the work:

    1. Discovery is a real regression risk. CompositeModelManager::list() auto-merges Ollama models into the selector; OpenAI-compat models come only from hand-written [[openai_compat.configs]] in daemon.toml, and OpenAiCompatInferenceEngine has no listing surface at all (only /chat/completions). Decision: add /v1/models discovery to the OpenAI-compat path so Ollama/LM Studio/vLLM models auto-populate — preserving today's UX rather than regressing users to manual config.
    2. The original timeout defect also exists in the engine that survives — openai_compat_inference.rs:53 is a bare reqwest::Client::new() with no .timeout(..), same as the Ollama client. Fixing it here as the issue's closing note asks.
  4. self-assigned this
    on Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions