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
This commit is contained in:
Dallin Romney 2026-03-25 22:21:11 -07:00 • committed by GitHub
parent 393c92509f
commit f7907fff08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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}`);