feat(ollama-cloud): add reasoning_effort support (xhigh->max) - #51482
feat(ollama-cloud): add reasoning_effort support (xhigh->max)#51482kshitijk4poor wants to merge 2 commits into
Conversation
Map Hermes xhigh→max to unlock DeepSeek V4's 'Max thinking' tier through Ollama Cloud's OpenAI-compatible /v1/chat/completions endpoint. low/medium/high pass through unchanged; disabled/none suppress reasoning entirely. Empirically confirmed: reasoning_effort:max produces ~2.5× more thinking tokens than high on deepseek-v4-pro:cloud (1576 vs 642).
Related: salvage of #29221 (@s010mn), part of the ollama-cloud |
08f1064 to
0f36445
Compare
… semantics
Three follow-up fixes to the salvaged reasoning_effort support, all verified
live against ollama.com /v1/chat/completions + /api/show on deepseek-v4-pro,
gemma3, and qwen3-coder:
1. Capability-gate on /api/show 'thinking'. The original ignored the
supports_reasoning flag and emitted reasoning_effort for every model. Now
gated: only models whose native /api/show capabilities list contains
'thinking' (deepseek-v4 yes; gemma3 / qwen3-coder no) get reasoning_effort.
Mirrors the LM Studio pattern — capability resolved once per (model,
base_url) in run_agent._supports_reasoning_extra_body via a cached probe
(hermes_cli.models.ollama_model_supports_thinking), threaded into the
profile hook as supports_reasoning. No live HTTP in the per-request path.
2. Disable actually disables. Ollama Cloud defaults to thinking ON and IGNORES
the extra_body.thinking:{type:disabled} shape (verified: still returned
reasoning). The only working off switch is top-level reasoning_effort:'none'.
The salvaged code returned ({}, {}) for enabled:false / effort:none, leaving
thinking ON. Now emits {'reasoning_effort': 'none'}.
3. Omit unrecognized effort. The original forwarded any unknown string verbatim
including 'minimal' (a real Hermes effort level). Ollama Cloud rejects
unrecognized values with a hard HTTP 400 (accepted set: low/medium/high/
max/none), so forwarding 'minimal' would break the request. Now omitted.
Core touches (run_agent.py, hermes_cli/models.py) add the capability probe;
the plugin profile only consumes the resolved flag. 24/24 profile tests green;
194 provider/transport tests unaffected.
0f36445 to
9b93948
Compare
|
Merged via PR #65723 — your follow-up commit was cherry-picked onto current main with your authorship preserved in git history ( The live verification against ollama.com (especially discovering that |
Summary
Hermes can now send
reasoning_effortto Ollama Cloud's OpenAI-compatible/v1/chat/completionsendpoint — but only for models that actually support thinking — unlocking DeepSeek V4's "Max thinking" tier viareasoning_effort: "max". Previously the bare ollama-cloud profile silently dropped all reasoning config.Salvage of #29221 by @s010mn onto current
main(cherry-picked, authorship preserved), plus one follow-up commit from me with three correctness fixes — all verified live againstollama.com.Changes
plugins/model-providers/ollama-cloud/__init__.py(@s010mn + my follow-up):OllamaCloudProfileoverridesbuild_api_kwargs_extrasto emit top-levelreasoning_effort.xhigh/max→max;low/medium/highpass through.deepseek-v4-pro/gemma3/qwen3-coder:/api/showcapabilitieslist containsthinkinggetreasoning_effort. Resolved once per(model, base_url)inrun_agent._supports_reasoning_extra_bodyvia a cached probe (hermes_cli.models.ollama_model_supports_thinking), threaded into the profile assupports_reasoning— no live HTTP in the per-request path. Mirrors the existing LM Studio capability pattern. The original ignored the flag and emitted for every model.extra_body.thinking:{disabled}(verified). The only off switch is top-levelreasoning_effort: "none". The original returned({}, {})on disable → thinking stayed on. Now emits{"reasoning_effort": "none"}.minimal(a real Hermes level). Ollama Cloud hard-400s unrecognized values (accepted set:{low, medium, high, max, none}). Now omitted → model default.Why the core touches
run_agent.py+hermes_cli/models.pygain the capability probe (where reasoning-capability resolution already lives, e.g. LM Studio). The plugin profile only consumes the resolvedsupports_reasoningflag — it doesn't reach into core.Validation (live against
ollama.com)deepseek-v4-pro/api/showcapabilities: [...,"thinking"]→ gated ONgemma3:27b,qwen3-coder:480bthinkingcap → noreasoning_effortxhighreasoning_effort="max"enabled:falsereasoning_effort="none"(real off switch)extra_body.thinking:{disabled}reasoning_effort:"ultra"Credit
Salvaged from #29221 by @s010mn. Cherry-picked with authorship preserved; one follow-up commit on top.