Skip to content

fix(ollama): send the thinking values each model supports - #168166

Merged
steipete merged 5 commits into
mainfrom
feat/ollama-thinking-levels-from-show
Oct 10, 2026
Merged

steipete merged 5 commits into
mainfrom
feat/ollama-thinking-levels-from-show

Conversation

@steipete

@steipete steipete commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Related: #157762

What Problem This Solves

Native Ollama can receive unsupported thinking values for High/Maximum, and OpenClaw refuses xhigh even when a model advertises it.

User Impact

Discovered boolean models receive booleans, and graded models receive supported effort values. A model advertising low, medium, and xhigh receives xhigh for High/Maximum and accepts an explicit xhigh selection. Existing Off/Low/Medium/High/Max selections map through the shared thinking ladder. Minimal and XHigh are exposed only when advertised. For models that cannot disable thinking, Off selects their lowest supported value.

OpenClaw keeps its existing Off default. Explicit params.think/params.thinking retain precedence over implicit Off; enabled runtime selections still override them. Models without descriptors retain the shipped fallback. No new configuration or core contract is introduced.

Why This Change Was Made

The Ollama plugin already fetched and cached /api/show, but dropped its thinking descriptor. Discovery now prepares the existing thinkingLevelMap, and the catalog carries it through setup and runtime model projection to the native stream. Turns make no extra discovery request. Legacy OpenAI-compatible routes do not receive native boolean mappings.

The final native request layer owns mandatory-thinking floors, including saved reasoning: false / params.think: false settings. This preserves the established GLM behavior that keeps reasoning separate from answer text. Unsupported markers also keep shared capability readers aligned with the provider profile.

Production LOC is +226/-70 (net +156); tests +313/-1; documentation +21/-6; assertion baseline +1/-1. Descriptor validation, mapping, propagation, and decoding require the remaining growth after removing the obsolete parameter wrapper and consolidating dynamic model projection in the existing model-definition owner. Older-server fallback remains a shipped contract.

Evidence

Final-head live proof used Ollama 0.40.2, an isolated Gateway launched with pnpm openclaw --profile ollama-thinking gateway run, models.list refresh, and real chat.send messages containing /think <level> followed by “Reply with exactly pong.” A transparent local proxy captured native /api/chat requests.

Model Advertised values Off Low High Max
qwen3:8b false, true false true true true
gpt-oss:20b low, medium, high low low high high

All eight requests completed with pong content; Qwen Low wrapped it in a text fence. There were zero /api/show calls after the catalog refresh. Before the fix, Qwen High sent the unadvertised string high, and GPT-OSS Off sent unadvertised false; both baseline requests also answered. The temporary GPT-OSS model and proof Gateway/proxy have been cleaned up.

Existing data: the final Gateway reused the pre-change configuration and canonical SQLite state. chat.history returned the earlier baseline assistant reply unchanged, and the config file's SHA-256 remained identical. The unchanged shipped GLM floor cases and new discovered-model cases prove the saved-setting contract through both agent and direct-completion transport paths. No schema, storage format, or updater changed; this is retained-state and configuration compatibility proof, not a claimed full latest-stable updater campaign.

The approved live models do not advertise xhigh. Its formerly rejected profile entry and exact native xhigh payload are proven by the discovery-to-request regression using the reported Qwen3.8 descriptor shape, rather than claimed as live Qwen3.8 proof. A live xhigh attempt on boolean Qwen remains correctly refused.

Validation, timing, and review corrections
  • The initial feature regression run failed six intended cases on original production. The shared-capability regression later failed four cases before correction. Final targeted proof passes 48 tests across discovery/catalog/runtime-projection/native-stream, thinking-floor, and provider-policy suites in 190.67 s wall, dominated by shared compiler setup. Cases include native Minimal/XHigh, boolean and mandatory thinking, explicit parameter precedence, off-only metadata, legacy transport isolation, missing/malformed descriptors, and digest-cache refresh.
  • New boundary file: 14 cases. Provider-policy file: 21 cases (7.23 s standalone wall before the final marker-only change). Thinking-floor file: 13 cases. Existing index suite: 63 passed (147.22 s wall); focused discovery, setup, cloud, and stream siblings also passed. Commands use node scripts/run-vitest.mjs <file> --maxWorkers=1.
  • pnpm build qaRuntime passed on the frozen final head in 732.20 s wall, with its head and clean-input stamp verified. Earlier overlapping build/test and source-changing build attempts were correctly refused by freshness guards; no guard was bypassed.
  • Full extension production types, full extension test types, touched-file lint, and required max-lines, line-cap, assertion-safety, database-worker, test-timeout-race, test-mock-exports, config-docs, and plugin-inventory ratchets pass. The initial missing QA dev link was resolved by installing already-declared workspace dependencies in the isolated checkout; manifests and lockfiles did not change.
  • ClawSweeper and the first CI run caught the legacy GLM floor regression; CI also caught an invalid test-fixture auth-source enum. Both are fixed. The existing GLM case failed before repair, and two added discovered-model cases failed before preserving raw disabled requests until the final floor. Independent Codex review also caught implicit native-API handling and unsupported extra-tier opt-ins; both have regressions.
  • Final independent Codex autoreview is scoped-clean through P2 on 8fc1cb4dc682a9062a4bca05f50566720a7702b5.
  • Final-head CI run 38033987265 passed, including openclaw/ci-gate. The changed-extension job took 108 s, with 50 s in its Node test step (shared job cost, not incremental cost of this patch). ClawSweeper reviewed the same head at 2026-10-10 07:28 UTC: no findings, no Before merge items, proof sufficient, ready for maintainer review. This PR has not been merged.

