fix(providers): probe ollama thinking capability before sending reasoning_effort on custom endpoints - #108070
Open
tomRumi wants to merge 1 commit into
Open
fix(providers): probe ollama thinking capability before sending reasoning_effort on custom endpoints#108070tomRumi wants to merge 1 commit into
tomRumi wants to merge 1 commit into
Conversation
…ning_effort on custom endpoints Ollama's /v1/chat/completions rejects top-level reasoning_effort with HTTP 400 '"<model>" does not support thinking' when the model lacks the thinking capability (e.g. granite4:3b, ministral-3:8b). CustomProfile forwarded any configured effort verbatim, so a global agent.reasoning_effort: high broke every non-thinking local model with three retries and a failed turn. Users had to discover the error in logs and hand-write agent.reasoning_overrides per model — re-doing it for every model they ever pull. CustomProfile now reuses the existing ollama_model_supports_thinking() probe (native /api/show capabilities — the same authority the Ollama Cloud profile and ReasoningParamsMixin rely on) for Ollama-shaped custom endpoints: - capability absent -> omit reasoning_effort (request cannot 400) - capability present -> effort forwarded verbatim (qwen3, deepseek-r1...) - probe unreachable -> fail open, send the effort (worst case is the previous behaviour; a transient probe failure must not silently drop the user's reasoning config - non-Ollama custom endpoints (GLM/ARK, Groq, vLLM, llama.cpp) are untouched — no probe, no latency, NousResearch#57601 passthrough contract intact - definitive results cached per (model, base_url) on the profile singleton (one /api/show per model, not per request build); failures retried after a 60s TTL Also covers the auxiliary path (session titles etc.), which builds its kwargs through the same profile and 400'd the same way. EOF )
tomRumi
force-pushed
the
fix/custom-ollama-thinking-400
branch
from
September 11, 2026 09:12
b6e2ecd to
0411a22
Compare
Contributor
Related: this is the fourth open fix for #59660 alongside #95854, #81574 and #86197 (plus closed #63315). All gate |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Ollama's
/v1/chat/completionsrejects top-levelreasoning_effortwith HTTP 400"<model>" does not support thinkingwhenever the target model lacks thethinkingcapability (verified live:granite4:3b,ministral-3:8b; their/api/showcapabilities are[completion, tools]/[completion, vision, tools]).CustomProfileforwarded any configured effort verbatim, so a globalagent.reasoning_effort: highbroke every non-thinking local model: three retries, failed turn, and no hint in the UI — the error only surfaced inerrors.log. The workaround (agent.reasoning_overrides.<model>: disabled) must be re-done by hand for every non-thinking model the user ever pulls.The main conversation path and the auxiliary path (session-title generation, which resolves through the same profile) both hit it:
Fix
CustomProfilereuses the existinghermes_cli.models_local.ollama_model_supports_thinking()probe (native/api/showcapabilities— the same authorityOllamaCloudProfileandReasoningParamsMixin._ollama_supports_thinking_cached()already rely on) for Ollama-shaped custom endpoints before emitting an effort:thinkingin capabilitiesthinkingreasoning_effortomitted — request cannot 400_looks_like_ollama_endpointgate; #57601 passthrough contract intact)Definitive results are cached per
(model, base_url)on the profile singleton — one/api/showper model per process, not per request build; failed probes retry after a 60 s TTL (mirrors the_cached_probepolicy inreasoning_params.py). The explicit-disable path (reasoning_effort: none+think: false, #14820/#25758) is untouched and stays probe-free.Testing
tests/plugins/model_providers/test_custom_profile.py: omit-on-non-thinking, verbatim-on-thinking, fail-open onNone-returning and raising probes, definitive caching (+ distinct key per model), no probe on non-Ollama endpoints, disable path still probe-free.tests/plugins/model_providers/test_custom_profile.py+test_ollama_cloud_profile.py), existing 40 assertions unchanged and green.agent.reasoning_effort: highand no overrides,granite4:3bnow answers a one-shothermes chat -qturn (previously: 3x retry, then HTTP 400 failure).Notes for reviewers
/api/chathappily ignores thinking params; this only concerns the OpenAI-compat/v1route Hermes uses for custom providers._ephemeral_reasoning_off) but only covers disable-rejected routes; probing before sending is cheaper than a failed turn + retry cycle, and matches how Ollama Cloud is already handled.