fix(ollama): omit think when unset so the model default applies - #1990
Merged
Merged
Conversation
The Ollama provider always serialized a `think` field, defaulting it to `false` when the caller did not set one. Ollama's /api/chat treats `think` as tri-state: an absent field means 'use the model's default', `false` suppresses thinking, and `true`/level forces it. By always sending `false`, rig turned off thinking that a model would otherwise do by default, and there was no way to express the neutral absent state. Make OllamaCompletionRequest.think an Option<Think> with skip_serializing_if = 'Option::is_none', so a request built without an explicit `think` omits the field entirely. Explicit `think: true | 'low' | 'medium' | 'high'` requests are unaffected. Fixes 0xPlaygrounds#1970 Signed-off-by: SarthakB11 <sarthak.bhardwaj21b@iiitg.ac.in>
Contributor
|
AWESOME |
Merged
This was referenced Jul 11, 2026
Closed
Closed
Closed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(ollama): omit
thinkwhen unset so the model default appliesDescription
The Ollama provider always serialized a
thinkfield, defaulting it tofalsewhen thecaller did not set one. Ollama's
/api/chattreatsthinkas tri-state: an absent fieldmeans "use the model's default",
falsesuppresses thinking, andtrue/level forces it.By always sending
false, rig turned off thinking that a model would otherwise do by default,and there was no way to express the neutral absent state.
This makes
OllamaCompletionRequest.thinkoptional and skips serialization when it is unset,so a request built without an explicit
thinkomits the field entirely. Explicitthink: true | "low" | "medium" | "high"requests are unaffected.Fixes #1970
Type of change
Testing
cargo test -p rig-core --lib providers::ollama::tests::: 28 passed, 0 failed.thinkcase omits the field, and the explicittrue/low/medium/highcases still serialize the expected top-level value.AI assistance
This PR was written with the assistance of AI tools (Claude Code).
Notes
PR #1982 also edits
crates/rig-core/src/providers/ollama.rs(adding amaxthink level). The scope here is disjoint (default/omission only), but a small rebase conflict near theThinkhandling is possible if both land; happy to rebase on whichever merges first.