mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 13:26:04 -06:00
fix: validate lmstudio discovered context lengths
This commit is contained in:
@@ -209,11 +209,10 @@ export function resolveLoadedContextWindow(
|
||||
let contextWindow: number | null = null;
|
||||
for (const instance of loadedInstances) {
|
||||
// Discovery payload is external JSON, so tolerate malformed entries.
|
||||
const length = instance?.config?.context_length;
|
||||
if (length === undefined || !Number.isFinite(length) || length <= 0) {
|
||||
const normalized = asPositiveSafeInteger(instance?.config?.context_length);
|
||||
if (normalized === undefined) {
|
||||
continue;
|
||||
}
|
||||
const normalized = Math.floor(length);
|
||||
contextWindow = contextWindow === null ? normalized : Math.max(contextWindow, normalized);
|
||||
}
|
||||
return contextWindow;
|
||||
@@ -463,12 +462,7 @@ export function mapLmstudioWireEntry(entry: LmstudioModelWire): LmstudioModelBas
|
||||
return null;
|
||||
}
|
||||
const loadedContextWindow = resolveLoadedContextWindow(entry);
|
||||
const advertisedContextWindow =
|
||||
entry.max_context_length !== undefined &&
|
||||
Number.isFinite(entry.max_context_length) &&
|
||||
entry.max_context_length > 0
|
||||
? Math.floor(entry.max_context_length)
|
||||
: null;
|
||||
const advertisedContextWindow = asPositiveSafeInteger(entry.max_context_length) ?? null;
|
||||
const contextWindow = advertisedContextWindow ?? SELF_HOSTED_DEFAULT_CONTEXT_WINDOW;
|
||||
// Keep native/advertised context window metadata in catalog, but use a practical
|
||||
// default target for model loading unless callers explicitly override it.
|
||||
|
||||
Reference in New Issue
Block a user