Skip to content

Commit cec50aa

Browse files
committed
fix(browser): cap act action timeouts
1 parent fc90f0f commit cec50aa

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎extensions/browser/src/browser/routes/agent.act.normalize.test.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { MAX_TIMER_TIMEOUT_MS } from "openclaw/plugin-sdk/number-runtime";
12
import { describe, expect, it } from "vitest";
23
import { normalizeActRequest } from "./agent.act.normalize.js";
34

@@ -32,6 +33,20 @@ describe("normalizeActRequest numeric fields", () => {
3233
});
3334
});
3435

36+
it("caps oversized action timeouts", () => {
37+
expect(
38+
normalizeActRequest({
39+
kind: "wait",
40+
text: "ready",
41+
timeoutMs: String(Number.MAX_SAFE_INTEGER),
42+
}),
43+
).toMatchObject({
44+
kind: "wait",
45+
text: "ready",
46+
timeoutMs: MAX_TIMER_TIMEOUT_MS,
47+
});
48+
});
49+
3550
it("rejects loose integer tokens for action durations and timeouts", () => {
3651
expect(() =>
3752
normalizeActRequest({

‎extensions/browser/src/browser/routes/agent.act.normalize.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
12
import {
23
ACT_MAX_BATCH_ACTIONS,
34
ACT_MAX_CLICK_DELAY_MS,
@@ -88,7 +89,8 @@ function readActionNonNegativeInteger(
8889
}
8990

9091
function readActionTimeoutMs(body: Record<string, unknown>): number | undefined {
91-
return readActionPositiveInteger(body, "timeoutMs");
92+
const timeoutMs = readActionPositiveInteger(body, "timeoutMs");
93+
return timeoutMs === undefined ? undefined : resolveTimerTimeoutMs(timeoutMs, 1);
9294
}
9395

9496
function readBoundedActionDurationMs(

0 commit comments

Comments
 (0)