Skip to content

Commit 02beb41

Browse files
wbadartdqbd
andauthored
RunsClient.create: support stateless Run creation (#1694)
Co-authored-by: David Duong <[email protected]>
1 parent c115fe9 commit 02beb41

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.changeset/thirty-boats-hear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@langchain/langgraph-sdk": patch
3+
---
4+
5+
Add support for creating stateless runs

libs/sdk/src/client.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ export class RunsClient<
11781178
* @returns The created run.
11791179
*/
11801180
async create(
1181-
threadId: string,
1181+
threadId: string | null,
11821182
assistantId: string,
11831183
payload?: RunsCreatePayload
11841184
): Promise<Run> {
@@ -1210,7 +1210,8 @@ export class RunsClient<
12101210
: undefined,
12111211
};
12121212

1213-
const [run, response] = await this.fetch<Run>(`/threads/${threadId}/runs`, {
1213+
const endpoint = threadId === null ? "/runs" : `/threads/${threadId}/runs`;
1214+
const [run, response] = await this.fetch<Run>(endpoint, {
12141215
method: "POST",
12151216
json,
12161217
signal: payload?.signal,

0 commit comments

Comments
 (0)