diff --git a/libs/sdk-js/src/client.ts b/libs/sdk-js/src/client.ts index 010864419..ecf7147ca 100644 --- a/libs/sdk-js/src/client.ts +++ b/libs/sdk-js/src/client.ts @@ -7,6 +7,7 @@ import { GraphSchema, Metadata, Run, + RunStatus, Thread, ThreadState, Cron, @@ -944,12 +945,18 @@ export class RunsClient extends BaseClient { * Defaults to 0. */ offset?: number; + + /** + * Status of the run to filter by. + */ + status?: RunStatus; }, ): Promise { return this.fetch(`/threads/${threadId}/runs`, { params: { limit: options?.limit ?? 10, offset: options?.offset ?? 0, + status: options?.status ?? undefined, }, }); } diff --git a/libs/sdk-js/src/schema.ts b/libs/sdk-js/src/schema.ts index dd79e07ba..f68e3d42f 100644 --- a/libs/sdk-js/src/schema.ts +++ b/libs/sdk-js/src/schema.ts @@ -2,7 +2,7 @@ import type { JSONSchema7 } from "json-schema"; type Optional = T | null | undefined; -type RunStatus = +export type RunStatus = | "pending" | "running" | "error" diff --git a/libs/sdk-py/langgraph_sdk/client.py b/libs/sdk-py/langgraph_sdk/client.py index 81e8a8506..b7cc1a78c 100644 --- a/libs/sdk-py/langgraph_sdk/client.py +++ b/libs/sdk-py/langgraph_sdk/client.py @@ -51,6 +51,7 @@ OnConflictBehavior, Run, RunCreate, + RunStatus, SearchItemsResponse, StreamMode, StreamPart, @@ -1684,7 +1685,12 @@ async def wait( return response async def list( - self, thread_id: str, *, limit: int = 10, offset: int = 0 + self, + thread_id: str, + *, + limit: int = 10, + offset: int = 0, + status: Optional[RunStatus] = None, ) -> List[Run]: """List runs. @@ -1692,6 +1698,7 @@ async def list( thread_id: The thread ID to list runs for. limit: The maximum number of results to return. offset: The number of results to skip. + status: The status of the run to filter by. Returns: List[Run]: The runs for the thread. @@ -1705,9 +1712,13 @@ async def list( ) """ # noqa: E501 - return await self.http.get( - f"/threads/{thread_id}/runs?limit={limit}&offset={offset}" - ) + params = { + "limit": limit, + "offset": offset, + } + if status is not None: + params["status"] = status + return await self.http.get(f"/threads/{thread_id}/runs", params=params) async def get(self, thread_id: str, run_id: str) -> Run: """Get a run.