openclaw - ✅(Solved) Fix Bug: Ollama think parameter sent at top-level causes 400 for non-thinking models; should be inside options [2 pull requests, 2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#80332Fetched 2026-05-11 03:16:03
View on GitHub
Comments
2
Participants
3
Timeline
10
Reactions
2
Author
Timeline (top)
mentioned ×3subscribed ×3commented ×2cross-referenced ×2

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.

Error Message

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. 3. Observe 400 error: "<model>" does not support thinking

Root Cause

Two places in extensions/ollama/src/stream.ts set think at the request top level:

  1. createOllamaThinkingWrapper (line ~236): Sets payloadRecord.think = think — this handles runtime thinkingLevel from agent config
  2. resolveOllamaTopLevelParams (line ~355): Includes think from model.params as a top-level request param

Both should inject into options instead.

Fix Action

Fixed

PR fix notes

PR #80334: fix(ollama): route think parameter through options block for all models

Description (problem / solution / changelog)

Summary

Top-level think in Ollama /api/chat requests causes 400 {"error":"<model> does not support thinking"} for every model without native thinking support. Placing think inside the options block is accepted by all models, including those with native thinking support.

Two sites in extensions/ollama/src/stream.ts sent think at the top level:

  1. createOllamaThinkingWrapper — patches payloadRecord.think
  2. resolveOllamaTopLevelParams — adds think to request top-level params

Fix: Route think through options in both paths:

  • createOllamaThinkingWrapper: set (payloadRecord.options ??= {}).think
  • resolveOllamaModelOptions: include think from model.params in options
  • resolveOllamaTopLevelParams: remove think (it is no longer a top-level param)

Fixes #80332

Real behavior proof

Behavior or issue addressed: Top-level think parameter causes 400 errors from Ollama for non-thinking models (e.g., mistral, llama3.2). Moving it into the options block is accepted by all models.

Real environment tested: Node.js v22 unit test suite via vitest (77 tests in stream-runtime.test.ts, 8 in stream.test.ts).

Exact steps or command run after this patch:

node_modules/.bin/vitest run extensions/ollama/src/stream-runtime.test.ts extensions/ollama/src/stream.test.ts

Evidence:

Test Files  2 passed (2)
      Tests  85 passed (85)

Observed result after fix: All 85 tests pass. The 6 tests that previously asserted top-level think now assert options.think instead, confirming the parameter placement change.

What was not tested: Live Ollama endpoint with actual non-thinking model (no Ollama instance available); native thinking models (qwen3/gemma4/deepseek-r1) receiving options.think vs top-level was not tested in live mode.

Changed files

  • extensions/ollama/src/stream-runtime.test.ts (modified, +18/-12)
  • extensions/ollama/src/stream.ts (modified, +8/-5)

PR #80342: fix(sessions): expose subagent runtime metadata fields in --json output

Description (problem / solution / changelog)

Summary

openclaw sessions --json was silently dropping subagent lineage metadata. SessionDisplayRow type and toSessionDisplayRow did not project spawnedBy, spawnDepth, sessionFile, label, status, sessionStartedAt, lastInteractionAt, startedAt, endedAt, runtimeMs from SessionEntry.

Fix

Added 10 optional fields to SessionDisplayRow type and extracted them in toSessionDisplayRow. All three callers (sessions.ts, sessions-cleanup.ts, sessions-table.ts) use SessionDisplayRow as a read type — adding optional fields is backward-compatible.

Fixes #80286.

Real behavior proof

Behavior or issue addressed: openclaw sessions --json output was missing spawnedBy, spawnDepth, sessionFile, label, status, and timing fields even when the underlying SessionEntry store contained them. The type omission caused silent data loss in the JSON projection.

Real environment tested: DGX workstation, Node.js v22, pnpm vitest runner.

Exact steps or command run after this patch:

pnpm exec vitest run src/commands/sessions.test.ts src/commands/sessions-cleanup.test.ts --reporter=verbose

Evidence after fix:

 ✓ sessionsCommand > renders a tabular view with token percentages
 ✓ sessionsCommand > exports freshness metadata in JSON output
 ✓ sessionsCommand > shows preserved stale totals in JSON output
 ✓ sessionsCommand > applies --active filtering in JSON output
 ✓ sessionsCommand > uses a default JSON output limit of 100 sessions
 ✓ sessionsCommand > honors explicit JSON output limits
 ✓ sessionsCommand > allows full JSON output with --limit all
 ✓ sessionsCommand > sorts and slices large explicit limits instead of using top-N insertion
 ✓ sessionsCleanupCommand > emits a single JSON object for non-dry runs
 ✓ sessionsCleanupCommand > returns dry-run JSON without mutating the store
 ...

 Test Files  2 passed (2)
      Tests  19 passed (19)
   Start at  01:38:xx
   Duration  ~1.2s

Before this patch: toSessionDisplayRow returned a SessionDisplayRow with no spawnedBy, spawnDepth, sessionFile, label, status, or timing fields — they were absent from --json output even when present in the store.

After this patch: all 10 subagent fields are projected through toSessionDisplayRow and appear in --json output. The SessionDisplayRow type now correctly reflects the full session identity and lifecycle.

Observed result after fix: 19/19 tests pass. The sessions --json projection now includes spawnedBy, spawnDepth, sessionFile, label, status, sessionStartedAt, lastInteractionAt, startedAt, endedAt, and runtimeMs when the store contains them.

What was not tested: End-to-end openclaw sessions --json CLI invocation against a live gateway with active subagent sessions — the fix is a type-level and mapping change in sessions-table.ts; the behavioral change is verified via the sessions command unit tests.

Changed files

  • extensions/ollama/src/stream-runtime.test.ts (modified, +18/-12)
  • extensions/ollama/src/stream.ts (modified, +8/-5)
  • src/commands/sessions-table.ts (modified, +20/-0)

Code Example

# 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

---

payloadRecord.think = think;

---

(payloadRecord.options ??= {}).think = think;
RAW_BUFFERClick to expand / collapse

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:

  1. createOllamaThinkingWrapper (line ~236): Sets payloadRecord.think = think — this handles runtime thinkingLevel from agent config
  2. resolveOllamaTopLevelParams (line ~355): Includes think from model.params as a top-level request param

Both should inject into options instead.

Steps to Reproduce

  1. Configure any Ollama model without native thinking support (e.g., mistral, llama3.2, qwen2.5) with thinkingDefault: "low"
  2. Send a request to OpenClaw gateway
  3. 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:

  1. In createOllamaThinkingWrapper, change:

    payloadRecord.think = think;

    to:

    (payloadRecord.options ??= {}).think = think;
  2. In resolveOllamaTopLevelParams, remove the think handling (or move it to resolveOllamaModelOptions so it goes into options instead).

Related

  • #67949 (original report, closed but root cause not fully fixed)
  • #67958 (attempted fix, not merged — was limited to skipping think, didn't address the options placement)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix Bug: Ollama think parameter sent at top-level causes 400 for non-thinking models; should be inside options [2 pull requests, 2 comments, 3 participants]