Skip to content

🙌 OpenHands: AI-Driven Development

feat: support a configurable timeout per automation (#1786)

Hiep Le4bd1fa5f9853
diff --git a/__tests__/components/automations/detail/edit-automation-modal.test.tsx b/__tests__/components/automations/detail/edit-automation-modal.test.tsx
index 876e2211db..e1a51ea50a 100644
--- a/__tests__/components/automations/detail/edit-automation-modal.test.tsx
+++ b/__tests__/components/automations/detail/edit-automation-modal.test.tsx
@@ -70,6 +70,14 @@ const modeledAutomation: Automation = {
model: "fast",
};
+// An automation carrying an explicit run timeout (in seconds). The base
+// fixtures intentionally leave `timeout` unset.
+const timeoutAutomation: Automation = {
+ ...dailyAutomation,
+ id: "auto-4",
+ timeout: 600,
+};
+
const profilesResponse = {
profiles: [
{
@@ -345,4 +353,97 @@ describe("EditAutomationModal", () => {
).not.toBeInTheDocument();
});
});
+
+ it("pre-fills the timeout and sends the new value when it changes", async () => {
+ // Arrange — automation currently times out after 600s.
+ vi.mocked(AutomationService.updateAutomation).mockResolvedValue({
+ ...timeoutAutomation,
+ timeout: 1800,
+ });
+ const user = userEvent.setup();
+ renderModal(timeoutAutomation);
+
+ // Sanity-check pre-fill before editing.
+ const timeoutInput = screen.getByTestId(
+ "edit-automation-timeout",
+ ) as HTMLInputElement;
+ expect(timeoutInput.value).toBe("600");
+
+ // Act — raise the timeout to the 1800s maximum and save.
+ await user.clear(timeoutInput);
+ await user.type(timeoutInput, "1800");
+ await user.click(screen.getByTestId("edit-automation-save"));
+
+ // Assert — the PATCH carries just the new timeout.
+ await waitFor(() => {
+ expect(AutomationService.updateAutomation).toHaveBeenCalledTimes(1);
+ });
+ expect(AutomationService.updateAutomation).toHaveBeenCalledWith("auto-4", {
+ timeout: 1800,
+ });
+ });
+
+ it("sends timeout: null when the timeout field is cleared", async () => {
+ // Arrange — automation has an explicit 600s timeout.
+ vi.mocked(AutomationService.updateAutomation).mockResolvedValue({
+ ...timeoutAutomation,
+ timeout: null,
+ });
+ const user = userEvent.setup();
+ renderModal(timeoutAutomation);
+
+ // Act — clear the field to fall back to the server default, then save.
+ await user.clear(screen.getByTestId("edit-automation-timeout"));
+ await user.click(screen.getByTestId("edit-automation-save"));
+
+ // Assert — the PATCH resets the stored timeout to null.
+ await waitFor(() => {
+ expect(AutomationService.updateAutomation).toHaveBeenCalledTimes(1);
+ });
+ expect(AutomationService.updateAutomation).toHaveBeenCalledWith("auto-4", {
+ timeout: null,
+ });
+ });
+
+ it("blocks submit and shows a validation error for an out-of-range timeout", async () => {
+ // Arrange
+ const user = userEvent.setup();
+ renderModal(timeoutAutomation);
+
+ // Act — enter a timeout beyond the 1800s cap and try to save.
+ const timeoutInput = screen.getByTestId("edit-automation-timeout");
+ await user.clear(timeoutInput);
+ await user.type(timeoutInput, "2000");
+ await user.click(screen.getByTestId("edit-automation-save"));
+
+ // Assert — no PATCH fired, inline error appears.
+ expect(AutomationService.updateAutomation).not.toHaveBeenCalled();
+ expect(
+ screen.getByTestId("edit-automation-timeout-error"),
+ ).toBeInTheDocument();
+ });
+
+ it("omits the timeout from the payload when it is left unchanged", async () => {
+ // Arrange
+ vi.mocked(AutomationService.updateAutomation).mockResolvedValue(
+ timeoutAutomation,
+ );
+ const user = userEvent.setup();
+ renderModal(timeoutAutomation);
+
+ // Act — rename the automation but leave the timeout at 600.
+ const nameInput = screen.getByTestId("edit-automation-name");
+ await user.clear(nameInput);
+ await user.type(nameInput, "Renamed digest");
+ await user.click(screen.getByTestId("edit-automation-save"));
+
+ // Assert — the PATCH renames but does not resend the unchanged timeout.
+ await waitFor(() => {
+ expect(AutomationService.updateAutomation).toHaveBeenCalledTimes(1);
+ });
+ const [, body] = vi.mocked(AutomationService.updateAutomation).mock
+ .calls[0];
+ expect(body).toMatchObject({ name: "Renamed digest" });
+ expect(body).not.toHaveProperty("timeout");
+ });
});
diff --git a/__tests__/utils/automation-timeout.test.ts b/__tests__/utils/automation-timeout.test.ts
new file mode 100644
index 0000000000..563e458269
--- /dev/null
+++ b/__tests__/utils/automation-timeout.test.ts
@@ -0,0 +1,51 @@
+import { describe, it, expect } from "vitest";
+import { I18nKey } from "#/i18n/declaration";
+import { validateAutomationTimeout } from "#/utils/automation-timeout";
+
+describe("validateAutomationTimeout", () => {
+ it("treats a blank value as 'use the server default'", () => {
+ // Arrange / Act
+ const result = validateAutomationTimeout(" ");
+
+ // Assert
+ expect(result).toEqual({ value: null });
+ });
+
+ it("accepts a positive integer up to the maximum", () => {
+ // Arrange / Act
+ const result = validateAutomationTimeout("1800");
+
+ // Assert
+ expect(result).toEqual({ value: 1800 });
+ });
+
+ it("rejects a non-integer value", () => {
+ // Arrange / Act
+ const result = validateAutomationTimeout("12.5");
+
+ // Assert
+ expect(result).toEqual({
+ errorKey: I18nKey.AUTOMATIONS$ERROR_TIMEOUT_INVALID_NUMBER,
+ });
+ });
+
+ it("rejects a non-positive value", () => {
+ // Arrange / Act
+ const result = validateAutomationTimeout("0");
+
+ // Assert
+ expect(result).toEqual({
+ errorKey: I18nKey.AUTOMATIONS$ERROR_TIMEOUT_POSITIVE,
+ });
+ });
+
+ it("rejects a value above the maximum", () => {
+ // Arrange / Act
+ const result = validateAutomationTimeout("1801");
+
+ // Assert
+ expect(result).toEqual({
+ errorKey: I18nKey.AUTOMATIONS$ERROR_TIMEOUT_MAX_EXCEEDED,
+ });
+ });
+});
diff --git a/src/api/automation-service/automation-service.api.test.ts b/src/api/automation-service/automation-service.api.test.ts
index 21b52e3221..f46a848d02 100644
--- a/src/api/automation-service/automation-service.api.test.ts
+++ b/src/api/automation-service/automation-service.api.test.ts
@@ -216,4 +216,14 @@ describe("AutomationService.createAutomation", () => {
},
);
});
+
+ it("includes the timeout in the create request when the spec sets one", async () => {
+ await AutomationService.createAutomation({ ...spec, timeout: 1200 });
+
+ expect(localAxios.post).toHaveBeenCalledWith(
+ "/api/automation/v1/preset/plugin",
+ expect.objectContaining({ timeout: 1200 }),
+ expect.any(Object),
+ );
+ });
});
diff --git a/src/api/automation-service/automation-service.api.ts b/src/api/automation-service/automation-service.api.ts
index 8cf7e6d644..52d1587dab 100644
--- a/src/api/automation-service/automation-service.api.ts
+++ b/src/api/automation-service/automation-service.api.ts
@@ -121,6 +121,7 @@ function buildCreateAutomationRequest(spec: AutomationSpec) {
...(spec.plugins?.length && {
plugins: spec.plugins.map((source) => ({ source })),
}),
+ ...(spec.timeout != null && { timeout: spec.timeout }),
},
};
}
diff --git a/src/components/features/automations/detail/edit-automation-modal.tsx b/src/components/features/automations/detail/edit-automation-modal.tsx
index 8b420022e2..7700f08e37 100644
--- a/src/components/features/automations/detail/edit-automation-modal.tsx
+++ b/src/components/features/automations/detail/edit-automation-modal.tsx
@@ -21,6 +21,11 @@ import {
formatEventOn,
type SchedulePresetKind,
} from "#/utils/automation-schedule";
+import {
+ validateAutomationTimeout,
+ AUTOMATION_TIMEOUT_DEFAULT_SECONDS,
+ AUTOMATION_TIMEOUT_MAX_SECONDS,
+} from "#/utils/automation-timeout";
import { cn } from "#/utils/utils";
import {
formControlMultilineFieldClassName,
@@ -61,9 +66,11 @@ interface FormState {
timeOfDay: string;
isCustomSchedule: boolean;
rawSchedule: string;
+ timeout: string;
}
function buildInitialState(automation: Automation): FormState {
+ const timeout = automation.timeout != null ? String(automation.timeout) : "";
if (automation.trigger.type === "event") {
return {
name: automation.name,
@@ -74,6 +81,7 @@ function buildInitialState(automation: Automation): FormState {
timeOfDay: "",
isCustomSchedule: true,
rawSchedule: "",
+ timeout,
};
}
const parsed = parseCronSchedule(automation.trigger.schedule);
@@ -90,6 +98,7 @@ function buildInitialState(automation: Automation): FormState {
: "",
isCustomSchedule: true,
rawSchedule: parsed.raw,
+ timeout,
};
}
return {
@@ -101,6 +110,7 @@ function buildInitialState(automation: Automation): FormState {
timeOfDay: formatTimeOfDay(parsed.hour, parsed.minute),
isCustomSchedule: false,
rawSchedule: automation.trigger.schedule ?? "",
+ timeout,
};
}
@@ -121,11 +131,13 @@ export function EditAutomationModal({
const initial = useMemo(() => buildInitialState(automation), [automation]);
const [form, setForm] = useState<FormState>(initial);
const [nameError, setNameError] = useState<string | null>(null);
+ const [timeoutError, setTimeoutError] = useState<string | null>(null);
useEffect(() => {
if (isOpen) {
setForm(initial);
setNameError(null);
+ setTimeoutError(null);
}
}, [isOpen, initial]);
@@ -174,6 +186,13 @@ export function EditAutomationModal({
}
setNameError(null);
+ const timeoutResult = validateAutomationTimeout(form.timeout);
+ if ("errorKey" in timeoutResult) {
+ setTimeoutError(t(timeoutResult.errorKey));
+ return;
+ }
+ setTimeoutError(null);
+
const body: Partial<Automation> = {};
if (trimmedName !== automation.name) {
@@ -192,6 +211,10 @@ export function EditAutomationModal({
body.model = selectedModel === "" ? null : selectedModel;
}
+ if ((timeoutResult.value ?? null) !== (automation.timeout ?? null)) {
+ body.timeout = timeoutResult.value;
+ }
+
if (!form.isCustomSchedule && form.frequency !== "custom") {
const parsedTime = parseTimeOfDay(form.timeOfDay);
if (parsedTime) {
@@ -261,6 +284,7 @@ export function EditAutomationModal({
<form
onSubmit={handleSubmit}
+ noValidate
className="mt-4 flex flex-col gap-4"
aria-label={t(I18nKey.AUTOMATIONS$EDIT_TITLE)}
>
@@ -313,6 +337,29 @@ export function EditAutomationModal({
/>
)}
+ <div className="flex flex-col gap-2.5 w-full min-w-0">
+ <SettingsInput
+ testId="edit-automation-timeout"
+ name="timeout"
+ type="number"
+ label={t(I18nKey.AUTOMATIONS$TIMEOUT)}
+ value={form.timeout}
+ onChange={(value) => setForm((f) => ({ ...f, timeout: value }))}
+ error={timeoutError ?? undefined}
+ showOptionalTag
+ min={1}
+ max={AUTOMATION_TIMEOUT_MAX_SECONDS}
+ step={1}
+ placeholder={String(AUTOMATION_TIMEOUT_DEFAULT_SECONDS)}
+ />
+ <span
+ data-testid="edit-automation-timeout-hint"
+ className="text-xs text-muted"
+ >
+ {t(I18nKey.AUTOMATIONS$TIMEOUT_HINT)}
+ </span>
+ </div>
+
{automation.trigger.type === "event" ? (
<div className="flex flex-col gap-3 rounded-lg bg-[var(--oh-surface-raised)] p-3">
<div className="flex items-center gap-2">
diff --git a/src/i18n/translation.json b/src/i18n/translation.json
index b86318cb05..55796b61dd 100644
--- a/src/i18n/translation.json
+++ b/src/i18n/translation.json
@@ -13531,6 +13531,91 @@
"uk": "Зміни застосовуються лише до майбутніх запусків.",
"ca": "Els canvis només s'apliquen a execucions futures."
},
+ "AUTOMATIONS$TIMEOUT": {
+ "en": "Timeout (seconds)",
+ "ja": "タイムアウト(秒)",
+ "zh-CN": "超时(秒)",
+ "zh-TW": "超時(秒)",
+ "ko-KR": "타임아웃(초)",
+ "no": "Timeout (sekunder)",
+ "it": "Timeout (secondi)",
+ "pt": "Timeout (segundos)",
+ "es": "Timeout (segundos)",
+ "ar": "المهلة الزمنية (ثوانٍ)",
+ "fr": "Timeout (secondes)",
+ "tr": "Zaman aşımı (saniye)",
+ "de": "Timeout (Sekunden)",
+ "uk": "Таймаут (секунди)",
+ "ca": "Temps d'espera (segons)"
+ },
+ "AUTOMATIONS$TIMEOUT_HINT": {
+ "en": "Maximum time a single run may take. Leave empty for the default of 600 seconds (10 minutes); maximum 1800 seconds (30 minutes).",
+ "ja": "1回の実行にかかる最大時間。空欄の場合はデフォルトの600秒(10分)が使用されます。最大1800秒(30分)。",
+ "zh-CN": "单次运行的最长时间。留空则使用默认值600秒(10分钟);最大1800秒(30分钟)。",
+ "zh-TW": "單次執行的最長時間。留空則使用預設值600秒(10分鐘);最大1800秒(30分鐘)。",
+ "ko-KR": "단일 실행에 걸리는 최대 시간입니다. 비워 두면 기본값 600초(10분)가 사용됩니다. 최대 1800초(30분).",
+ "no": "Maksimal tid en enkelt kjøring kan ta. La stå tom for standardverdien på 600 sekunder (10 minutter); maksimalt 1800 sekunder (30 minutter).",
+ "it": "Tempo massimo che una singola esecuzione può richiedere. Lascia vuoto per il valore predefinito di 600 secondi (10 minuti); massimo 1800 secondi (30 minuti).",
+ "pt": "Tempo máximo que uma única execução pode levar. Deixe em branco para o padrão de 600 segundos (10 minutos); máximo de 1800 segundos (30 minutos).",
+ "es": "Tiempo máximo que puede tardar una sola ejecución. Déjalo vacío para el valor predeterminado de 600 segundos (10 minutos); máximo 1800 segundos (30 minutos).",
+ "ar": "الحد الأقصى للوقت الذي قد تستغرقه عملية تشغيل واحدة. اتركه فارغًا لاستخدام القيمة الافتراضية 600 ثانية (10 دقائق)؛ الحد الأقصى 1800 ثانية (30 دقيقة).",
+ "fr": "Durée maximale d'une seule exécution. Laissez vide pour la valeur par défaut de 600 secondes (10 minutes) ; maximum 1800 secondes (30 minutes).",
+ "tr": "Tek bir çalıştırmanın alabileceği maksimum süre. Varsayılan 600 saniye (10 dakika) için boş bırakın; en fazla 1800 saniye (30 dakika).",
+ "de": "Maximale Dauer eines einzelnen Laufs. Leer lassen für den Standardwert von 600 Sekunden (10 Minuten); maximal 1800 Sekunden (30 Minuten).",
+ "uk": "Максимальний час одного запуску. Залиште порожнім для значення за замовчуванням 600 секунд (10 хвилин); максимум 1800 секунд (30 хвилин).",
+ "ca": "Temps màxim que pot trigar una sola execució. Deixa-ho buit per al valor predeterminat de 600 segons (10 minuts); màxim 1800 segons (30 minuts)."
+ },
+ "AUTOMATIONS$ERROR_TIMEOUT_INVALID_NUMBER": {
+ "en": "Timeout must be a valid number",
+ "ja": "タイムアウトは有効な数値である必要があります",
+ "zh-CN": "超时必须是有效数字",
+ "zh-TW": "超時必須是有效數字",
+ "ko-KR": "타임아웃은 유효한 숫자여야 합니다",
+ "no": "Timeout må være et gyldig tall",
+ "it": "Il timeout deve essere un numero valido",
+ "pt": "O timeout deve ser um número válido",
+ "es": "El timeout debe ser un número válido",
+ "ar": "يجب أن يكون المهلة الزمنية رقمًا صالحًا",
+ "fr": "Le timeout doit être un nombre valide",
+ "tr": "Zaman aşımı geçerli bir sayı olmalıdır",
+ "de": "Timeout muss eine gültige Zahl sein",
+ "uk": "Таймаут повинен бути дійсним числом",
+ "ca": "El temps d'espera ha de ser un número vàlid"
+ },
+ "AUTOMATIONS$ERROR_TIMEOUT_POSITIVE": {
+ "en": "Timeout must be positive",
+ "ja": "タイムアウトは正の値である必要があります",
+ "zh-CN": "超时必须为正数",
+ "zh-TW": "超時必須為正數",
+ "ko-KR": "타임아웃은 양수여야 합니다",
+ "no": "Timeout må være positiv",
+ "it": "Il timeout deve essere positivo",
+ "pt": "O timeout deve ser positivo",
+ "es": "El timeout debe ser positivo",
+ "ar": "يجب أن تكون المهلة الزمنية موجبة",
+ "fr": "Le timeout doit être positif",
+ "tr": "Zaman aşımı pozitif olmalıdır",
+ "de": "Timeout muss positiv sein",
+ "uk": "Таймаут повинен бути позитивним",
+ "ca": "El temps d'espera ha de ser positiu"
+ },
+ "AUTOMATIONS$ERROR_TIMEOUT_MAX_EXCEEDED": {
+ "en": "Timeout cannot exceed 1800 seconds (30 minutes)",
+ "ja": "タイムアウトは1800秒(30分)を超えることはできません",
+ "zh-CN": "超时不能超过1800秒(30分钟)",
+ "zh-TW": "超時不能超過1800秒(30分鐘)",
+ "ko-KR": "타임아웃은 1800초(30분)을 초과할 수 없습니다",
+ "no": "Timeout kan ikke overstige 1800 sekunder (30 minutter)",
+ "it": "Il timeout non può superare 1800 secondi (30 minuti)",
+ "pt": "O timeout não pode exceder 1800 segundos (30 minutos)",
+ "es": "El timeout no puede exceder 1800 segundos (30 minutos)",
+ "ar": "لا يمكن أن تتجاوز المهلة الزمنية 1800 ثانية (30 دقيقة)",
+ "fr": "Le timeout ne peut pas dépasser 1800 secondes (30 minutes)",
+ "tr": "Zaman aşımı 1800 saniyeyi (30 dakika) aşamaz",
+ "de": "Timeout kann 1800 Sekunden (30 Minuten) nicht überschreiten",
+ "uk": "Таймаут не може перевищувати 1800 секунд (30 хвилин)",
+ "ca": "El temps d'espera no pot superar els 1800 segons (30 minuts)"
+ },
"AUTOMATIONS$CUSTOM_SCHEDULE_HINT": {
"en": "This automation uses a custom schedule. Frequency editing is disabled to avoid breaking it.",
"ja": "このオートメーションはカスタムスケジュールを使用しています。誤って壊さないよう、頻度の編集は無効化されています。",
diff --git a/src/mocks/automation-handlers.ts b/src/mocks/automation-handlers.ts
index 07f98ca726..e2d4aac70f 100644
--- a/src/mocks/automation-handlers.ts
+++ b/src/mocks/automation-handlers.ts
@@ -58,6 +58,7 @@ export const AUTOMATION_HANDLERS = [
trigger: Automation["trigger"];
repos?: { url: string; ref?: string }[];
plugins?: { source: string }[];
+ timeout?: number;
};
const now = new Date().toISOString();
const automation: Automation = {
@@ -77,6 +78,7 @@ export const AUTOMATION_HANDLERS = [
...(body.plugins && {
plugins: body.plugins.map((plugin) => plugin.source),
}),
+ ...(typeof body.timeout === "number" && { timeout: body.timeout }),
...(typeof body.trigger.timezone === "string" && {
timezone: body.trigger.timezone,
}),
diff --git a/src/mocks/automations.mock.ts b/src/mocks/automations.mock.ts
index 6f47fff4d1..95441f3da9 100644
--- a/src/mocks/automations.mock.ts
+++ b/src/mocks/automations.mock.ts
@@ -28,6 +28,7 @@ export const MOCK_AUTOMATIONS_RESPONSE: AutomationsResponse = {
enabled: true,
repository: "acme/frontend-app",
model: "triage-fast",
+ timeout: 600,
created_at: daysAgo(90),
updated_at: now,
prompt:
@@ -49,6 +50,7 @@ export const MOCK_AUTOMATIONS_RESPONSE: AutomationsResponse = {
enabled: true,
repository: "acme/backend-api",
model: "security-careful",
+ timeout: 900,
created_at: daysAgo(60),
updated_at: now,
prompt:
@@ -134,6 +136,7 @@ export const MOCK_AUTOMATIONS_RESPONSE: AutomationsResponse = {
enabled: true,
repository: "acme/frontend-app",
model: "review-fast",
+ timeout: 1800,
created_at: daysAgo(15),
updated_at: now,
prompt:
diff --git a/src/types/automation.ts b/src/types/automation.ts
index cd6753d400..e5dcf5ebe7 100644
--- a/src/types/automation.ts
+++ b/src/types/automation.ts
@@ -29,6 +29,11 @@ export interface Automation {
repository?: string;
/** LLM/model profile name used for automation runs. */
model?: string | null;
+ /**
+ * Maximum run time in seconds. `null`/omitted uses the server default
+ * (600s, 10 min); the server caps it at 1800s (30 min).
+ */
+ timeout?: number | null;
created_at: string;
updated_at: string;
diff --git a/src/utils/automation-export.test.ts b/src/utils/automation-export.test.ts
index 1923b6be76..d6e06ca0ac 100644
--- a/src/utils/automation-export.test.ts
+++ b/src/utils/automation-export.test.ts
@@ -71,6 +71,14 @@ describe("automation export files", () => {
);
});
+ it("preserves a positive timeout through an export/import round-trip", () => {
+ const withTimeout: Automation = { ...cronAutomation, timeout: 900 };
+
+ const exported = serializeAutomation(withTimeout);
+
+ expect(parseAutomationFile(exported).timeout).toBe(900);
+ });
+
it("reports every malformed field with its path", () => {
const malformed = {
version: 2,
@@ -82,6 +90,7 @@ describe("automation export files", () => {
trigger: { type: "event", source: 42, on: [] },
plugins: ["github:openhands/extensions", 42],
model: false,
+ timeout: -5,
},
};
@@ -106,6 +115,7 @@ describe("automation export files", () => {
"spec.trigger.on: required for an event trigger",
"spec.plugins: expected an array of non-empty strings",
"spec.model: expected a non-empty string or null",
+ "spec.timeout: expected a positive integer",
]),
);
}
diff --git a/src/utils/automation-export.ts b/src/utils/automation-export.ts
index a8a15a5634..f5ad2599de 100644
--- a/src/utils/automation-export.ts
+++ b/src/utils/automation-export.ts
@@ -159,6 +159,7 @@ export function serializeAutomation(a: Automation): AutomationExportFile {
prompt: a.prompt,
...(a.repository !== undefined && { repository: a.repository }),
...(a.model !== undefined && { model: a.model }),
+ ...(a.timeout != null && { timeout: a.timeout }),
...(a.branch !== undefined && { branch: a.branch }),
...(a.plugins !== undefined && { plugins: [...a.plugins] }),
...(a.notification !== undefined && { notification: a.notification }),
@@ -247,6 +248,19 @@ export function parseAutomationFile(json: unknown): AutomationSpec {
issues.push("spec.model: expected a non-empty string or null");
}
+ let timeout: number | null | undefined;
+ if (json.spec.timeout === null || json.spec.timeout === undefined) {
+ timeout = json.spec.timeout;
+ } else if (
+ typeof json.spec.timeout === "number" &&
+ Number.isInteger(json.spec.timeout) &&
+ json.spec.timeout > 0
+ ) {
+ timeout = json.spec.timeout;
+ } else {
+ issues.push("spec.timeout: expected a positive integer");
+ }
+
let plugins: string[] | undefined;
if (json.spec.plugins !== undefined) {
if (
@@ -272,6 +286,7 @@ export function parseAutomationFile(json: unknown): AutomationSpec {
enabled: enabled as boolean,
...(repository !== undefined && { repository }),
...(model !== undefined && { model }),
+ ...(timeout !== undefined && { timeout }),
...(branch !== undefined && { branch }),
...(plugins !== undefined && { plugins }),
...(notification !== undefined && { notification }),
diff --git a/src/utils/automation-timeout.ts b/src/utils/automation-timeout.ts
new file mode 100644
index 0000000000..fcef8460ce
--- /dev/null
+++ b/src/utils/automation-timeout.ts
@@ -0,0 +1,37 @@
+import { I18nKey } from "#/i18n/declaration";
+
+/**
+ * Per-automation run timeout bounds. These mirror the automation server
+ * (`openhands/automation/utils/timeout.py`): a `null`/omitted timeout falls back
+ * to the default, and the server rejects anything above the maximum.
+ */
+export const AUTOMATION_TIMEOUT_DEFAULT_SECONDS = 600; // 10 minutes
+export const AUTOMATION_TIMEOUT_MAX_SECONDS = 1800; // 30 minutes
+
+export type AutomationTimeoutValidation =
+ | { value: number | null }
+ | { errorKey: I18nKey };
+
+/**
+ * Validate a raw timeout string from the edit form. A blank string means "use
+ * the server default" (resolved as `null`). Otherwise the value must be a
+ * positive integer no greater than {@link AUTOMATION_TIMEOUT_MAX_SECONDS}.
+ */
+export function validateAutomationTimeout(
+ raw: string,
+): AutomationTimeoutValidation {
+ const trimmed = raw.trim();
+ if (!trimmed) return { value: null };
+
+ const seconds = Number(trimmed);
+ if (!Number.isInteger(seconds)) {
+ return { errorKey: I18nKey.AUTOMATIONS$ERROR_TIMEOUT_INVALID_NUMBER };
+ }
+ if (seconds <= 0) {
+ return { errorKey: I18nKey.AUTOMATIONS$ERROR_TIMEOUT_POSITIVE };
+ }
+ if (seconds > AUTOMATION_TIMEOUT_MAX_SECONDS) {
+ return { errorKey: I18nKey.AUTOMATIONS$ERROR_TIMEOUT_MAX_EXCEEDED };
+ }
+ return { value: seconds };
+}