From e3cb957a10a632ae9973d2b5bfeaaeea7eb0b11c Mon Sep 17 00:00:00 2001 From: teknium1 Date: Wed, 25 Feb 2026 16:49:41 -0800 Subject: [PATCH] refactor: streamline reasoning configuration checks in AIAgent - Simplified the logic for determining support for reasoning based on the base URL by introducing clearer variable names. - Added product attribution for the Nous Portal to the extra body of requests when applicable, enhancing tagging for better tracking. --- run_agent.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/run_agent.py b/run_agent.py index b96879c8b..beb9d07a1 100644 --- a/run_agent.py +++ b/run_agent.py @@ -1186,11 +1186,10 @@ class AIAgent: if provider_preferences: extra_body["provider"] = provider_preferences - _supports_reasoning = ( - "openrouter" in self.base_url.lower() - or "nousresearch" in self.base_url.lower() - ) - if _supports_reasoning: + _is_openrouter = "openrouter" in self.base_url.lower() + _is_nous = "nousresearch" in self.base_url.lower() + + if _is_openrouter or _is_nous: if self.reasoning_config is not None: extra_body["reasoning"] = self.reasoning_config else: @@ -1199,6 +1198,10 @@ class AIAgent: "effort": "xhigh" } + # Nous Portal product attribution + if _is_nous: + extra_body["tags"] = ["product=hermes-agent"] + if extra_body: api_kwargs["extra_body"] = extra_body @@ -1612,11 +1615,9 @@ class AIAgent: api_messages.insert(sys_offset + idx, pfm.copy()) summary_extra_body = {} - _supports_reasoning = ( - "openrouter" in self.base_url.lower() - or "nousresearch" in self.base_url.lower() - ) - if _supports_reasoning: + _is_openrouter = "openrouter" in self.base_url.lower() + _is_nous = "nousresearch" in self.base_url.lower() + if _is_openrouter or _is_nous: if self.reasoning_config is not None: summary_extra_body["reasoning"] = self.reasoning_config else: @@ -1624,6 +1625,8 @@ class AIAgent: "enabled": True, "effort": "xhigh" } + if _is_nous: + summary_extra_body["tags"] = ["product=hermes-agent"] summary_kwargs = { "model": self.model,