This repository was archived by the owner on May 15, 2026. It is now read-only.
feat: Add native thinking support for Ollama models - #10952
Draft
ghost wants to merge 1 commit into
Draft
Conversation
- Add support for Ollama native thinking field (message.thinking) - Pass think option to Ollama chat request when reasoning is enabled - Map reasoning effort settings to Ollama think option values - Keep existing <think> tag detection as fallback for compatibility This enables reasoning blocks to display for Ollama models that support native thinking (Ollama 0.5.0+), such as gpt-oss models. Fixes #10949
Author
Review completed. No issues found. The implementation correctly:
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
|
Well, that's awfully convenient. My next feature request was going to be support for reasoning effort settings. Two birds, one stone. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
This PR attempts to address Issue #10949. Feedback and guidance are welcome.
Problem
Users with Ollama models that support native thinking (like gpt-oss-20b and gpt-oss-120b) were not seeing reasoning blocks appear in Roo Code. The reasoning content was not being detected or displayed.
Solution
This PR adds support for Ollama's native thinking feature (available since Ollama 0.5.0+):
message.thinkingfield in Ollama responses and yield it as reasoning contentthinkoption to Ollama chat requests when reasoning is enabled via settingshigh,medium,low,minimal) to Ollama'sthinkoption values<think>tag detection as a fallback for models that use that format (like DeepSeek R1)Changes
src/api/providers/native-ollama.ts: AddedgetThinkOption()method and native thinking support increateMessage()src/api/providers/__tests__/native-ollama.spec.ts: Added comprehensive tests for native thinking supportTesting
Usage
For models that support Ollama native thinking, users should:
enableReasoningEffort: true)supportsReasoningEffort: trueThe reasoning blocks should now appear for models like gpt-oss-20b and gpt-oss-120b when they return thinking content via the native
thinkingfield.Fixes #10949
Important
Adds native thinking support for Ollama models, enabling reasoning content detection and display, with tests for new functionality.
native-ollama.tsby checkingmessage.thinkingfield and yielding it as reasoning content.thinkoption values.<think>tag detection for backward compatibility.getThinkOption()inNativeOllamaHandlerto determinethinkoption based on model and settings.createMessage()inNativeOllamaHandlerto includethinkoption in API requests.native-ollama.spec.tsfor native thinking support, including reasoning field handling andthinkoption mapping.This description was created by
for 5762ad7. You can customize this summary. It will automatically update as commits are pushed.