From a7e5f195284a54b469a1f2bf9ab6b60401ae3212 Mon Sep 17 00:00:00 2001 From: teknium1 Date: Wed, 11 Mar 2026 22:41:33 -0700 Subject: [PATCH] fix: don't send OpenRouter-specific provider preferences to Nous Portal Two bugs in _build_api_kwargs that broke Nous Portal: 1. Provider preferences (only, ignore, order, sort) are OpenRouter- specific routing features. They were being sent in extra_body to ALL providers, including Nous Portal. When the config had providers_only=['google-vertex'], Nous Portal returned 404 'Inference host not found' because it doesn't have a google-vertex backend. Fix: Only include provider preferences when _is_openrouter is True. 2. Reasoning config with enabled=false was being sent to Nous Portal, which requires reasoning and returns 400 'Reasoning is mandatory for this endpoint and cannot be disabled.' Fix: Omit the reasoning parameter for Nous when enabled=false. Root cause found via HERMES_DUMP_REQUESTS=1 which showed the exact request payload being sent to Nous Portal's inference API. --- run_agent.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/run_agent.py b/run_agent.py index 107b803c6..bb66351b4 100644 --- a/run_agent.py +++ b/run_agent.py @@ -2392,16 +2392,24 @@ class AIAgent: extra_body = {} - if provider_preferences: - extra_body["provider"] = provider_preferences - _is_openrouter = "openrouter" in self.base_url.lower() + + # Provider preferences (only, ignore, order, sort) are OpenRouter- + # specific — don't send them to other providers (Nous, Codex, etc.) + if provider_preferences and _is_openrouter: + extra_body["provider"] = provider_preferences _is_nous = "nousresearch" in self.base_url.lower() _is_mistral = "api.mistral.ai" in self.base_url.lower() if (_is_openrouter or _is_nous) and not _is_mistral: if self.reasoning_config is not None: - extra_body["reasoning"] = self.reasoning_config + rc = dict(self.reasoning_config) + # Nous Portal requires reasoning enabled — don't send + # enabled=false to it (would cause 400). + if _is_nous and rc.get("enabled") is False: + pass # omit reasoning entirely for Nous when disabled + else: + extra_body["reasoning"] = rc else: extra_body["reasoning"] = { "enabled": True,