Skip to content

fix(agent): stop sending think=false to remote custom providers - #11296

Open
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:fix/custom-provider-think-flag
Open

fix(agent): stop sending think=false to remote custom providers#11296
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:fix/custom-provider-think-flag

Conversation

@LeonSGP43

Copy link
Copy Markdown
Contributor

Summary\n- only send Ollama's native \ flag to Ollama-style custom endpoints\n- keep existing local Ollama behavior intact while avoiding 4xx validation errors on remote OpenAI-compatible providers\n- add a regression test for remote custom providers\n\nWhy\n- \ currently injects \ for every endpoint when reasoning is disabled\n- remote custom providers like Mistral reject that Ollama-specific field with HTTP 422\n\nFixes #11237\n\nTesting\n- python3 -m pytest -o addopts='' tests/run_agent/test_run_agent.py -k "think_false or remote_custom_provider_does_not_receive_ollama_think_flag or non_custom_provider_unaffected"

@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
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competing fix for #11237 — at least 4 other PRs address the same issue: #11362, #11520, #12914, #12488. All gate think=false behind Ollama detection.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for isolating the incompatible think field.

Problems

  • Current main no longer has the inline request builder this PR edits: AIAgent._build_api_kwargs() is a forwarder at run_agent.py:5328-5331. The active provider-specific request construction calls CustomProfile.build_api_kwargs_extras() through agent/transports/chat_completions.py:562-594.
  • The reported behavior is still live there: plugins/model-providers/custom/__init__.py:52-56 emits extra_body["think"] = False for every disabled-reasoning custom endpoint. Existing assertions at tests/plugins/model_providers/test_custom_profile.py:51-64 encode that broad behavior.

Suggested changes

  • Port the endpoint predicate to CustomProfile.build_api_kwargs_extras() and gate the assignment at plugins/model-providers/custom/__init__.py:55-56 using its supplied base_url context.
  • Add remote-custom and supported-Ollama cases at the profile/transport layer, replacing the stale run-agent test target.

Automated hermes-sweeper review.

Comment thread run_agent.py
# Ollama-style custom providers: pass think=false when reasoning is
# disabled. Remote OpenAI-compatible custom endpoints reject Ollama's
# native `think` field with 4xx validation errors.
if self._should_send_ollama_think_flag() and self.reasoning_config and isinstance(self.reasoning_config, dict):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current main no longer executes this inline custom-provider branch: AIAgent._build_api_kwargs() now forwards to agent.chat_completion_helpers, whose transport invokes CustomProfile.build_api_kwargs_extras() (agent/transports/chat_completions.py:562-594). Port this guard to plugins/model-providers/custom/__init__.py; otherwise the active request path will still emit think: false for remote custom endpoints.

@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.

3 participants