Bug type
Behavior bug (incorrect output/state without crash)
Summary
OpenClaw sends think as a top-level parameter in Ollama /api/chat requests, but Ollama only accepts top-level think for models with native thinking support (e.g., Gemma 4, DeepSeek R1). For all other models, the top-level think field causes a 400 {"error":"\"<model>\" does not support thinking"} error.
However, sending think inside the options block (options: {think: "low"}) works correctly for ALL models and provides a reasoning token budget.
Root Cause
Two places in extensions/ollama/src/stream.ts set think at the request top level:
createOllamaThinkingWrapper (line ~236): Sets payloadRecord.think = think — this handles runtime thinkingLevel from agent config
resolveOllamaTopLevelParams (line ~355): Includes think from model.params as a top-level request param
Both should inject into options instead.
Steps to Reproduce
- Configure any Ollama model without native thinking support (e.g.,
mistral, llama3.2, qwen2.5) with thinkingDefault: "low"
- Send a request to OpenClaw gateway
- Observe 400 error:
"<model>" does not support thinking
Direct Ollama API proof
# Top-level think — FAILS for non-thinking models
curl http://localhost:11434/api/chat -d '{
"model": "llama3.2:1b",
"messages": [{"role":"user","content":"hi"}],
"think": "low"
}'
# → 400: "llama3.2:1b does not support thinking"
# think inside options — WORKS for all models
curl http://localhost:11434/api/chat -d '{
"model": "llama3.2:1b",
"messages": [{"role":"user","content":"hi"}],
"options": {"think": "low"}
}'
# → 200, response works normally
Expected Behavior
The think parameter should be sent inside the options block for all Ollama models (or at minimum, top-level think should only be used for models that are heuristically detected as having native thinking support).
Suggested Fix
In extensions/ollama/src/stream.ts:
-
In createOllamaThinkingWrapper, change:
payloadRecord.think = think;
to:
(payloadRecord.options ??= {}).think = think;
-
In resolveOllamaTopLevelParams, remove the think handling (or move it to resolveOllamaModelOptions so it goes into options instead).
Related
Bug type
Behavior bug (incorrect output/state without crash)
Summary
OpenClaw sends
thinkas a top-level parameter in Ollama/api/chatrequests, but Ollama only accepts top-levelthinkfor models with native thinking support (e.g., Gemma 4, DeepSeek R1). For all other models, the top-levelthinkfield causes a400 {"error":"\"<model>\" does not support thinking"}error.However, sending
thinkinside theoptionsblock (options: {think: "low"}) works correctly for ALL models and provides a reasoning token budget.Root Cause
Two places in
extensions/ollama/src/stream.tssetthinkat the request top level:createOllamaThinkingWrapper(line ~236): SetspayloadRecord.think = think— this handles runtimethinkingLevelfrom agent configresolveOllamaTopLevelParams(line ~355): Includesthinkfrommodel.paramsas a top-level request paramBoth should inject into
optionsinstead.Steps to Reproduce
mistral,llama3.2,qwen2.5) withthinkingDefault: "low""<model>" does not support thinkingDirect Ollama API proof
Expected Behavior
The
thinkparameter should be sent inside theoptionsblock for all Ollama models (or at minimum, top-levelthinkshould only be used for models that are heuristically detected as having native thinking support).Suggested Fix
In
extensions/ollama/src/stream.ts:In
createOllamaThinkingWrapper, change:to:
In
resolveOllamaTopLevelParams, remove thethinkhandling (or move it toresolveOllamaModelOptionsso it goes intooptionsinstead).Related