feat: Add native thinking support for Ollama models #10952
Draft
+278
−2
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.