Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

bug fix: update "Max Context Window Length" properly

Forhad Hosain73684f7e7cb0
diff --git a/packages/app/src/builder-ui/components/GenAILLM.class.ts b/packages/app/src/builder-ui/components/GenAILLM.class.ts
index 5308b11e..8b6daddb 100644
--- a/packages/app/src/builder-ui/components/GenAILLM.class.ts
+++ b/packages/app/src/builder-ui/components/GenAILLM.class.ts
@@ -241,6 +241,11 @@ export class GenAILLM extends Component {
const currentModel = modelSelect?.value || this.data.model;
const provider = LLMRegistry.getModelProvider(currentModel);
+ // Update context size to ensure maxContextWindowLength has proper max value
+ if (modelSelect) {
+ LLMFormController.updateContextSize(modelSelect);
+ }
+
// Automatically switch search options based on provider
this.autoSwitchSearchOptions(provider, form);
diff --git a/packages/app/src/builder-ui/helpers/LLMFormController.helper.ts b/packages/app/src/builder-ui/helpers/LLMFormController.helper.ts
index 9fc1e209..f03ce14f 100644
--- a/packages/app/src/builder-ui/helpers/LLMFormController.helper.ts
+++ b/packages/app/src/builder-ui/helpers/LLMFormController.helper.ts
@@ -288,6 +288,28 @@ export class LLMFormController {
}
// #endregion
+ // #region update the max context window length field
+ const maxContextWindowLengthElm = formElm.querySelector(
+ '#maxContextWindowLength',
+ ) as HTMLInputElement;
+
+ if (maxContextWindowLengthElm && allowedMaxContextTokens) {
+ const currentValue = maxContextWindowLengthElm.valueAsNumber || 0;
+
+ // Update the max attribute for the range input
+ this.replaceValidationRules({
+ fieldElm: maxContextWindowLengthElm,
+ attribute: 'max',
+ targetValue: allowedMaxContextTokens,
+ inputType: 'range',
+ });
+
+ // Ensure current value doesn't exceed the new max
+ const validMaxContextWindowLength = Math.min(allowedMaxContextTokens, currentValue);
+ this.setRangeInputValue(formElm, 'maxContextWindowLength', `${validMaxContextWindowLength}`);
+ }
+ // #endregion
+
// #region update the web search context size information
const allowedWebSearchContextTokens = LLMRegistry.getWebSearchContextTokens(model);