Skip to content

fix(agent): restrict think=False to Ollama/local endpoints only#11362

Open
yeyitech wants to merge 1 commit into
NousResearch:mainfrom
yeyitech:fix/think-false-ollama-only
Open

fix(agent): restrict think=False to Ollama/local endpoints only#11362
yeyitech wants to merge 1 commit into
NousResearch:mainfrom
yeyitech:fix/think-false-ollama-only

Conversation

@yeyitech

Copy link
Copy Markdown
Contributor

Summary

  • Fixes [Bug]: think=False incorrectly sent to all provider=custom endpoints, not just Ollama #11237
  • The think=False parameter in extra_body is Ollama-specific. The previous guard if self.provider == "custom" matched all custom providers (Mistral, Fireworks, Together.ai, vLLM remote, etc.), causing HTTP 422 errors from cloud APIs that do not recognise the think field.
  • Replace the guard with an explicit Ollama/local endpoint check that mirrors the pattern already used elsewhere in run_agent.py (_ollama_num_ctx, _is_glm_zai_direct).

Changes

In _build_api_kwargs(), replaced:

if self.provider == "custom" and self.reasoning_config and ...:

with:

_is_ollama_endpoint = (
    "ollama" in self._base_url_lower
    or ":11434" in self._base_url_lower
    or is_local_endpoint(self.base_url or "")
)
if _is_ollama_endpoint and self.reasoning_config and ...:

is_local_endpoint is already imported at the top of run_agent.py and self._base_url_lower is a cached lowercased copy of the base URL set in the base_url property setter.

Test plan

  • Ollama endpoint (http://localhost:11434/v1): think=False still sent when reasoning is disabled
  • Ollama via URL keyword (http://my-ollama-server/v1): think=False still sent
  • Cloud custom provider (e.g. Fireworks, Together.ai): think=False no longer sent; no HTTP 422
  • Mistral, vLLM remote: think=False no longer sent; no HTTP 422

🤖 Generated with Claude Code

The `think=False` extra_body parameter is Ollama-specific. The previous
guard `provider == "custom"` matched all custom providers (Mistral,
Fireworks, Together.ai, vLLM remote, etc.), causing HTTP 422 errors from
cloud APIs that don't recognize the `think` field.

Replace the guard with an Ollama/local endpoint check that mirrors the
existing pattern used elsewhere in the codebase:
- URL contains "ollama"
- URL contains ":11434" (default Ollama port)
- is_local_endpoint() returns True

Fixes NousResearch#11237

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@tong-hao

Copy link
Copy Markdown

I want this fix.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder provider/ollama Ollama / local models labels Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists provider/ollama Ollama / local models type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: think=False incorrectly sent to all provider=custom endpoints, not just Ollama

3 participants