fix(ollama): emit top-level reasoning_effort=none on /v1/chat/complet…#29820
Open
Epoxidex wants to merge 1 commit into
Open
fix(ollama): emit top-level reasoning_effort=none on /v1/chat/complet…#29820Epoxidex wants to merge 1 commit into
Epoxidex wants to merge 1 commit into
Conversation
…ions + propagate reasoning_config to bg-review fork Fixes NousResearch#6152 Fixes NousResearch#25758
Collaborator
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): emit top-level
reasoning_effort=noneon/v1/chat/completions+ propagatereasoning_configto bg-review forkFixes #6152
Fixes #25758
What does this PR do?
When
reasoning_effort: noneis set (via/reasoning noneorconfig.yaml), Hermes should suppress thinking on Ollama. It doesn't — the model always runs its full reasoning chain regardless of the user's config.Two root causes:
Defect 1 (main agent): The
customprovider plugin emitsextra_body["think"] = Falseto disable thinking. This works on Ollama's native/api/chatendpoint but is silently ignored on/v1/chat/completions— the OpenAI-compat path Hermes actually uses. The field that/v1/chat/completionshonours is a top-levelreasoning_effort = "none", which was never emitted.Defect 2 (bg-review fork):
_spawn_background_review()creates a newAIAgentwithout passingreasoning_config. Even when Defect 1 is fixed, the review fork always defaults toreasoning_effort=mediumand can produce 200k+ token reasoning traces taking up to 28 minutes per turn.Related Issue
Fixes #6152
Fixes #25758
Type of Change
Changes Made
plugins/model-providers/custom/__init__.py— emittop_level["reasoning_effort"] = "none"alongside the existingextra_body["think"] = Falsewhen reasoning is disabled. The top-level field is what Ollama's/v1/chat/completionsactually processes (confirmed inopenai/openai.go);think=Falseis kept for/api/chatbackward-compat and proxies.agent/background_review.py— passreasoning_config=getattr(agent, "reasoning_config", None)when constructing the forkedAIAgent, so the review fork inherits the parent's reasoning settings.tests/plugins/model_providers/test_custom_profile.py— new test file covering theCustomProfile.build_api_kwargs_extras()wire shape, following the pattern intest_deepseek_profile.py.How to Test
qwen3.6:35b)hermesand set/reasoning noneout=token count matching only the answer (no reasoning chain)/reasoning medium— response takes 30-60s+ with significantly higherout=token countpytest tests/plugins/model_providers/test_custom_profile.py -v— all 15 tests passChecklist
Code
pytest tests/ -qand all tests passDocumentation & Housekeeping
cli-config.yaml.example— N/ACONTRIBUTING.mdorAGENTS.md— N/AScreenshots / Logs
Without fix (
reasoning_effort: nonesilently ignored — model thinks):With fix (thinking correctly disabled):
Direct Ollama API verification (
test_ollama_thinking.py):