Skip to content

fix(ollama): models pulled after setup never appear in model pickers - #167463

Merged
obviyus merged 3 commits into
mainfrom
fix/ollama-rediscover-pulled-models
Oct 9, 2026
Merged

obviyus merged 3 commits into
mainfrom
fix/ollama-rediscover-pulled-models

Conversation

@obviyus

@obviyus obviyus commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

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 #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 (6070074) 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 #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 (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/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

#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 (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.

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.

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).

before: picker after pull

After (this branch), chat picker after Settings → Models → Refresh: Ollama (3), embedding model absent.

after: picker after refresh

@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling extensions: ollama size: S labels Oct 8, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The 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

  • Before: The picker still lists only qwen2.5:0.5b.
  • After: The picker also lists qwen3:0.6b without a config edit or Gateway restart.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, useful correction with real entry-point proof and the previous compatibility defect resolved.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Real Ollama container, CLI, Gateway, and inspected picker screenshots demonstrate newly pulled chat models appearing after Refresh. Current-head output additionally proves configured supportsTools: false survives publication and an agent turn. Config bytes and stored formats remain unchanged, establishing a no-migration case.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Models pulled after Ollama setup remain missing from model pickers even after Refresh.
Reason: The change repairs a documented discovery workflow with a small provider-owned correction. The catalog area's prior contributor explicitly accepted the configured-list behavior change.

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
Reviewed head: 392ff91a365222bd301145d2ce5bb14218514a7d

Before merge

None.

Findings

None.

Agent review details

How this fits together

The 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
Loading

Technical review

Best 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

  • extensions/ollama/src/discovery-shared.ts: configured-model early return changes intended behavior with a stated reason (fix(agents): skip Ollama discovery when explicit models are configured #28827: Avoid discovery delays and timeouts when explicit Ollama models are configured.)
  • extensions/ollama/src/discovery-shared.ts: hosted cloud guard keeps the original intent (92264fb: Prevent provider-managed hosted catalogs from repeatedly expanding explicitly selected model inventories.)
  • extensions/ollama/src/discovery-shared.ts: live catalog publication keeps the original intent (9718729: Publish truthful acquisition outcomes and retain compatible last-good inventory through the shared catalog owner.)
  • docs/providers/ollama configuration, discovery, recipes, and troubleshooting changes intended behavior with a stated reason (a48a9f4: Split existing Ollama guidance by reader task while preserving its content.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main still needs the fix: Current-main blame shows the explicit-model early return remains. Comparing the merge base with fetched main confirms discovery-shared.ts and the registered-catalog regression file have not changed. (extensions/ollama/src/discovery-shared.ts:269, 6b2afbfe981a)
  • Prior finding resolved: The exact latest commit filters configured model IDs out of discovered rows. The shared merge retains those explicit rows, preventing discovered compatibility metadata from replacing supportsTools: false. (extensions/ollama/src/discovery-shared.ts:297, 392ff91a3652)
  • Registered catalog regression: The added planner-boundary test checks configured qwen2.5:0.5b retaining supportsTools: false, discovery adding qwen3:0.6b, embedding exclusion, and configured-row retention after HTTP 503. The body records the intended failures against the earlier head and main. (src/agents/models-config.ollama-secretref.test.ts:172, 392ff91a3652)
  • Observed picker proof: Both downloaded screenshots were inspected: before shows Ollama (1) with qwen2.5:0.5b; after shows Ollama (3) with qwen2.5:0.5b, qwen3:0.6b, and smollm2:135m. The embedding model is absent. These images support the visible inventory change.
  • Current-head real behavior: The captured PR body, source identity f11f6daa93fc019bdc738a7a49bac8d26a504e4f3dd245112bfc79275e7be204, records a disposable real Ollama container and isolated Gateway at 392ff91: refresh adds qwen3:0.6b, models.list retains qwen2.5:0.5b supportsTools: false, and an agent turn returns pong with no tool schemas. Config hashes remain unchanged. (392ff91a3652)
  • Accepted inventory tradeoff: The author previously implemented the merged Ollama catalog owner in fix(ollama): preserve model catalogs during discovery failures #139817. Their recorded decision at fix(ollama): models pulled after setup never appear in model pickers #167463 (comment) accepts expanding self-hosted configured inventories on explicit refresh; existing replace mode, discovery opt-out, and agent allowlists retain restricted inventories. (extensions/ollama/src/discovery-shared.ts:248, 392ff91a3652)

PR surface

Source +2, Tests +35, Docs +4. Total +41 across 8 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 12 10 +2
Tests 3 111 76 +35
Docs 4 13 9 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 136 95 +41

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.
  • remove proof: 📸 screenshot: Current real behavior proof evidence kind is live_output.

Label justifications:

  • P2: This repairs a bounded model-discovery problem for users who pull models after Ollama setup.
  • merge-risk: 🚨 compatibility: Configured self-hosted model lists cease acting as picker allowlists; the catalog area contributor explicitly accepted that tradeoff with existing opt-out paths.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-08T21:34:07.112Z sha 0e0a14a :: blocked before merge. :: [P1] Preserve explicit compatibility settings when rediscovering models
  • reviewed 2026-10-08T22:28:37.425Z sha 0e0a14a :: needs changes before merge. :: [P1] Preserve explicit compatibility settings when rediscovering models
  • reviewed 2026-10-08T22:50:33.934Z sha 40d037b :: needs changes before merge. :: [P1] Preserve explicit compatibility settings when rediscovering models

Reviewed October 8, 2026, 7:37 PM ET / 23:37 UTC (Revision 4).

@obviyus

obviyus commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

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.

@obviyus
obviyus marked this pull request as ready for review October 8, 2026 22:23
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Oct 8, 2026
@obviyus
obviyus merged commit 711e23c into main Oct 9, 2026
123 of 124 checks passed
@obviyus
obviyus deleted the fix/ollama-rediscover-pulled-models branch October 9, 2026 00:20
@obviyus

obviyus commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator Author

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.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 9, 2026
…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).

![before: picker after pull](https://github.com/user-attachments/assets/3dbfc9ab-7f34-44b1-a16e-476cbf66c055)

After (this branch), chat picker after Settings → Models → **Refresh**: Ollama (3), embedding model absent.

![after: picker after refresh](https://github.com/user-attachments/assets/c348e17c-c478-43ee-9173-844d5f44a837)

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: ollama merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant