Repository navigation
Description
[Bug] Ollama integration in Studio: models get a wrong source, crash the schema, and are almost always withheld from the inventory
Summary
Studio's Ollama integration is broken in three separate, stacked ways. Together they mean that on a normal ollama pull-populated ~/.ollama directory, zero Ollama models show up anywhere in Studio, and the one code path that does surface them tags them with the wrong source.
Backend version reported by /openapi.json: 2026.8.22. Desktop app version: 0.1.804-beta.
Environment
- macOS, Apple Silicon
- Ollama installed separately (
/Applications/Ollama.app), 8 local models pulled viaollama pull(mix oflibrary/*, a namespacedhuihui_ai/*, and onehf.co/...repo), plus one*-cloudreference with no local blob. - Studio backend:
unsloth studio --api-only -H 127.0.0.1 -p 8888
Bug 1 — routes/models.py's local _scan_ollama_dir hardcodes source = "custom", and the newer schema doesn't even allow "ollama"
GET /api/models/local (used by the chat and training model pickers, see frontend/src/features/chat/api/chat-api.ts) is served by collect_local_models in studio/backend/routes/models.py. That function has its own copy of the Ollama-manifest scanner (_scan_ollama_dir, ~line 791), separate from the "canonical" one in studio/backend/hub/services/models/ollama.py. Two problems:
studio/backend/routes/models.py~line 988, inside_scan_ollama_dir:found.append( LocalModelInfo( id = gguf_link_path, model_id = f"ollama/{repo_name}:{tag}", display_name = display + suffix, path = gguf_link_path, source = "custom", # <-- should be "ollama" updated_at = updated_at, ), )
- Even after fixing that, it throws, because the
LocalModelInfoPydantic model these routes use (studio/backend/models/models.py:223) has:— nosource: Literal["models_dir", "hf_cache", "lmstudio", "custom"] = Field(...)
"ollama"literal at all, unlike the otherLocalModelInfoinstudio/backend/hub/schemas/inventory.py(which the OpenAPI spec exposes with"ollama"as a validsourceenum value). Settingsource="ollama"in the legacy model raises:500ingpydantic_core._pydantic_core.ValidationError: 1 validation error for LocalModelInfo source Input should be 'models_dir', 'hf_cache', 'lmstudio' or 'custom' [type=literal_error, input_value='ollama', input_type=str]GET /api/models/localentirely.
Separately, the generic "custom scan folder" merge step at the end of collect_local_models also blanket-stamps every row from a registered folder:
local_models += [m.model_copy(update = {"source": "custom"}) for m in custom_models]with no guard for rows that already carry a real source — unlike the equivalent, correct _promote_to_custom_source() in hub/services/models/local_inventory.py, which explicitly does if model.source in {"hf_cache", "ollama"}: return model. If ~/.ollama/models is ever registered as a scan folder (Studio's own "recommended folders" onboarding suggests exactly this), every Ollama row gets re-stamped "custom" here too.
Net effect: the frontend explicitly branches on source === "ollama" in several places (features/chat/local-model-options.ts:53, features/model-picker/components/model-selector/pickers.tsx:2735,5902, features/train-model-picker/*, features/hub/inventory/view-models.ts — which even has a dedicated localSourceLabel case returning "Ollama"), but the backend never actually produces that value through this code path.
Bug 2 — the "canonical" Ollama scanner withholds virtually every real Ollama model from the inventory
GET /api/hub/local (a second, separate endpoint — powers the Hub/Models library screen, via hub/routes/inventory.py → hub/services/models/local_inventory.py → hub/services/models/ollama.py::scan_ollama_dir) uses the correct scanner (it does set source = "ollama" and is validated by the newer schema). But it has its own, much larger problem:
hub/services/models/ollama.py defines:
_OLLAMA_LOADABLE_LAYER_MEDIA_TYPES = frozenset({
"application/vnd.ollama.image.model",
"application/vnd.ollama.image.projector",
"application/vnd.ollama.image.license",
})Any manifest layer outside this set (checked in _unsupported_ollama_layer_media_types) causes the entire model to be silently withheld from the scan (_ollama_model_info_from_manifest → invalid_manifest(...) → return None), and to be hard-rejected with a 400 if you try to load it directly by manifest ref.
This is deliberate — there's an explicit test, test_rich_manifest_is_withheld_from_inventory in tests/test_ollama_manifest_load_resolution.py, asserting exactly this for a manifest carrying params/template/system/messages/adapter/prompt/future-runtime layers. The stated rationale (per the test file's context) is that loading the raw GGUF via llama.cpp would silently drop the Modelfile's custom system prompt / template, giving different behavior than ollama run.
In practice this makes the integration close to useless: ollama pull always writes at least a template layer, and very commonly params and/or system too. On a normal local Ollama install with 8 pulled models (standard library/* pulls, no LoRA adapters), scan_ollama_dir() returned 0 of 8 models — every single one was withheld, each for carrying nothing more exotic than params/template/system.
None of params/template/system/messages/prompt are actually read anywhere else in the backend (confirmed via grep -rn "vnd.ollama.image.template\|...params\|...system\|...messages" studio/backend — zero hits outside this one gate), so excluding them from the withheld set costs nothing functionally today; adapter (LoRA weights) and future-runtime (genuinely unknown layer types) are the only ones where dropping the layer could plausibly change model behavior, and those arguably deserve to stay guarded.
Steps to reproduce
- Have Ollama installed with at least one model pulled the normal way, e.g.
ollama pull llama3:8b. - Open Studio, go to the chat model picker or the Hub/Models library screen.
- Observe: the Ollama model does not appear in either place (Hub/Models: silently absent,
scan_ollama_dirwithholds it for thetemplatelayer; chat picker: appears only if~/.ollama/modelshappens to be registered as a scan folder, and even then undersource: "custom", not grouped/labeled as Ollama). curl -H "Authorization: Bearer $TOKEN" http://127.0.0.1:8888/api/hub/local?models_dir=./modelsreturns 0source: "ollama"rows despite the model being present under~/.ollama/models/manifests/....
Expected
A normally-pulled Ollama model shows up in both the chat/training model pickers and the Hub/Models library, tagged source: "ollama", without needing to manually register ~/.ollama/models as a custom scan folder.
What I did locally (workaround, not a real fix)
Patched the installed venv directly (~/.unsloth/studio/unsloth_studio/lib/python3.13/site-packages/studio/backend/...) as a stopgap, since a Studio auto-update will overwrite it:
models/models.py: added"ollama"to theLocalModelInfo.sourceLiteral.routes/models.py:_scan_ollama_dirnow setssource = "ollama"; the custom-folder merge step now preservessource in {"hf_cache", "ollama"}instead of blanket-overwriting to"custom".hub/services/models/ollama.py: addedparams/template/system/messages/promptto_OLLAMA_LOADABLE_LAYER_MEDIA_TYPES, keptadapter/future-runtimeexcluded.
After these three changes, all 8 locally-pulled models show up correctly, tagged source: "ollama", in both /api/models/local and /api/hub/local.
Possibly related
- [Bug] Unsloth Studio fails to scan local Ollama models #5219 (closed) — different symptom (500 on
/api/models/local), but same general area. - [Bug] August updates issues: (1). No longer see/re-used Ollama-download models, (2). Setting too small context size ( about 50%) #7877 (open) — "No longer see/re-used Ollama-download models" after an August update; could be the same root cause as Bug 2 above (a regression that added/tightened the layer gate).
- [Bug] Studio: changing the Models folder leaves models listed as external dirs, and image models are then not found #8407 (closed) — models mislabeled as "custom"/external after a folder change; same class of bug as Bug 1 (source classification getting clobbered), different trigger.
Activity
lonexreb commentedon Aug 29, 2026
Claiming this — I wrote the manifest-ref load path in #9237, happy to carry the follow-through.
Plan, split to keep each mergeable on its own:
Bug 1 (PR incoming today): the legacy
routes/models.pypath — add"ollama"to the legacyLocalModelInfo.sourceliteral, tag_scan_ollama_dirrowssource = "ollama", and give the custom-folder merge the same already-sourced guard_promote_to_custom_source()applies (hf_cache/ollamarows keep their source). All three are mechanical and your local patch matches what I'd ship; I'll add the regression tests.Bug 2 needs a maintainer call before code: the rich-manifest withholding is deliberate and pinned by
test_rich_manifest_is_withheld_from_inventory— the rationale being that llama.cpp loads the bare GGUF and silently drops the Modelfile'ssystem/template, so the model answers differently thanollama run. Your data (8/8 normal pulls withheld —ollama pullalways writestemplate) shows the gate as-is guards almost nothing into existence, but flipping it silently changes that stated contract. Two options worth weighing: (a) surface rich-manifest models with a visible "Modelfile system/template not applied" note instead of withholding; (b) keep withholding onlyadapter/unknown-runtime layers and treattemplate/params/system/messages/promptas cosmetic, as you propose. I'd lean (a) for honesty about the behavior difference, but that's a product call — deferring to the maintainers on direction before touching that gate.lonexreb commentedon Aug 30, 2026
Data point for the bug-2 direction call: #7877 is a second independent report of the same withholding gate (Daniel's triage there confirms the
template/paramsrejection) — a reporter with 20 pulled models seeing none of them. Strengthens the case for surfacing rich-manifest models with a "Modelfile system/template not applied" note rather than dropping them silently.Tag the compat endpoint's Ollama rows with their real source (#9988)
lonexreb commentedon Aug 31, 2026
Status: bug 1 is fixed on main — #9988 merged (d37e98e): the legacy endpoint's Ollama rows now carry
source: "ollama", the legacy literal admits it, the custom-folder merge no longer re-stamps attributed rows, and the recipe selector labels them. Bug 2 (the rich-manifest withholding direction) is the remaining half — the options from the claim comment above still stand, and #7877 is a second report of the same gate. Happy to build whichever direction you pick.lonexreb commentedon Sep 4, 2026
Nudge on the bug-2 direction, since bug 1 has now been merged (#9988) and #7877 remains a second live report of this gate: every normal
ollama pullcarries atemplatelayer, so the withholding hides essentially all Ollama models from the inventory. The two directions from the claim comment still stand — (a) surface rich-manifest models with a "Modelfile system/template not applied" note, or (b) keep withholding and document it. I have (a) scoped and ready to build the moment you pick; if the silence means "maintainer's choice", I'll take that as (a) and open the PR.danielhanchen commentedon Sep 6, 2026
Fixed! Normally pulled Ollama models show up now, we were wrongly withholding manifests with template and params layers, and the source field no longer crashes the schema.
To update: the desktop app updates itself (Settings > General), otherwise
unsloth studio update, or in Dockerdocker exec <container> unsloth-studio-update.