Cache native thinking mappings from /api/show and use the shared thinking ladder for boolean and graded models. Preserve explicit thinking parameters, older-server fallbacks, and the OpenAI-compatible route. Related: #157762.
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: ollama size: L labels Oct 10, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR discovers each Ollama model’s supported thinking values and maps existing thinking selections to valid native requests.

Example: Select High for qwen3:8b advertising boolean thinking values.

  • Before: OpenClaw sends the unadvertised string "high".
  • After: OpenClaw sends true, as the model advertises.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused provider repair with real shipped-entry-point proof, retained configuration and history evidence, meaningful regressions, and no open findings; tests were inspected rather than executed during this read-only review.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Final-head live Gateway chat.send runs exercised discovery and native requests against real boolean Qwen3 and graded GPT-OSS models, returned answers with supported wire values, and showed no per-turn inspection calls; xhigh coverage is correctly identified as a regression harness rather than live model proof.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Thinking selections can send unsupported values or reject a model’s advertised effort tier.
Reason: The existing provider controls should produce supported requests, and the maintainer-authored direction preserves established defaults and compatibility contracts.

Merge readiness

✅ Ready for maintainer review

Keep this PR open for landing: it addresses a current provider defect, preserves established compatibility behavior, and has sufficient real Gateway proof with no actionable findings.

Priority: P2
Reviewed head: 8fc1cb4dc682a9062a4bca05f50566720a7702b5

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Ollama plugin turns discovery metadata and user thinking selections into native /api/chat payloads consumed by local or hosted Ollama servers.

flowchart LR
  A[Ollama model metadata] --> B[Discovery cache]
  B --> C[Model thinking map]
  C --> D[Thinking controls]
  D --> E[Native request adapter]
  C --> E
  E --> F[Ollama chat API]
Loading

Technical review

Best possible solution:

Land the plugin-owned descriptor mapping while retaining existing defaults, explicit-setting precedence, and descriptor-free fallbacks.

Do we have a high-confidence way to reproduce the issue?

Current-main source confirms that discovery drops thinking descriptors and native translation uses fixed values; supplied baseline traces demonstrate the mismatched requests.

Is this the best way to solve the issue?

The change repairs the provider’s existing discovery-to-request path, reuses the shared thinking ladder, and preserves explicit settings and legacy transport behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 5861fe788ef5.

Provenance checked

  • Cloud max-thinking fallback and provider profile changes intended behavior with a stated reason (9320bd3: Expose verified Cloud max effort while retaining compatible fallback mappings for other models.)
  • Final mandatory-thinking floor keeps the original intent (379e3d7: Prevent unsupported false from moving GLM reasoning into answer content across agent and direct-completion paths.)
  • Lazy transport and explicit thinking precedence keeps the original intent (2fc2fc9: Reduce inactive plugin startup cost while preserving synchronous compatibility policy and stream-wrapper behavior.)
  • Discovery metadata cache keeps the original intent (3da5822: Reuse model inspection metadata while the advertised digest or modification time remains stable.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +156, Tests +312, Docs +15, Other 0. Total +483 across 13 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 8 226 70 +156
Tests 3 313 1 +312
Docs 1 21 6 +15
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 13 561 78 +483

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +226/-70; tests +313/-1 Growth covers descriptor validation, shared-ladder mapping, existing projection paths, and boundary regressions without adding a parallel core capability.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #157762
Summary: This PR implements descriptor-driven native thinking mapping; the earlier GLM repair supplies a narrower compatibility floor.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Unsupported thinking values and refused advertised tiers are a bounded provider correctness problem.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-10T03:58:00.965Z sha 0b88c9c :: blocked before merge. :: [P2] Preserve the GLM thinking floor when reasoning is disabled
  • reviewed 2026-10-10T04:28:10.385Z sha 0b88c9c :: needs changes before merge. :: [P2] Preserve the GLM thinking floor when reasoning is disabled
  • reviewed 2026-10-10T07:28:45.922Z sha 8fc1cb4 :: needs maintainer review before merge. :: none

Reviewed October 10, 2026, 3:34 AM ET / 07:34 UTC (Revision 4).

@steipete
steipete marked this pull request as ready for review October 10, 2026 04:23
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Oct 10, 2026
Keep disabled requests intact until the final native floor, even when reasoning visibility suppresses enabled runtime settings. Preserve the shipped GLM contract and add discovered mandatory-model coverage for agent and direct completion paths. Correct the catalog auth fixture source type.
Keep unsupported markers for Minimal and XHigh so shared model capability readers and the provider profile agree. Decode prepared wire values when determining reasoning support, preserving off-only descriptors.
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 10, 2026
@steipete steipete self-assigned this Oct 10, 2026
@steipete
steipete merged commit b0539fd into main Oct 10, 2026
128 checks passed
@steipete
steipete deleted the feat/ollama-thinking-levels-from-show branch October 10, 2026 07:57
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
…68166)

* fix(ollama): honor model-specific thinking levels from discovery

Cache native thinking mappings from /api/show and use the shared thinking ladder for boolean and graded models. Preserve explicit thinking parameters, older-server fallbacks, and the OpenAI-compatible route. Related: openclaw#157762.

* fix(ollama): preserve discovered tiers with implicit native API

* chore(ollama): shrink assertion baseline after model projection cleanup

* fix(ollama): preserve mandatory thinking floors for saved settings

Keep disabled requests intact until the final native floor, even when reasoning visibility suppresses enabled runtime settings. Preserve the shipped GLM contract and add discovered mandatory-model coverage for agent and direct completion paths. Correct the catalog auth fixture source type.

* fix(ollama): expose extra thinking controls only when advertised

Keep unsupported markers for Minimal and XHigh so shared model capability readers and the provider profile agree. Decode prepared wire values when determining reasoning support, preserving off-only descriptors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: ollama P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant