Skip to content

fix(ollama): omit think when unset so the model default applies - #1990

Merged
gold-silver-copper merged 1 commit into
0xPlaygrounds:mainfrom
SarthakB11:fix/issue-1970
Jul 1, 2026
Merged

gold-silver-copper merged 1 commit into
0xPlaygrounds:mainfrom
SarthakB11:fix/issue-1970

Conversation

@SarthakB11

Copy link
Copy Markdown
Contributor

fix(ollama): omit think when unset so the model default applies

Description

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.

This makes OllamaCompletionRequest.think optional and skips serialization when it is unset,
so a request built without an explicit think omits the field entirely. Explicit
think: true | "low" | "medium" | "high" requests are unaffected.

Fixes #1970

Type of change

  • Bug fix

Testing

  • cargo test -p rig-core --lib providers::ollama::tests::: 28 passed, 0 failed.
  • Verified the no-think case omits the field, and the explicit true/low/medium/high cases 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 a max think level). The scope here is disjoint (default/omission only), but a small rebase conflict near the Think handling is possible if both land; happy to rebase on whichever merges first.

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>
@gold-silver-copper

Copy link
Copy Markdown
Contributor

AWESOME

@gold-silver-copper
gold-silver-copper added this pull request to the merge queue Jul 1, 2026
Merged via the queue into 0xPlaygrounds:main with commit d1151af Jul 1, 2026
6 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(ollama): think is always serialized (defaults to false), so a model's default thinking can't be used

2 participants