fix: omit tools param entirely when empty instead of sending None (#3820)
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).
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user