You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(ollama): OllamaModelBackend has no way to reach Granite low_effort/reasoning_effort mode #1637
The native OllamaModelBackend forwards ModelOption.THINKING only as Ollama's own boolean think= kwarg (mellea/backends/ollama.py:589 non-streaming, :705 streaming). It never sends reasoning_effort or low_effort, so there is no way to reach Granite's low-effort reasoning mode through this backend — regardless of what value is passed to ModelOption.THINKING.
Contrast with other backends
The OpenAI and LiteLLM backends already translate a string THINKING value (e.g. "low") straight through as reasoning_effort (openai.py:712-751, litellm.py:417-442), and this has been verified to correctly trigger Granite 4.2's low_effort chat-template branch when going through Ollama's own /v1/chat/completions endpoint:
reliably produces markedly shorter reasoning output than "medium"/"high"/unset. So Ollama's server itself supports this — the gap is specifically that mellea's nativeOllamaModelBackend class (as opposed to routing Ollama through the OpenAI-compatible backend) never sends the parameter.
Suggested fix
Add the same string-to-reasoning_effort (or native equivalent, if Ollama's /api/chat supports one — needs checking, since Ollama's native /api/chatthink param is currently boolean-only per its docs) translation that the OpenAI/LiteLLM backends already have, so ModelOption.THINKING="low" behaves consistently whether a Granite model is reached via OllamaModelBackend or via OpenAIBackend/LiteLLMModelBackend pointed at the same Ollama server.
Environment
Verified against granite4.2:3b, Ollama 0.33.3, mellea on main (e6861c418).
Closing as not reproducible — this issue's premise was wrong, my error.
I claimed OllamaModelBackend only forwards ModelOption.THINKING as a bool think= kwarg. Re-checking mellea/backends/ollama.py:589,705: it's a raw passthrough (think=model_opts.get(ModelOption.THINKING, None)) with no bool cast at all. I'd tested bool values against native /api/chat and string values against the /v1 OpenAI-compat endpoint during the original investigation, but never tested a string against native /api/chat directly — and wrongly assumed it was bool-only based on how it's typically documented/typed, rather than testing it.
Empirical evidence (Ollama server 0.33.3, ollama pip package 0.6.1, granite4.2:3b):
Through mellea's actual OllamaModelBackend.generate_from_context:
medium/high are statistically identical — consistent with Granite's chat template only branching on reasoning_effort == "low" (see #1636 for that template logic), no distinct "high" tier exists on the model side regardless of backend.
Byte-identical cross-check, native think="low" vs OpenAI-compat reasoning_effort="low" (same seed/temp/prompt): both return the exact string "Explain Rayleigh scattering.\n" as the reasoning content — confirming native Ollama's think= already reaches the same low-effort branch as the /v1 path, no separate translation needed.
So: current mellea (main) already works correctly for Granite reasoning-effort strings via the native Ollama backend, with no code change required. Note mellea's pin is ollama>=0.5.1 — this hasn't been verified against that floor version, only against 0.6.1/server 0.33.3, so a regression test pinning this behavior is still worthwhile to guard against an older-Ollama environment silently regressing.
Thanks to the session that caught this while starting the fix PR — the empirical check here is theirs.
Activity
planetf1 commentedon Sep 9, 2026
Closing as not reproducible — this issue's premise was wrong, my error.
I claimed
OllamaModelBackendonly forwardsModelOption.THINKINGas a boolthink=kwarg. Re-checkingmellea/backends/ollama.py:589,705: it's a raw passthrough (think=model_opts.get(ModelOption.THINKING, None)) with no bool cast at all. I'd tested bool values against native/api/chatand string values against the/v1OpenAI-compat endpoint during the original investigation, but never tested a string against native/api/chatdirectly — and wrongly assumed it was bool-only based on how it's typically documented/typed, rather than testing it.Empirical evidence (Ollama server 0.33.3,
ollamapip package 0.6.1,granite4.2:3b):Through mellea's actual
OllamaModelBackend.generate_from_context:Raw ollama-py, fixed seed=1/temp=0, 3 repeats each:
medium/highare statistically identical — consistent with Granite's chat template only branching onreasoning_effort == "low"(see #1636 for that template logic), no distinct "high" tier exists on the model side regardless of backend.Byte-identical cross-check, native
think="low"vs OpenAI-compatreasoning_effort="low"(same seed/temp/prompt): both return the exact string"Explain Rayleigh scattering.\n"as the reasoning content — confirming native Ollama'sthink=already reaches the same low-effort branch as the/v1path, no separate translation needed.So: current mellea (
main) already works correctly for Granite reasoning-effort strings via the native Ollama backend, with no code change required. Note mellea's pin isollama>=0.5.1— this hasn't been verified against that floor version, only against 0.6.1/server 0.33.3, so a regression test pinning this behavior is still worthwhile to guard against an older-Ollama environment silently regressing.Thanks to the session that caught this while starting the fix PR — the empirical check here is theirs.