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 runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/ollama Ollama / local models labels Apr 25, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for tracing the incorrect custom-provider guard. The underlying issue is still present on current main, but this patch needs to be salvaged onto the current provider-profile path.

Problems

  • run_agent.py:_build_api_kwargs is now only a forwarder (run_agent.py:5328-5331); provider=custom kwargs are assembled through the registered CustomProfile (agent/chat_completion_helpers.py:849-888, plugins/model-providers/custom/__init__.py:22-60).
  • The proposed is_local_endpoint() test is not Ollama-specific: it treats Docker service names and private/link-local/Tailscale addresses as local (agent/model_metadata.py:618-647). The custom profile also covers vLLM and llama.cpp (plugins/model-providers/custom/__init__.py:3-10), so local non-Ollama endpoints could still receive think=False.
  • Please add regression coverage for both cloud and local non-Ollama custom endpoints; current tests still assert generic custom providers emit the field (tests/plugins/model_providers/test_custom_profile.py:51-65).

Suggested changes

  • Move the endpoint-specific decision into CustomProfile.build_api_kwargs_extras and gate it on positive Ollama identification.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists provider/ollama Ollama / local models sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades 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

4 participants