feat(ollama): pass think=false to custom providers when reasoning_effort is none#3197
Closed
Mibayy wants to merge 1 commit into
Closed
feat(ollama): pass think=false to custom providers when reasoning_effort is none#3197Mibayy wants to merge 1 commit into
Mibayy wants to merge 1 commit into
Conversation
…ort is none When a custom/Ollama provider is used and reasoning_effort is set to 'none' (or enabled: false), inject 'think': false into the request extra_body. Ollama does not recognise the OpenRouter-style 'reasoning' extra_body field, so thinking-capable models (Qwen3, etc.) generate <think> blocks regardless of the reasoning_effort setting. This produces empty-response errors that corrupt session state. The fix adds a provider-specific block in _build_api_kwargs() that sets think=false in extra_body whenever self.provider == 'custom' and reasoning is explicitly disabled. Closes NousResearch#3191
Contributor
|
@teknium1 @Mibayy this is wrong. this solves nothing to the raised issue. Thinking still happens. "POST /v1/chat/completions" endpoint, that is used by hermes agent for OpenAI compatible endpoints for Ollama interaction does not support "think":False. The correct injection should be "reasoning_effort":"none" which works. I tested it by patching hermes agent (run_agent.py) v0.10.0 like this: Please fix this with a new pull request and proper testing. My ollama version is 0.20.6. Also ping me if you need more proof. Some proof with debugging messages (injected by me).
|
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.



Summary
Closes #3191
When a custom/Ollama provider is used with
reasoning_effort: none(orenabled: false), inject"think": falseinto the requestextra_body.Root Cause
Ollama does not recognise the OpenRouter-style
reasoningextra_body field. Thinking-capable models (Qwen3, etc.) therefore generate<think>blocks regardless of thereasoning_effortsetting. This produces empty-response errors that corrupt session state.The existing
_supports_reasoning_extra_body()guard correctly blocks thereasoningfield from being sent to custom endpoints — but there was no mechanism to affirmatively disable thinking on Ollama's side.Fix
One block added in
_build_api_kwargs(), after theextra_bodyassembly:This covers both config shapes users might use:
reasoning_effort: none→{"effort": "none"}reasoning: {enabled: false}→{"enabled": false}Non-custom providers and Ollama with reasoning enabled are unaffected.
Tests
4 new tests in
TestBuildApiKwargs:test_ollama_think_false_on_effort_none— effort=none triggers think=falsetest_ollama_think_false_on_enabled_false— enabled=false triggers think=falsetest_ollama_no_think_param_when_reasoning_enabled— enabled provider → no think paramtest_non_custom_provider_unaffected— OpenRouter with effort=none is not affectedScope
Single file change (
run_agent.py), 12 lines added.