mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
fix(config): clamp maxTokens to contextWindow to prevent invalid configurations
Closes #5308 When users configure maxTokens larger than contextWindow (e.g., maxTokens: 40960 with contextWindow: 32768), the model may fail silently. This fix clamps maxTokens to be at most contextWindow, preventing such invalid configurations.
This commit is contained in:
@@ -215,7 +215,9 @@ export function applyModelDefaults(cfg: OpenClawConfig): OpenClawConfig {
|
||||
}
|
||||
|
||||
const defaultMaxTokens = Math.min(DEFAULT_MODEL_MAX_TOKENS, contextWindow);
|
||||
const maxTokens = isPositiveNumber(raw.maxTokens) ? raw.maxTokens : defaultMaxTokens;
|
||||
// Clamp maxTokens to contextWindow to prevent invalid configurations
|
||||
const rawMaxTokens = isPositiveNumber(raw.maxTokens) ? raw.maxTokens : defaultMaxTokens;
|
||||
const maxTokens = Math.min(rawMaxTokens, contextWindow);
|
||||
if (raw.maxTokens !== maxTokens) {
|
||||
modelMutated = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user