Repository navigation
fix(ollama): retain advertised context and tools when model inspection is unavailable - #130000
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 5:19 AM ET / 09:19 UTC. ClawSweeper reviewWhat this changesThe PR retains context-window and tool-capability metadata from Ollama’s model-list response when optional per-model inspection fails or omits those values. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessThis is a coherent owner-boundary repair for a defect still present on current main; it should remain open for normal maintainer review while exact-head CI completes. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherThe Ollama plugin lists installed local models, optionally enriches each model through per-model inspection, then supplies the resulting definitions to provider discovery and interactive setup. Those definitions determine the recommended model, context limit, and tool availability. flowchart LR
A[Ollama model list] --> B[Model metadata owner]
C[Per-model inspection] --> B
B --> D[Metadata precedence]
D --> E[Provider discovery]
D --> F[Interactive setup]
E --> G[Model definition]
F --> G
G --> H[Context and tool behavior]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -2, Tests +142. Total +140 across 4 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge the shared metadata-precedence repair once exact-head CI is green, preserving explicit inspection values—including an explicit empty capability list—over advertised list metadata. Do we have a high-confidence way to reproduce the issue? Yes. Current main’s two Object.assign paths overwrite advertised list metadata with absent inspection fields; the PR’s focused tests encode failed and incomplete inspection sequences through provider discovery and setup. Is this the best way to solve the issue? Yes. One metadata-owner merger covers both callers, preserves conservative behavior when no list capability exists, and keeps explicit inspection metadata authoritative. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 771d5e5393dd. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
b4ea0ef to
296227f
Compare
|
Measured this at
The core repair reproduces, and it is worth more than the body claims
main did not merely report a wrong-but-harmless number; it advertised 15x a small model's real window, which is the direction that actually breaks a run. The body undersells this by framing it as "an incorrect 128,000-token context window". Three things the current tests do not pin, all downstream of list capabilities now surviving. 1. Rows whose list capabilities omit
|
| row | main | this branch |
|---|---|---|
gpt-oss:120b-cloud, remote_host set, capabilities: ["tools","thinking"] |
present | dropped |
Unless the cloud manifest's cfg.Capabilities always carries completion, this removes cloud models from discovery in exactly the degraded-inspection case the PR is about. Treating an absent completion as "unknown, keep" and excluding only on an explicit embedding would keep the intent without the new exclusion.
2. isReasoningModelHeuristic is now effectively unreachable on the discovery path
provider-models.ts:378-380:
capabilities === undefined
? isReasoningModelHeuristic(modelId)
: capabilities.includes("thinking")The heuristic now runs only when the field is entirely absent — pre-capabilities Ollama. Every modern list row carries capabilities, so any row whose capabilities lack thinking resolves reasoning: false with no name fallback. Upstream adds thinking only inside if tmpl != nil (L367-L387) and never for remote rows, so "has capabilities, no thinking" is a reachable shape rather than a hypothetical.
deepseek-r1:8b with capabilities: ["completion","tools"] and an empty /api/show: reasoning: true on main, reasoning: false on this branch. The body covers context and tools precedence but is silent on reasoning, and the live test keeps its deepseek-r1 row capability-free — the one shape that still reaches the heuristic.
3. The same ?? selects an app-guided default that violates the selector's own policy
setup-model-selection.ts:116 repeats the pattern:
reasoning: model.capabilities?.includes("thinking") ?? isReasoningModelHeuristic(model.name),?? falls back only on undefined, so a present-but-incomplete capability list silences the heuristic here too, while selectAppGuidedOllamaModelId prefers non-reasoning models before picking the smallest.
Two tool-capable rows, both above the 16_384 floor, /api/show empty, this branch:
deepseek-r1:1.5b (1.1 GB) list capabilities |
app-guided default |
|---|---|
["completion","tools"] |
deepseek-r1:1.5b |
["completion","tools","thinking"] (control arm) |
llama3.1:8b (4.7 GB) |
main selects nothing at all in this setup, so this is not a regression — it is the newly reachable default-selection path landing on a reasoning model precisely because the heuristic no longer runs. The control arm confirms the flip is the reasoning flag and not the harness.
Suggested shape
For 2 and 3, keep the name heuristic as an || rather than a fallback whenever the capability list came from the list response instead of an explicit inspection. That is the same rule this PR already applies to contextWindow: the list is authoritative for what it asserts, not for what it omits. showInspectionFailed already distinguishes those provenances, and mergeOllamaModelShowInfo is the natural place to record whether capabilities came from /api/show or /api/tags.
|
Merged via squash.
|
…n is unavailable (openclaw#130000) * fix(ollama): preserve model metadata from discovery * test(ollama): use numeric status in discovery fixture
What Problem This Solves
Fixes an issue where users configuring a tools-capable local Ollama model would receive no recommended default, an incorrect 128,000-token context window, or disabled tools when Ollama already advertised the correct capabilities and context in
/api/tagsbut/api/showfailed or omitted those fields.Why This Change Was Made
Ollama's upstream list response already contains both
capabilitiesanddetails.context_length; its actual list producer and upstream regression test independently confirm both facts.Merge those authoritative list facts once in the Ollama plugin's model-metadata owner and reuse that owner for provider discovery and interactive setup. Explicit
/api/showmetadata remains higher authority, including an explicit empty capability array; failed inspection without advertised capabilities remains conservative, and the existing public list-response shape, authentication behavior, config surface, and storage stay unchanged. Production code shrinks by two lines (+20/-22).User Impact
Operators can complete Ollama setup with the correct installed default, accurate native context window, and working tools even when optional per-model inspection is temporarily unavailable or incomplete. Existing older Ollama responses and explicit unsupported-model capability lists retain their previous behavior.
Evidence
details.context_length: 32768andcapabilities: ["completion", "tools"]instead configuredcontextWindow: 128000, disabled tools after failed inspection, and left interactive setup without a default model./api/tagsand failing/api/showrequests; sibling cases cover missing show fields, stronger show metadata, explicit empty capabilities, and legacy responses.node scripts/run-vitest.mjs extensions/ollama/src/provider-models.test.ts extensions/ollama/src/provider-models.ssrf.test.ts extensions/ollama/src/provider-models.preflight-timeout.test.ts extensions/ollama/src/setup-model-selection.test.ts extensions/ollama/src/setup.test.ts extensions/ollama/src/setup.cancellation.test.ts extensions/ollama/src/setup-pull.test.ts extensions/ollama/src/setup-body-release.test.ts extensions/ollama/src/discovery-shared.test.ts extensions/ollama/src/provider-base-url.test.ts extensions/ollama/provider-discovery.test.ts extensions/ollama/provider-discovery.import-guard.test.ts extensions/ollama/provider-policy-api.test.ts extensions/ollama/index.test.ts— 14 files, 355 tests passed.jsonResponserequires its HTTP status as a number); that fixture is corrected on the current head, and the complete 355-test suite, focused lint, and whole-branch P1 review were rerun successfully.build-artifactsfailure was an unrelated Control UI startup CSS budget overflow (46,092 Bversus46,080 B) inherited from the movingmainmerge-ref. The canonical fix landed separately in fix(ui): remove unused startup styles to restore css budget #130027; this branch was mechanically rebased onto that repaired commit, withgit range-diffconfirming both Ollama commits remained patch-identical, followed by a fresh 355-test run, focused lint, and clean whole-branch P1 review.