Merge pull request #617 from themavik/fix/523-clamp-max-tokens

fix(providers): clamp max_tokens to >= 1 before calling LiteLLM
This commit is contained in:
Xubin Ren 2026-02-14 18:02:20 +08:00 committed by GitHub
commit 3411035447
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -122,6 +122,10 @@ class LiteLLMProvider(LLMProvider):
"""
model = self._resolve_model(model or self.default_model)
# Clamp max_tokens to at least 1 — negative or zero values cause
# LiteLLM to reject the request with "max_tokens must be at least 1".
max_tokens = max(1, max_tokens)
kwargs: dict[str, Any] = {
"model": model,
"messages": messages,