From f7907fff08719bd9847f1eb65c6967c302768f4a Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 25 Mar 2026 22:21:11 -0700 Subject: [PATCH] fix: vLLM provider should respect user-configured contextLength and model (#11868) * fix: respect user-configured maxTokens and contextLength for autocomplete Two fixes for autocomplete's maxTokens not being respected (#6003): 1. vLLM provider: _setupCompletionOptions() unconditionally overwrote the user's contextLength and model with server-reported values. Now user-explicit settings take priority over auto-detected values. 2. Autocomplete pipeline: renderPromptWithTokenLimit() returned completionOptions without maxTokens, relying on an implicit merge deeper in the call stack. Now maxTokens is explicitly included in the returned completionOptions so the value flows through to the API request reliably. * remove verbose comments from Vllm provider * style: fix prettier formatting * fix: only set maxTokens when llm provides a value * remove defensive-only maxTokens pass-through from autocomplete pipeline --- core/llm/llms/Vllm.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/core/llm/llms/Vllm.ts b/core/llm/llms/Vllm.ts index 66f9b84c4..8b8080bfa 100644 --- a/core/llm/llms/Vllm.ts +++ b/core/llm/llms/Vllm.ts @@ -22,9 +22,16 @@ interface VllmRerankResponse { class Vllm extends OpenAI { static providerName = "vllm"; + private _userExplicitContextLength: boolean; + private _userExplicitModel: boolean; + constructor(options: LLMOptions) { super(options); + this._userExplicitContextLength = options.contextLength !== undefined; + this._userExplicitModel = + options.model !== undefined && options.model !== ""; + if (options.isFromAutoDetect) { this._setupCompletionOptions(); } @@ -71,8 +78,12 @@ class Vllm extends OpenAI { } const json = await response.json(); const data = json.data[0]; - this.model = data.id; - this._contextLength = Number.parseInt(data.max_model_len); + if (!this._userExplicitModel) { + this.model = data.id; + } + if (!this._userExplicitContextLength) { + this._contextLength = Number.parseInt(data.max_model_len); + } }) .catch((e) => { console.log(`Failed to list models for vLLM: ${e.message}`);