Skip to content

Chat: show the Thinking control for Ollama models that report the thinking capability - #10043

Merged
danielhanchen merged 29 commits into
unslothai:mainfrom
lonexreb:feat/ollama-connection-reasoning
Oct 5, 2026
Merged

danielhanchen merged 29 commits into
unslothai:mainfrom
lonexreb:feat/ollama-connection-reasoning

Conversation

@lonexreb

@lonexreb lonexreb commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

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", ...], ListModelResponse in api/types.go), so the selected model decides rather than a connection-level checkbox:

  • Backend: _list_models layers the /api/tags capability list onto the /v1/models rows (a failing /api/tags leaves the listing as is), and ProviderModelInfo carries an optional capabilities list.
  • Frontend: fetching models in the connection dialog stores thinking per model (learnCatalogModelCapabilities); a model reporting it gets a reasoning_effort ladder of low/medium/high/max with Thinking off sent as none, all values Ollama's /v1/chat/completions accepts. 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.
  • Research synthesis now sends the explicit none for Thinking off on reasoning_effort ladders that include it, matching the chat path.

Verification

  • studio/backend/tests/test_ollama_model_capabilities.py (10 tests) and studio/frontend/tests/ollama-connection-reasoning.test.ts (6 tests) plus two new cases in research-inference-request.test.ts; with the functional code reverted, 8 backend and 2 frontend tests fail.
  • Full frontend suite and the provider / Ollama backend test files pass; the only backend failures (test_mcp_server_ids_are_scoped_before_session_or_tool_access) fail identically on main.
  • npm run typecheck clean.
  • Existing Ollama connections pick up the capability the next time models are fetched in the connection dialog.

Before / after

Studio built at the merge base (left) and at this branch (right), against a stub Ollama that serves /v1/models and /api/tags, with the issue's custom model thinkingcap-27b-bottlecap:latest (reports thinking) and llama3.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:

Composer Thinking control before and after

After sending, choosing None sends reasoning_effort: "none" to Ollama (the stub recorded no reasoning_effort before, medium then none after). llama3.2:3b shows no control on either side:

Chat turns before and after

…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.
chatgpt-codex-connector[bot]

This comment was marked as outdated.

chatgpt-codex-connector[bot]

This comment was marked as outdated.

@oobabooga

Copy link
Copy Markdown
Member

Thanks for tracking this down, and the diagnosis is right: _apply_ollama_reasoning_controls has been in place since 1fe27b1, getExternalReasoningCapabilities had no ollama branch, so the control never appeared and that mapper stayed unreachable.

The connection-level flag is the problem. Ollama's native /api/tags reports a per-model capabilities list including thinking (ListModelResponse.Capabilities in its api/types.go), and _list_ollama_native_models in studio/backend/core/inference/external_provider.py already calls that endpoint, reducing each entry to {id, owned_by} and dropping the field. The checkbox asks users a question we can answer ourselves, and we would remove it once that is plumbed through.

Could you do the model-scoped version instead: carry capabilities through that discovery path, surface it on ProviderModelInfo and the /api/providers/models response, and key the ollama branch on the selected model rather than isReasoningModel?

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.
@lonexreb
lonexreb requested a review from NilayYadav as a code owner September 4, 2026 05:31
@lonexreb lonexreb changed the title Chat: surface the Thinking ladder for Ollama connections flagged as reasoning Chat: surface the Thinking ladder for Ollama models that report the thinking capability Sep 4, 2026
…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
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from lonexreb Oct 4, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 4, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 4, 2026
@unslothai unslothai deleted a comment from oobabooga Oct 4, 2026
@unslothai unslothai deleted a comment from oobabooga Oct 4, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 4, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 4, 2026
@unslothai unslothai deleted a comment from oobabooga Oct 4, 2026
@unslothai unslothai deleted a comment from oobabooga Oct 4, 2026
@unslothai unslothai deleted a comment from oobabooga Oct 4, 2026
@danielhanchen danielhanchen changed the title Chat: surface the Thinking ladder for Ollama models that report the thinking capability Chat: show the Thinking control for Ollama models that report the thinking capability Oct 4, 2026
@shimmyshimmer

Copy link
Copy Markdown
Member

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 35f83760a (no equivalent commit found on this PR)

chatgpt-codex-connector[bot] (on the mirror)

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 35f83760af

No triage reaction was recorded on the mirror

Verdict

The round converged at mirror 35f83760a (no equivalent commit found on this PR).

This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it.

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 5, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 5, 2026
@danielhanchen
danielhanchen merged commit afd6a6c into unslothai:main Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Studio: expose Thinking controls for Ollama connections and forward reasoning_effort

4 participants