From 7d658dfd970135b0f58c8f6ab48b6336255a4029 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sat, 20 Jun 2026 06:18:09 +0200 Subject: [PATCH] fix(sdk): honor session send timeouts --- packages/sdk/src/client.ts | 9 ++++++++- packages/sdk/src/index.test.ts | 13 ++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/packages/sdk/src/client.ts b/packages/sdk/src/client.ts index 5abdcc8be73f..b4a012e30a4a 100644 --- a/packages/sdk/src/client.ts +++ b/packages/sdk/src/client.ts @@ -695,7 +695,14 @@ export class Session { async send(input: string | Omit): Promise { const params: SessionSendParams = typeof input === "string" ? { key: this.key, message: input } : { ...input, key: this.key }; - const raw = await this.client.request("sessions.send", params, { expectFinal: true }); + const timeoutMs = normalizeTimeoutMs(params.timeoutMs); + if (timeoutMs !== undefined) { + params.timeoutMs = timeoutMs; + } + const raw = await this.client.request("sessions.send", params, { + expectFinal: true, + ...(timeoutMs !== undefined ? { timeoutMs: timeoutMs === 0 ? null : timeoutMs } : {}), + }); const record = asRecord(raw); const runId = readOptionalString(record.runId); if (!runId) { diff --git a/packages/sdk/src/index.test.ts b/packages/sdk/src/index.test.ts index 876a1803c8e1..d91a2420f15e 100644 --- a/packages/sdk/src/index.test.ts +++ b/packages/sdk/src/index.test.ts @@ -1339,9 +1339,11 @@ describe("OpenClaw SDK", () => { const oc = new OpenClaw({ transport }); const session = await oc.sessions.create({ key: "session-main" }); - const run = await session.send({ message: "continue", thinking: "medium" }); + const run = await session.send({ message: "continue", thinking: "medium", timeoutMs: 1_500 }); + const noTimeoutRun = await session.send({ message: "continue without timeout", timeoutMs: 0 }); expect(run.id).toBe("run_session"); + expect(noTimeoutRun.id).toBe("run_session"); expect(transport.calls).toEqual([ { method: "sessions.create", @@ -1350,8 +1352,13 @@ describe("OpenClaw SDK", () => { }, { method: "sessions.send", - options: { expectFinal: true }, - params: { key: "session-main", message: "continue", thinking: "medium" }, + options: { expectFinal: true, timeoutMs: 1_500 }, + params: { key: "session-main", message: "continue", thinking: "medium", timeoutMs: 1_500 }, + }, + { + method: "sessions.send", + options: { expectFinal: true, timeoutMs: null }, + params: { key: "session-main", message: "continue without timeout", timeoutMs: 0 }, }, ]); });