Repository navigation
Chat: show the Thinking control for Ollama models that report the thinking capability - #10043
Conversation
…easoning The backend has mapped thinking controls onto Ollama's reasoning_effort field since 1fe27b1, but the frontend never advertised the capability: getExternalReasoningCapabilities() had no ollama path, so Studio hid the Thinking control and a reasoning-capable Ollama model burned its default thinking budget on every prompt with no way to turn it off (unslothai#9649's 89-second trivial prompt). Ollama's OpenAI-compat endpoint does not advertise reasoning per model -- the same shape vLLM has -- so this joins ollama to vLLM's existing connection-level "Reasoning model" toggle contract, and resolves a flagged connection to a reasoning_effort ladder (low/medium/high/max, exactly the non-none values Ollama accepts; off maps to "none" in the adapter and backend). Unflagged connections keep no controls, because Ollama errors a thinking request at a model that cannot think. Closes unslothai#9649.
|
Thanks for tracking this down, and the diagnosis is right: The connection-level flag is the problem. Ollama's native Could you do the model-scoped version instead: carry |
The connection-level "Reasoning model" checkbox was a guess standing in for a
fact Ollama already reports: /api/tags carries a per-model `capabilities` list
that names "thinking". One connection serves both thinking and non-thinking
models, so a checkbox is necessarily wrong for half of them.
Backend. `_list_ollama_native_models` kept only {id, owned_by} and dropped the
capabilities; it now carries them, and `ProviderModelInfo` /
POST /api/providers/models pass them through.
The design choice worth reviewing: /v1/models answers first on a populated
Ollama host and has no capability field, so the native catalog would only ever
be consulted on the empty-catalog fallback path. Rather than switch the primary
listing to /api/tags for the ollama provider type — which would change which
endpoint decides the id set — `_with_ollama_capabilities` keeps /v1/models as
the id source and layers the native capabilities onto matching ids. The extra
call is ollama-only and non-fatal: an unreachable /api/tags leaves a working
catalog untouched rather than failing the listing.
A row that reports no capabilities at all (older Ollama) stays absent rather
than becoming an empty list, so "said nothing" never reads as "said no".
Frontend. `getExternalReasoningCapabilities` resolves the ollama ladder from the
selected model's thinking capability instead of `options.isReasoningProvider`,
and "ollama" leaves REASONING_TOGGLE_PROVIDER_TYPES so the checkbox is gone
(vLLM, which has no per-model signal, keeps it).
Second design choice: rather than add an options field the five call sites would
each have to populate, the capability is read through the existing per-model
capability map — the same channel `providerModelSupportsStudioTools` already
uses from this file, and the same one the Codex plan catalog already learns from
a models fetch. The catalog fetch in the connections dialog folds the names in
via `learnCatalogModelCapabilities`. This keeps the five call sites untouched
and cannot desync from the model id actually being resolved, since the lookup
uses the id passed to `getExternalReasoningCapabilities` itself.
The catalog is the truth for the rows it describes, so a model that stops
reporting "thinking" is written back as false instead of latching on its last
yes. A model the catalog never described reads as unknown, and unknown is not a
yes — Ollama errors a thinking request at a model that cannot think.
Unchanged: the low/medium/high/max effort ladder, Thinking-off sending "none",
and the vLLM `enable_thinking` path.
Tests. New studio/backend/tests/test_ollama_model_capabilities.py covers the
native carry, the /v1/models augment, the unreachable-tags tolerance, the
non-ollama no-op, and the route's shape guard: 8 of its 10 fail against the
pre-change backend. The existing frontend test moves from flagged-connection
assertions to selected-model ones (the vllm pin stays); against pre-change
source both of its behavioural claims fail.
…into feat/ollama-connection-reasoning
…n-reasoning # Conflicts: # studio/frontend/src/features/chat/external-providers.ts # studio/frontend/src/features/chat/provider-capabilities.ts
…n-reasoning # Conflicts: # studio/frontend/tests/research-inference-request.test.ts
|
Review record for #10043, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#396. Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found. Round 1: reviewed mirror
|
Closes #9649.
What
A thinking-capable model behind an Ollama connection always used its default thinking budget, because Studio never showed the Thinking control for Ollama models (the issue's trivial prompt took 89 s). The backend already maps thinking controls onto Ollama's
reasoning_effort(_apply_ollama_reasoning_controls, #9770); the frontend never advertised the capability, so that mapper was unreachable. The models.dev catalog on main only covers Ollama cloud ids, so locally pulled models still get no control.How
Ollama reports capabilities per model on
/api/tags(capabilities: ["completion", "thinking", ...],ListModelResponseinapi/types.go), so the selected model decides rather than a connection-level checkbox:_list_modelslayers the/api/tagscapability list onto the/v1/modelsrows (a failing/api/tagsleaves the listing as is), andProviderModelInfocarries an optionalcapabilitieslist.thinkingper model (learnCatalogModelCapabilities); a model reporting it gets areasoning_effortladder oflow/medium/high/maxwith Thinking off sent asnone, all values Ollama's/v1/chat/completionsaccepts. Models without the capability, hand-typed ids, and older Ollama builds that report no capabilities keep no control, since Ollama rejects a thinking request at a model that cannot think.nonefor Thinking off onreasoning_effortladders that include it, matching the chat path.Verification
studio/backend/tests/test_ollama_model_capabilities.py(10 tests) andstudio/frontend/tests/ollama-connection-reasoning.test.ts(6 tests) plus two new cases inresearch-inference-request.test.ts; with the functional code reverted, 8 backend and 2 frontend tests fail.test_mcp_server_ids_are_scoped_before_session_or_tool_access) fail identically on main.npm run typecheckclean.Before / after
Studio built at the merge base (left) and at this branch (right), against a stub Ollama that serves
/v1/modelsand/api/tags, with the issue's custom modelthinkingcap-27b-bottlecap:latest(reportsthinking) andllama3.2:3b(does not). Models are loaded through Settings > Connections > Load available models.The composer now shows the Thinking effort control for the thinking model; before, there was none:
After sending, choosing None sends
reasoning_effort: "none"to Ollama (the stub recorded noreasoning_effortbefore,mediumthennoneafter).llama3.2:3bshows no control on either side: