Repository navigation
fix(ollama): models pulled after setup never appear in model pickers - #167463
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThe branch discovers newly installed chat models on self-hosted Ollama endpoints while preserving configured model settings. Example: Pull qwen3:0.6b after setting up qwen2.5:0.5b, then refresh models
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR remains useful because current main still pins discovery to configured models. The prior settings-preservation finding is resolved, and no new actionable defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Ollama plugin reads installed models from an Ollama server and supplies them to OpenClaw's shared model catalog. The catalog combines discovery with configured rows for CLI lists and Control UI pickers. flowchart TD
A[Configured Ollama models] --> B[Ollama discovery]
C[Model refresh] --> B
B --> D{Hosted or discovery disabled?}
D -->|Yes| E[Configured rows only]
D -->|No| F[Read installed chat models]
F --> G[Combine new models with configured rows]
E --> H[CLI lists and UI pickers]
G --> H
Technical reviewBest possible solution: Keep discovery in the Ollama catalog producer, adding only unconfigured installed models through the existing refresh and merge lifecycle. Do we have a high-confidence way to reproduce the issue? Yes: current main returns early for nonempty configured models, and the supplied real setup demonstrates a later pull remaining absent after refresh. The reviewer did not execute target code. Is this the best way to solve the issue? Yes: the correction stays in the provider-owned catalog path and uses the existing merge owner, preserving authored settings without adding another refresh mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6b2afbfe981a. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +2, Tests +35, Docs +4. Total +41 across 8 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 8, 2026, 7:37 PM ET / 23:37 UTC (Revision 4). |
|
Maintainer decision: accepted. A configured Ollama model list on a self-hosted endpoint is no longer a picker allowlist (use models.mode replace, discovery.enabled false, or the agent model allowlist to keep only configured models). New pulls appear on the next model-list refresh (Refresh / startup / config or credential change); refreshing on picker open is out of scope. |
|
Landed in 711e23c. Self-hosted Ollama now re-lists installed models, so a model pulled after setup appears on the next model-list refresh with no config edit or restart; saved model settings (including compat.supportsTools:false) still win, and hosted ollama.com is unchanged. Proof: real Docker Ollama before/after with screenshots, a regression that failed on main, unchanged startup with an unreachable/hung/slow endpoint, and a published 2026.9.9 → candidate upgrade that kept the saved Ollama config. |
…penclaw#167463) ## What Problem This Solves Fixes: a model pulled with `ollama pull` after OpenClaw's Ollama setup never shows up in the model pickers, even after **Refresh**, until the user edits config. ## User Impact User impact: after setting up a local or self-hosted Ollama server, newly pulled chat models appear in the Control UI picker and `openclaw models list --provider ollama` on the next model-list refresh, with no config edit or Gateway restart. Setup-saved models keep their settings. Embedding-only models stay out. Behavior change to note: a nonempty `models.providers.ollama.models` list on a self-hosted endpoint no longer acts as a picker allowlist. Users who want only their listed models use `models.mode: "replace"`, `plugins.entries.ollama.config.discovery.enabled: false`, or the existing model allowlist. Hosted `https://ollama.com` still uses only the configured rows. ## Why This Change Was Made Setup saves every model it finds into `models.providers.ollama.models`, and Ollama discovery returned only those saved rows whenever that list was nonempty, without listing `/api/tags`. That pinned the inventory to setup time. Discovery now lists `/api/tags` for self-hosted endpoints even when models are configured; listed models the config already has are dropped from the discovered set, so configured rows keep all their settings (for example the documented `compat.supportsTools: false` workaround, even when `/api/show` advertises `tools`), and the existing config merge adds the other installed chat models. Discovery opt-out, hosted Ollama Cloud, endpoint/credential rules and failure handling are unchanged: if `/api/tags` fails, the configured rows stay. The stale WIP also added a 30 s fallback expiry in core inventory capture. It is not part of this PR: since openclaw#167008, ordinary `models.list` reads no longer renew expired provider inventory, so a deadline would not make a plain picker open re-list. Explicit **Refresh** (Models page, `models list --refresh`), startup and config/credential changes own discovery, and that path now picks up new pulls. ## Evidence Real run on a disposable `ollama/ollama` Docker container (no host mounts, removed afterwards) with isolated profiles, running real `openclaw onboard --non-interactive --auth-choice ollama --custom-base-url http://127.0.0.1:11471 --custom-model-id qwen2.5:0.5b`. Setup saved `models.providers.ollama.models = ["qwen2.5:0.5b"]` (`mode: "merge"`). The config file hash was identical before and after every step below, and the Gateway was not restarted between pull and listing. | Step | `origin/main` (618f4d2) | This branch | | --- | --- | --- | | `models list --provider ollama` after setup | `qwen2.5:0.5b` | `qwen2.5:0.5b` | | `ollama pull qwen3:0.6b`, then `models list --provider ollama --refresh` | `qwen2.5:0.5b` only (also 45 s later) | `qwen2.5:0.5b`, `qwen3:0.6b` | | Control UI chat picker | Ollama (1) | — | | `ollama pull smollm2:135m` + `all-minilm` (embedding), Settings → Models → **Refresh**, reopen chat picker | — | Ollama (3): `qwen2.5:0.5b`, `qwen3:0.6b`, `smollm2:135m`; `all-minilm` absent | | `infer model run --gateway --model ollama/qwen3:0.6b --prompt "Reply with exactly: PULLED_OK"` | — | `ok: true`, provider `ollama`, model `qwen3:0.6b`, output `PULLED_OK` (7 s) | The host was heavily loaded (load average ~70 on 32 cores). Ollama's default 32 llama.cpp threads stalled while loading the model, so before the chat turn the pulled model's Ollama-side default was set to `num_thread 6` (`ollama create qwen3:0.6b` with `FROM qwen3:0.6b`). OpenClaw config was not touched. An earlier full-agent Control UI turn to the same model was stopped after its 8.8k-token prompt ran at about 8 tokens/s under that load. Without **Refresh**, a plain `models list` / picker open keeps showing the published catalog on both builds; that is the existing openclaw#167008 read policy, not changed here. Tests: - New `src/agents/models-config.ollama-secretref.test.ts` case runs the registered Ollama plugin through the real models-config planner. Configured `qwen2.5:0.5b` (`compat.supportsTools: false`) plus `/api/tags` listing `qwen3:0.6b` and `nomic-embed-text`, with `/api/show` advertising `tools`, results in `[qwen2.5:0.5b (supportsTools: false), qwen3:0.6b (supportsTools: true)]`. A later `/api/tags` 503 keeps `[qwen2.5:0.5b (supportsTools: false)]`. Before 392ff91 the compat assertion failed with the setup row's compat replaced by the discovered `{ supportsTools: true, supportsUsageInStreaming: true, supportsJsonSchemaResponseFormat: true }`. Against main's `discovery-shared.ts` it fails with `expected [ 'qwen2.5:0.5b' ] to deeply equal [ 'qwen2.5:0.5b', 'qwen3:0.6b' ]`. - Existing tests that asserted "no discovery with configured models" now assert the discovery request's credentials instead. Local synthetic auth sends no `Authorization`; ambient `OLLAMA_API_KEY` stays away from local hosts; a configured remote key or SecretRef is sent. - `extensions/ollama/src/discovery-shared.test.ts`, `extensions/ollama/provider-discovery.test.ts`, `extensions/ollama/index.test.ts`: 135 passed. `models-config.ollama-secretref.test.ts`: 7 passed. After 392ff91: `node scripts/run-vitest.mjs run` on `models-config.ollama-secretref`, `provider-discovery`, `discovery-shared`, `models-config.merge`, `model-compat-catalog` tests: 3 shards passed. `oxlint --type-aware` on changed files: clean. - `node scripts/check-changed.mjs`: every step passed except the dead export scan, which flags `src/talk/client-voice-session-store.ts: ClientVoiceToolEffect`. This PR does not touch that file; the export comes from main (openclaw#166795). Rerun at 392ff91: same single unrelated failure; every other step (including core/extension typechecks) passed. ### Configured model settings survive discovery (392ff91) Real run, isolated profile, disposable `ollama/ollama` container on `127.0.0.1:21434` (removed afterwards), Gateway on loopback. Config: `models.providers.ollama.models = [{ id: "qwen2.5:0.5b", compat: { supportsTools: false } }]`; `/api/show` for `qwen2.5:0.5b` returns `capabilities: ["completion", "tools"]`. | Step | Effective rows (`gateway call models.list`, provider `ollama`) | | --- | --- | | After Gateway start | `qwen2.5:0.5b` `supportsTools: false` | | `ollama pull qwen3:0.6b`, then `models list --provider ollama --refresh` | `qwen2.5:0.5b` `supportsTools: false`; `qwen3:0.6b` `supportsTools: true` (ctx 40960) | | `openclaw agent --agent main -m "Reply with exactly the word: pong"` on `ollama/qwen2.5:0.5b` | `status: ok`, reply `pong`; run report tools `entries: []`, `schemaChars: 0` (no tool schemas sent) | The container ran with `OLLAMA_CONTEXT_LENGTH=16384`; at Ollama's default 4096 the 6k-token system prompt overflowed (an Ollama server setting, unrelated to this change). ### Startup with an unreachable or slow configured endpoint openclaw#28827 skipped discovery for configured models to avoid startup delays. Measured Gateway start (spawn of `pnpm openclaw --profile … gateway run` to `/readyz` 200) with the same configured model, `origin/main` (618f4d2) vs this branch (392ff91), alternating, 3 runs each. Endpoints: unreachable = closed loopback port; hang = loopback server that accepts and never answers; slow = every response after 2 s. Host load average was 28–46 on 32 cores, so absolute numbers are noisy. | Endpoint | main `/readyz` ms (r1, r2, r3) | branch `/readyz` ms (r1, r2, r3) | | --- | --- | --- | | unreachable | 8988, 18618, 58035 | 9401, 21341, 32035 | | hang | 9507, 32831, 25592 | 8351, 9313, 27288 | | slow (2 s) | 18887, 10279, 11986 | 9144, 20723, 15589 | No systematic difference. On the branch, every `/api/tags` request reached the hang and slow servers 2.0–3.5 s **after** the Gateway logged `ready` (none before it), so discovery is not on the startup path. `models list --provider ollama --json` right after ready returned the configured row in 2.8–10.6 s on both builds (main 2.8–7.9 s, branch 2.9–10.6 s); in hang runs 1 and 3 it returned before the hanging `/api/tags` request hit its 5 s timeout. Main also sends one post-ready `/api/show` for the configured model. No overlap with Pash/Sarah changes Merge danger: two-way door (one conditional in the Ollama plugin plus docs; no schema, stored-data, config-option or protocol change). Blast radius: users with a self-hosted Ollama endpoint and a nonempty configured model list. Their picker gains the other installed chat models, and startup and refresh now send `/api/tags` and `/api/show` requests to that server. If the server is offline, Ollama now reports an unavailable refresh, keeps the configured rows, and retries with backoff. Hosted Ollama Cloud, discovery opt-out and replace mode are unaffected. ### Screenshots Before (`origin/main`), chat picker after `ollama pull qwen3:0.6b` and `--refresh`: Ollama (1).  After (this branch), chat picker after Settings → Models → **Refresh**: Ollama (3), embedding model absent.  Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes: a model pulled with
ollama pullafter OpenClaw's Ollama setup never shows up in the model pickers, even after Refresh, until the user edits config.User Impact
User impact: after setting up a local or self-hosted Ollama server, newly pulled chat models appear in the Control UI picker and
openclaw models list --provider ollamaon the next model-list refresh, with no config edit or Gateway restart. Setup-saved models keep their settings. Embedding-only models stay out.Behavior change to note: a nonempty
models.providers.ollama.modelslist on a self-hosted endpoint no longer acts as a picker allowlist. Users who want only their listed models usemodels.mode: "replace",plugins.entries.ollama.config.discovery.enabled: false, or the existing model allowlist. Hostedhttps://ollama.comstill uses only the configured rows.Why This Change Was Made
Setup saves every model it finds into
models.providers.ollama.models, and Ollama discovery returned only those saved rows whenever that list was nonempty, without listing/api/tags. That pinned the inventory to setup time. Discovery now lists/api/tagsfor self-hosted endpoints even when models are configured; listed models the config already has are dropped from the discovered set, so configured rows keep all their settings (for example the documentedcompat.supportsTools: falseworkaround, even when/api/showadvertisestools), and the existing config merge adds the other installed chat models. Discovery opt-out, hosted Ollama Cloud, endpoint/credential rules and failure handling are unchanged: if/api/tagsfails, the configured rows stay.The stale WIP also added a 30 s fallback expiry in core inventory capture. It is not part of this PR: since #167008, ordinary
models.listreads no longer renew expired provider inventory, so a deadline would not make a plain picker open re-list. Explicit Refresh (Models page,models list --refresh), startup and config/credential changes own discovery, and that path now picks up new pulls.Evidence
Real run on a disposable
ollama/ollamaDocker container (no host mounts, removed afterwards) with isolated profiles, running realopenclaw onboard --non-interactive --auth-choice ollama --custom-base-url http://127.0.0.1:11471 --custom-model-id qwen2.5:0.5b. Setup savedmodels.providers.ollama.models = ["qwen2.5:0.5b"](mode: "merge"). The config file hash was identical before and after every step below, and the Gateway was not restarted between pull and listing.origin/main(6070074)models list --provider ollamaafter setupqwen2.5:0.5bqwen2.5:0.5bollama pull qwen3:0.6b, thenmodels list --provider ollama --refreshqwen2.5:0.5bonly (also 45 s later)qwen2.5:0.5b,qwen3:0.6bollama pull smollm2:135m+all-minilm(embedding), Settings → Models → Refresh, reopen chat pickerqwen2.5:0.5b,qwen3:0.6b,smollm2:135m;all-minilmabsentinfer model run --gateway --model ollama/qwen3:0.6b --prompt "Reply with exactly: PULLED_OK"ok: true, providerollama, modelqwen3:0.6b, outputPULLED_OK(7 s)The host was heavily loaded (load average ~70 on 32 cores). Ollama's default 32 llama.cpp threads stalled while loading the model, so before the chat turn the pulled model's Ollama-side default was set to
num_thread 6(ollama create qwen3:0.6bwithFROM qwen3:0.6b). OpenClaw config was not touched. An earlier full-agent Control UI turn to the same model was stopped after its 8.8k-token prompt ran at about 8 tokens/s under that load.Without Refresh, a plain
models list/ picker open keeps showing the published catalog on both builds; that is the existing #167008 read policy, not changed here.Tests:
src/agents/models-config.ollama-secretref.test.tscase runs the registered Ollama plugin through the real models-config planner. Configuredqwen2.5:0.5b(compat.supportsTools: false) plus/api/tagslistingqwen3:0.6bandnomic-embed-text, with/api/showadvertisingtools, results in[qwen2.5:0.5b (supportsTools: false), qwen3:0.6b (supportsTools: true)]. A later/api/tags503 keeps[qwen2.5:0.5b (supportsTools: false)]. Before 392ff91 the compat assertion failed with the setup row's compat replaced by the discovered{ supportsTools: true, supportsUsageInStreaming: true, supportsJsonSchemaResponseFormat: true }. Against main'sdiscovery-shared.tsit fails withexpected [ 'qwen2.5:0.5b' ] to deeply equal [ 'qwen2.5:0.5b', 'qwen3:0.6b' ].Authorization; ambientOLLAMA_API_KEYstays away from local hosts; a configured remote key or SecretRef is sent.extensions/ollama/src/discovery-shared.test.ts,extensions/ollama/provider-discovery.test.ts,extensions/ollama/index.test.ts: 135 passed.models-config.ollama-secretref.test.ts: 7 passed. After 392ff91:node scripts/run-vitest.mjs runonmodels-config.ollama-secretref,provider-discovery,discovery-shared,models-config.merge,model-compat-catalogtests: 3 shards passed.oxlint --type-awareon changed files: clean.node scripts/check-changed.mjs: every step passed except the dead export scan, which flagssrc/talk/client-voice-session-store.ts: ClientVoiceToolEffect. This PR does not touch that file; the export comes from main (fix(talk): settle accepted voice work before shutdown #166795). Rerun at 392ff91: same single unrelated failure; every other step (including core/extension typechecks) passed.Configured model settings survive discovery (392ff91)
Real run, isolated profile, disposable
ollama/ollamacontainer on127.0.0.1:21434(removed afterwards), Gateway on loopback. Config:models.providers.ollama.models = [{ id: "qwen2.5:0.5b", compat: { supportsTools: false } }];/api/showforqwen2.5:0.5breturnscapabilities: ["completion", "tools"].gateway call models.list, providerollama)qwen2.5:0.5bsupportsTools: falseollama pull qwen3:0.6b, thenmodels list --provider ollama --refreshqwen2.5:0.5bsupportsTools: false;qwen3:0.6bsupportsTools: true(ctx 40960)openclaw agent --agent main -m "Reply with exactly the word: pong"onollama/qwen2.5:0.5bstatus: ok, replypong; run report toolsentries: [],schemaChars: 0(no tool schemas sent)The container ran with
OLLAMA_CONTEXT_LENGTH=16384; at Ollama's default 4096 the 6k-token system prompt overflowed (an Ollama server setting, unrelated to this change).Startup with an unreachable or slow configured endpoint
#28827 skipped discovery for configured models to avoid startup delays. Measured Gateway start (spawn of
pnpm openclaw --profile … gateway runto/readyz200) with the same configured model,origin/main(6070074) vs this branch (392ff91), alternating, 3 runs each. Endpoints: unreachable = closed loopback port; hang = loopback server that accepts and never answers; slow = every response after 2 s. Host load average was 28–46 on 32 cores, so absolute numbers are noisy./readyzms (r1, r2, r3)/readyzms (r1, r2, r3)No systematic difference. On the branch, every
/api/tagsrequest reached the hang and slow servers 2.0–3.5 s after the Gateway loggedready(none before it), so discovery is not on the startup path.models list --provider ollama --jsonright after ready returned the configured row in 2.8–10.6 s on both builds (main 2.8–7.9 s, branch 2.9–10.6 s); in hang runs 1 and 3 it returned before the hanging/api/tagsrequest hit its 5 s timeout. Main also sends one post-ready/api/showfor the configured model.Merge danger: two-way door (one conditional in the Ollama plugin plus docs; no schema, stored-data, config-option or protocol change). Blast radius: users with a self-hosted Ollama endpoint and a nonempty configured model list. Their picker gains the other installed chat models, and startup and refresh now send
/api/tagsand/api/showrequests to that server. If the server is offline, Ollama now reports an unavailable refresh, keeps the configured rows, and retries with backoff. Hosted Ollama Cloud, discovery opt-out and replace mode are unaffected.Screenshots
Before (
origin/main), chat picker afterollama pull qwen3:0.6band--refresh: Ollama (1).After (this branch), chat picker after Settings → Models → Refresh: Ollama (3), embedding model absent.