From 68d54728109f3c4c9a642a31e8520d78a7d6f7d6 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sun, 29 Mar 2026 16:12:47 -0700 Subject: [PATCH] fix: omit tools param entirely when empty instead of sending None (#3820) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some providers (Fireworks AI) reject tools=null, and others (Anthropic) reject tools=[]. The safest approach is to not include the key at all when there are no tools — the OpenAI SDK treats a missing parameter as NOT_GIVEN and omits it from the request entirely. Inspired by PR #3736 (@kelsia14). --- run_agent.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/run_agent.py b/run_agent.py index 8674149ea..66f1ff4c8 100644 --- a/run_agent.py +++ b/run_agent.py @@ -4721,9 +4721,10 @@ class AIAgent: api_kwargs = { "model": self.model, "messages": sanitized_messages, - "tools": self.tools if self.tools else None, "timeout": float(os.getenv("HERMES_API_TIMEOUT", 1800.0)), } + if self.tools: + api_kwargs["tools"] = self.tools if self.max_tokens is not None: api_kwargs.update(self._max_tokens_param(self.max_tokens))