diff --git a/src/components/providers/forms/OpenCodeFormFields.tsx b/src/components/providers/forms/OpenCodeFormFields.tsx
index 717b166d09..24114da488 100644
--- a/src/components/providers/forms/OpenCodeFormFields.tsx
+++ b/src/components/providers/forms/OpenCodeFormFields.tsx
@@ -466,6 +466,53 @@ export function OpenCodeFormFields({
});
};
+ // Model limit handlers (limit.context and limit.output)
+ const handleModelLimitContextChange = (modelKey: string, value: string) => {
+ const model = models[modelKey];
+ const numValue = value.trim() ? Number(value) : undefined;
+ if (numValue !== undefined && !Number.isFinite(numValue)) return;
+ const currentLimit = model.limit || {};
+ // If both context and output are undefined, remove limit entirely
+ if (numValue === undefined && currentLimit.output === undefined) {
+ const { limit: _, ...rest } = model;
+ onModelsChange({
+ ...models,
+ [modelKey]: rest as OpenCodeModel,
+ });
+ } else {
+ onModelsChange({
+ ...models,
+ [modelKey]: {
+ ...model,
+ limit: { ...currentLimit, context: numValue },
+ },
+ });
+ }
+ };
+
+ const handleModelLimitOutputChange = (modelKey: string, value: string) => {
+ const model = models[modelKey];
+ const numValue = value.trim() ? Number(value) : undefined;
+ if (numValue !== undefined && !Number.isFinite(numValue)) return;
+ const currentLimit = model.limit || {};
+ // If both context and output are undefined, remove limit entirely
+ if (currentLimit.context === undefined && numValue === undefined) {
+ const { limit: _, ...rest } = model;
+ onModelsChange({
+ ...models,
+ [modelKey]: rest as OpenCodeModel,
+ });
+ } else {
+ onModelsChange({
+ ...models,
+ [modelKey]: {
+ ...model,
+ limit: { ...currentLimit, output: numValue },
+ },
+ });
+ }
+ };
+
// Extra Options handlers
const handleAddExtraOption = () => {
const newKey = `option-${Date.now()}`;
@@ -827,6 +874,59 @@ export function OpenCodeFormFields({
)}
+ {/* Token Limits (model.limit) */}
+
+
+ {t("opencode.tokenLimits", {
+ defaultValue: "Token Limits",
+ })}
+
+
+
+ {t("opencode.limitContext", {
+ defaultValue: "Context Window",
+ })}
+
+
+ handleModelLimitContextChange(key, e.target.value)
+ }
+ placeholder={t("opencode.limitContextPlaceholder", {
+ defaultValue: "e.g. 128000",
+ })}
+ className="flex-1"
+ min={1}
+ />
+
+
+
+ {t("opencode.limitOutput", {
+ defaultValue: "Max Output",
+ })}
+
+
+ handleModelLimitOutputChange(key, e.target.value)
+ }
+ placeholder={t("opencode.limitOutputPlaceholder", {
+ defaultValue: "e.g. 4096",
+ })}
+ className="flex-1"
+ min={1}
+ />
+
+
+ {t("opencode.tokenLimitsHint", {
+ defaultValue:
+ "Set context window and max output token limits for this model",
+ })}
+
+
+
{/* SDK Options (model.options) */}
diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json
index 6a4fc62157..44d638bade 100644
--- a/src/i18n/locales/en.json
+++ b/src/i18n/locales/en.json
@@ -1028,7 +1028,13 @@
"modelExtraFieldKeyPlaceholder": "variants",
"sdkOptions": "SDK Options",
"modelOptionKeyPlaceholder": "provider",
- "modelOptionValuePlaceholder": "{\"order\": [\"baseten\"]}"
+ "modelOptionValuePlaceholder": "{\"order\": [\"baseten\"]}",
+ "tokenLimits": "Token Limits",
+ "limitContext": "Context Window",
+ "limitOutput": "Max Output",
+ "limitContextPlaceholder": "e.g. 128000",
+ "limitOutputPlaceholder": "e.g. 4096",
+ "tokenLimitsHint": "Set context window and max output token limits for this model"
},
"providerPreset": {
"label": "Provider Preset",
diff --git a/src/i18n/locales/ja.json b/src/i18n/locales/ja.json
index 65d0c4aaf1..e230020268 100644
--- a/src/i18n/locales/ja.json
+++ b/src/i18n/locales/ja.json
@@ -1028,7 +1028,13 @@
"modelExtraFieldKeyPlaceholder": "variants",
"sdkOptions": "SDK オプション",
"modelOptionKeyPlaceholder": "provider",
- "modelOptionValuePlaceholder": "{\"order\": [\"baseten\"]}"
+ "modelOptionValuePlaceholder": "{\"order\": [\"baseten\"]}",
+ "tokenLimits": "トークン制限",
+ "limitContext": "コンテキストウィンドウ",
+ "limitOutput": "最大出力",
+ "limitContextPlaceholder": "例: 128000",
+ "limitOutputPlaceholder": "例: 4096",
+ "tokenLimitsHint": "このモデルのコンテキストウィンドウと最大出力トークン制限を設定"
},
"providerPreset": {
"label": "プロバイダータイプ",
diff --git a/src/i18n/locales/zh.json b/src/i18n/locales/zh.json
index 0bd66025e7..30cb0efedc 100644
--- a/src/i18n/locales/zh.json
+++ b/src/i18n/locales/zh.json
@@ -1029,7 +1029,13 @@
"modelExtraFieldKeyPlaceholder": "variants",
"sdkOptions": "SDK 选项",
"modelOptionKeyPlaceholder": "provider",
- "modelOptionValuePlaceholder": "{\"order\": [\"baseten\"]}"
+ "modelOptionValuePlaceholder": "{\"order\": [\"baseten\"]}",
+ "tokenLimits": "Token 限制",
+ "limitContext": "上下文窗口",
+ "limitOutput": "最大输出",
+ "limitContextPlaceholder": "如 128000",
+ "limitOutputPlaceholder": "如 4096",
+ "tokenLimitsHint": "设置此模型的上下文窗口和最大输出 token 限制"
},
"providerPreset": {
"label": "预设供应商",