Merge pull request #9997 from Kilo-Org/fix/drop-max-tokens-gpt5-openai-compatible

fix(cli): drop max_tokens for gpt-5 models on @ai-sdk/openai-compatible
This commit is contained in:
Christiaan Arnoldus
2026-05-07 14:50:32 +02:00
committed by GitHub
2 changed files with 13 additions and 1 deletions
@@ -0,0 +1,5 @@
---
"@kilocode/cli": patch
---
Fix gpt-5 models failing with `Unsupported parameter: max_tokens` when accessed through custom OpenAI-compatible providers such as LiteLLM.
+8 -1
View File
@@ -186,7 +186,14 @@ const live: Layer.Layer<
: undefined,
topP: input.agent.topP ?? ProviderTransform.topP(input.model),
topK: ProviderTransform.topK(input.model),
maxOutputTokens: ProviderTransform.maxOutputTokens(input.model),
// kilocode_change start - gpt-5 via @ai-sdk/openai-compatible proxies (e.g. LiteLLM)
// rejects `max_tokens`; OpenAI requires `max_completion_tokens` and the compatible
// SDK cannot rename the field, so drop the cap and let the upstream default apply.
maxOutputTokens:
input.model.api.npm === "@ai-sdk/openai-compatible" && input.model.api.id.toLowerCase().includes("gpt-5")
? undefined
: ProviderTransform.maxOutputTokens(input.model),
// kilocode_change end
options,
},
)