Repository navigation
Remove the Ollama-native inference path: drive Ollama through its OpenAI-compatible endpoint - #1806
Conversation
Drives Ollama through its OpenAI-compatible /v1 endpoint instead of its
bespoke native wire format, so one protocol implementation serves every
remotely-served model.
Verified against a live Ollama 0.32.1 before deleting anything:
- /v1/models returns the same catalog as the native /api/tags
- /v1/chat/completions tool calling works both streaming and non-streaming
New: openai_compat_discovery
The OpenAI-compat path had no listing surface at all, so a straight delete
would have cost Ollama users auto-discovery and left them hand-writing one
daemon.toml config per model. discover_models() queries GET {base_url}/models,
which every OpenAI-compatible server implements. A discovered model is
addressed as "openai-compat:<config_id>:<model>" — one endpoint config now
exposes N models rather than pinning exactly one.
/v1/models reports only id/created/owned_by, so discovered rows carry no
size, quantization or context window; those fields are left at their unknown
sentinels rather than guessed at.
Deleted: ollama_inference.rs, ollama_model_manager.rs, composite_model_manager.rs
(it existed only to route GGUF vs Ollama, so it collapses entirely rather than
being reworked), and tests/ollama_integration.rs.
Kept, renamed: ollama_ndjson.rs -> ndjson.rs. The surviving OpenAI-compat
engine depends on it for SSE line buffering, so deleting it as scoped would
have broken the engine we are keeping. It is a generic newline-delimited
buffer; only its name and docs were Ollama-specific.
ModelBackend::Ollama -> OpenAiCompat, with an explicit as_wire_str(). The
daemon stringified this enum via format!("{:?}").to_lowercase(), which would
have rendered the new variant as "openaicompat" and silently disagreed with
the hyphenated value the frontend matches on.
Also fixes the original defect this issue reported, in the engine that
survives: OpenAiCompatInferenceEngine built a bare reqwest::Client with no
timeout, so an endpoint that accepts the connection then stalls would hang
the turn forever. Adds connect and request timeouts.
Refs #1793
Co-Authored-By: Claude <[email protected]>
… RPC
list_models now merges GGUF catalog rows with every model discovered at a
configured OpenAI-compatible endpoint. Endpoints are queried concurrently via
a JoinSet — they are independent network calls and the selector awaits the
whole listing — and a dead endpoint contributes nothing rather than failing
the catalog, so one bad provider cannot blank out the others.
CompositeModelManager is gone, so the daemon holds a GgufModelManager
directly and the Ollama load branch collapses into the OpenAI-compat branch
above it. Adds parse_openai_compat_id() for the "<uuid>:<model>" form, which
splits on the FIRST colon after the prefix: a UUID never contains one, while
a model identifier routinely does ("mistral:7b"). A discovered model wins over
the config's pinned `model` field.
Removes the OllamaAvailable RPC end to end — proto, daemon handler, Tauri
command, and its invoke_handler registration. Whether a remote endpoint is
reachable is now answered by discovery returning rows for it.
Also fixes a live bug that predates this work: behaviors/mod.rs accepted only
native|ollama|openai|pty for an ai-chat node's provider, while the frontend
has been emitting "openai-compat" and persisting it verbatim — so those nodes
failed validation. The accepted set is now native|openai|openai-compat|pty.
Refs #1793
Co-Authored-By: Claude <[email protected]>
…ckend The chat selector's OpenAI-compat options were rendered disabled with a "(coming soon)" label, so the Ollama optgroup was the only working way to pick a remotely-served model. Deleting the native path without finishing this would have left no selectable remote model at all — so the selector now renders discovered models as real, selectable options under "Remote endpoints", replacing both the Ollama section and the stubbed config list. Settings' dedicated Ollama panel (running/not-running state, install link, its own refresh) becomes "Available remote models", listing what discovery actually returned. It no longer duplicates the "Custom endpoints" section directly below it, which is where endpoints are configured. buildDefaultOptions() now emits one row per discovered model and falls back to a bare config row only when that config contributed nothing — otherwise a configured endpoint appeared twice in the default-model picker. Frontend types follow the daemon: ModelFamily drops 'ollama' for 'openai-compat', AiChatProvider drops 'ollama', and the catalog row's backend discriminator becomes 'gguf' | 'openai-compat'. ollamaAvailable() and the dev-proxy's /api/agent/ollama-available route are removed. Fixes a latent mismatch in ai-chat-node-viewer: its openai-compat branch prefixed the stored model, assuming a bare config UUID. Selections are now fully-qualified daemon ids, so the value passes through unchanged. Frontend suite: 170 files / 4106 tests, matching baseline exactly. Refs #1793 Co-Authored-By: Claude <[email protected]>
The smoke test drives the real production path — discover_models() then a streamed tool-calling turn through OpenAiCompatInferenceEngine — against a locally running server. It guards the claim this whole change rests on: that Ollama's /v1 serves both discovery and tool calls, so the native client was redundant rather than merely similar. #[ignore]d, since it needs a real server; run with --ignored. Verified against Ollama 0.32.1: discovered 3 models, mistral:7b requested get_weather (71 prompt / 55 completion tokens). Remaining "Ollama" mentions are deliberate prose explaining that it is now reached through the OpenAI-compatible endpoint. The ones removed here had gone stale — "Ollama-managed models", "the Ollama engine", and three references to a "local Ollama agent" that described the local agent generally and were inaccurate even before this change. Refs #1793 Co-Authored-By: Claude <[email protected]>
Code Review — PR #1806Review Type: Initial Review SummaryA genuinely excellent deletion: -3477 / +705. Three native modules, a 1843-line integration test, and an entire I verified the acceptance criteria independently rather than trusting the summary. Findings are one 🟡 correctness bug (a real round-trip break in the default-model selector), plus one 🟡 latent scaling concern and a few 🟢s. Nothing blocking. Requirements Check
📝 Scope deviations — all four were the right call:
Findings🟡 Important1. 📁
opts.push({
label: c.name,
value: encodeSelection({
provider: 'openai-compat',
modelId: `openai-compat:${c.id}`, // fully qualified
configId: c.id,
}),
});But It isn't. Per CLAUDE.md this is greenfield with zero users, so losing the persisted value is acceptable by policy. The problem is the failure mode, not the data loss: it fails silently to a valid-looking state rather than loudly. A user who set a default sees it quietly forgotten with no error, no log line, nothing to grep for. Two options, either fine:
I'd take the first — it's three lines and removes the invariant entirely rather than reporting its violation. Principle: Encode/decode pairs must be mutual inverses over the full domain of their input type. 2. 📁 The But note what this does to
The 5s timeout is well-chosen and the doc comment justifies it precisely ("must degrade to no models quickly rather than stall the whole list"). I'm not asking for a change in this PR — the behavior is strictly better than the old Ollama path, which had no timeout at all. But a short-TTL cache on the discovery result (even 30s) would turn a repeated 5s stall into a one-time one, and is worth a follow-up issue. Principle: A synchronous read path that acquires a network dependency inherits that dependency's worst-case latency. Fanning out concurrently bounds it to one timeout instead of N; caching removes it from the steady state. 🟢 Suggestions3. 📁 const localAgents = models.map(modelToAgent); // no backend filter
I checked: this was already unfiltered before this PR ( Principle: DRY applies to filtering invariants, not just code. Two stores consuming the same catalog disagree about which rows belong to them; the one with the comment explaining the rule is the one that should be copied. 4. The no-timeout fix is sound, and the fallback is correctly reasoned 📁
5. 📁 Splitting on the first colon is the correct choice and the reasoning is airtight: UUIDs never contain a colon, model names routinely do ( I traced all four parse sites and they agree:
6. 📁 Catching that Nit: 7. Test quality is notably good The RecommendationCOMMENT — approve-with-nits in substance. This is comfortably net-positive: a large, well-justified deletion that removes an entire redundant protocol client and its indirection layer, backed by a live test that proves the redundancy claim rather than asserting it. All eight acceptance criteria are met, and the three scope expansions were each necessary to avoid shipping a regression. Finding #1 is a real bug and worth fixing before merge — it's a few lines and the silent-failure mode is the objectionable part, not the data loss. Findings #2 and #3 are legitimate follow-up issues, not merge blockers. |
malibio
left a comment
There was a problem hiding this comment.
Initial review posted as a PR comment. Recommendation: COMMENT (approve-with-nits). One 🟡 correctness finding worth fixing before merge (encodeSelection round-trip in model-manager.svelte), plus two follow-up-issue items. All 8 acceptance criteria verified independently.
…ilently reset Review finding #1 (🟡). encodeSelection() returned modelId verbatim for openai-compat, so the encode/decode round-trip held only when modelId was already fully qualified. It is not always: buildDefaultOptions' fallback rows and any default persisted before this branch carry a bare config UUID. The <select> binds to encodeSelection(defaultModel), so a bare UUID matched no <option> and the picker fell back to "" — the user's saved default silently read as "None", with no error and nothing to grep for. Losing the persisted value is fine per CLAUDE.md (greenfield, zero users); failing silently to a valid-looking state is not. encodeSelection now normalizes instead of passing through, making it total over ModelSelection rather than correct only on a subset its signature does not distinguish. Verified the old code encoded a pre-existing default to "abc-123" (matching no option) where the new code yields "openai-compat:abc-123" (matching). Adds model-manager-selection.test.ts pinning the round-trip, including the colon-bearing model name, the bare-UUID case, and idempotency so a future pass-through cannot silently reintroduce this. Also from review: - #4 nit: log when the HTTP client falls back to an untimed one — that branch discards the very timeouts the constants exist to enforce, so silence there hid the failure it was meant to prevent. - #6 nit: as_wire_str takes self by value; ModelBackend is Copy. Not addressed, deliberately: - #2 (list_models inherits endpoint latency): reviewer flagged as non-blocking and strictly better than the old no-timeout path. A TTL cache needs an invalidation design — when should a newly pulled model appear? — which is a design decision, not review feedback. Follow-up issue. - #3 (agent-store missing the backend === 'gguf' filter): reviewer verified it predates this branch. Fixing unrelated pre-existing bugs mid-PR is the scope creep the project guide warns against. Follow-up issue. Frontend: 171 files / 4112 tests (was 170 / 4106; +1 file, +6 tests). Refs #1793 Co-Authored-By: Claude <[email protected]>
Review addressed — commit 287f93f✅ Addressed (3)🟡 #1 — Confirmed as a real bug before fixing. Reproduced the exact failure the review described:
Added 🟢 #4 nit — swallowed HTTP-client fallback Added a 🟢 #6 nit — ⏭️ Deferred to follow-up issues (2)🟡 #2 — 🟢 #3 — Verification
Re-Review DecisionNO RE-REVIEW NEEDED. The one behavioral change is three lines in a pure function, its correctness is pinned by six new tests including an idempotency case, and the before/after was verified against the concrete failure the review reported. The other two changes are a log line and a |
Closes #1793