fix(agent): scope think=False to Ollama endpoints only (#11237)#12914
Closed
Tranquil-Flow wants to merge 1 commit into
Closed
fix(agent): scope think=False to Ollama endpoints only (#11237)#12914Tranquil-Flow wants to merge 1 commit into
Tranquil-Flow wants to merge 1 commit into
Conversation
…11237) The think parameter is Ollama-native and was being sent to ALL custom providers (Mistral, Fireworks, Together.ai, vLLM, LM Studio) when reasoning was disabled, causing HTTP 422 rejections from providers that validate request bodies. Root cause: _build_api_kwargs() used provider == 'custom' as the guard condition, matching every custom endpoint regardless of whether it understands the think parameter. Fix: - Add _is_ollama() detection method using two signals: 1. _ollama_num_ctx — set via config or /api/show probe (proven Ollama) 2. URL heuristics — 'ollama' or ':11434' in base URL (fallback) - Replace provider == 'custom' guard with _is_ollama() in the think=False section of _build_api_kwargs() Tests: 23 new tests covering: - 7 _is_ollama() unit tests (num_ctx probe, URL patterns, rejections) - 5 cloud custom provider no-think tests (Mistral, Fireworks, Together, vLLM) - 1 LM Studio no-think test (local but not Ollama) - 7 Ollama think=False positive tests (URL, num_ctx, effort, enabled) - 3 unaffected provider tests (OpenRouter, Anthropic) All tests fail without the fix (6 failures from cloud/LM Studio tests) and pass with it. 107 total tests pass (23 new + 84 existing).
Contributor
Author
|
Closing — the The literal
Neither path constructs a request payload that sets |
This was referenced May 26, 2026
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.
What does this PR do?
The
thinkparameter is Ollama-native and was being sent to ALL custom providers when reasoning was disabled, causing HTTP 422 rejections from Mistral, Fireworks, Together.ai, vLLM, and LM Studio — all of which validate request bodies and reject unrecognized parameters.Root cause:
_build_api_kwargs()usedprovider == "custom"as the guard condition, matching every custom endpoint regardless of whether it understands thethinkparameter.Fix:
_is_ollama()detection method using two complementary signals:_ollama_num_ctx— set during init via config or/api/showprobe (proves endpoint is Ollama)"ollama"or":11434"in the base URL (fallback for when probe failed)provider == "custom"guard with_is_ollama()in thethink=Falseinjection pathRelated Issue
Closes #11237
Type of Change
Changes Made
_is_ollama()detection method (num_ctx probe + URL heuristics)provider == "custom"guard with_is_ollama()in thethink=Falseinjection pathHow to Test
reasoning_effort: nonereasoning_effort: none<think/>blocksAutomated: 23 new tests in
tests/run_agent/test_think_param_ollama_scope.py:_is_ollama()unit tests (num_ctx probe, URL patterns, cloud/LM Studio/vLLM rejections)Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs