Repository navigation
fix(ollama): send the thinking values each model supports - #168166
Conversation
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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +156, Tests +312, Docs +15, Other 0. Total +483 across 13 files. Added test files: 1. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 10, 2026, 3:34 AM ET / 07:34 UTC (Revision 4). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
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.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…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.
Related: #157762
What Problem This Solves
Native Ollama can receive unsupported thinking values for High/Maximum, and OpenClaw refuses
xhigheven when a model advertises it.User Impact
Discovered boolean models receive booleans, and graded models receive supported effort values. A model advertising
low,medium, andxhighreceivesxhighfor High/Maximum and accepts an explicitxhighselection. 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.thinkingretain 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 existingthinkingLevelMap, 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: falsesettings. 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.listrefresh, and realchat.sendmessages containing/think <level>followed by “Reply with exactly pong.” A transparent local proxy captured native/api/chatrequests.qwen3:8bfalse,truefalsetruetruetruegpt-oss:20blow,medium,highlowlowhighhighAll eight requests completed with
pongcontent; Qwen Low wrapped it in a text fence. There were zero/api/showcalls after the catalog refresh. Before the fix, Qwen High sent the unadvertised stringhigh, and GPT-OSS Off sent unadvertisedfalse; 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.historyreturned 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 nativexhighpayload are proven by the discovery-to-request regression using the reported Qwen3.8 descriptor shape, rather than claimed as live Qwen3.8 proof. A livexhighattempt on boolean Qwen remains correctly refused.Validation, timing, and review corrections
node scripts/run-vitest.mjs <file> --maxWorkers=1.pnpm build qaRuntimepassed 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.8fc1cb4dc682a9062a4bca05f50566720a7702b5.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.