fix(sdk): preserve zero run timeout watchdog

This commit is contained in:
Vincent Koc
2026-06-22 00:13:45 +02:00
parent 464adfe5e5
commit 2bdcc8314d
2 changed files with 18 additions and 2 deletions

View File

@@ -790,9 +790,11 @@ export class RunsNamespace {
constructor(private readonly client: OpenClaw) {}
async create(params: RunCreateParams): Promise<Run> {
const raw = await this.client.request("agent", buildAgentParams(params), {
const timeoutMs = normalizeTimeoutMs(params.timeoutMs);
const normalizedParams = timeoutMs !== undefined ? { ...params, timeoutMs } : params;
const raw = await this.client.request("agent", buildAgentParams(normalizedParams), {
expectFinal: false,
timeoutMs: params.timeoutMs,
...(timeoutMs !== undefined ? { timeoutMs: timeoutMs === 0 ? null : timeoutMs } : {}),
});
const record = asRecord(raw);
const runId = readOptionalString(record.runId);

View File

@@ -445,6 +445,11 @@ describe("OpenClaw SDK", () => {
timeoutMs: 1_500,
idempotencyKey: "timeout-test",
});
await oc.runs.create({
input: "run without SDK watchdog",
timeoutMs: 0,
idempotencyKey: "no-watchdog-test",
});
expect(requireTransportCall(transport.calls, 0)).toEqual({
method: "agent",
@@ -455,6 +460,15 @@ describe("OpenClaw SDK", () => {
idempotencyKey: "timeout-test",
},
});
expect(requireTransportCall(transport.calls, 1)).toEqual({
method: "agent",
options: { expectFinal: false, timeoutMs: null },
params: {
message: "run without SDK watchdog",
timeout: 0,
idempotencyKey: "no-watchdog-test",
},
});
await expect(
oc.runs.create({
input: "bad timeout",