From 454af218968b2962b4beeb9a28b9d421f0610694 Mon Sep 17 00:00:00 2001 From: Connor Braa <3478454+cwlbraa@users.noreply.github.com> Date: Fri, 9 Jan 2026 13:07:32 -0800 Subject: [PATCH] feat(sdk-py): cron.on_run_completed support (#6662) **Description:** this PR adds cron.on_run_completed support to the SDK. documentation https://github.com/langchain-ai/docs/pull/2147 js equivalent change https://github.com/langchain-ai/langgraphjs/pull/1845 original langgraph-api change https://github.com/langchain-ai/langgraph-api/pull/1731 **Issue:** LSD-172 --------- Signed-off-by: Connor Braa Co-authored-by: Claude Opus 4.5 --- libs/sdk-py/langgraph_sdk/__init__.py | 2 +- libs/sdk-py/langgraph_sdk/client.py | 12 ++++++++++++ libs/sdk-py/langgraph_sdk/schema.py | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/libs/sdk-py/langgraph_sdk/__init__.py b/libs/sdk-py/langgraph_sdk/__init__.py index f3798684b..aa1b1b73e 100644 --- a/libs/sdk-py/langgraph_sdk/__init__.py +++ b/libs/sdk-py/langgraph_sdk/__init__.py @@ -3,6 +3,6 @@ from langgraph_sdk.client import get_client, get_sync_client from langgraph_sdk.encryption import Encryption from langgraph_sdk.encryption.types import EncryptionContext -__version__ = "0.3.1" +__version__ = "0.3.2" __all__ = ["Auth", "Encryption", "EncryptionContext", "get_client", "get_sync_client"] diff --git a/libs/sdk-py/langgraph_sdk/client.py b/libs/sdk-py/langgraph_sdk/client.py index cda54ac78..34c7e9863 100644 --- a/libs/sdk-py/langgraph_sdk/client.py +++ b/libs/sdk-py/langgraph_sdk/client.py @@ -3064,6 +3064,7 @@ class CronClient: interrupt_before: All | list[str] | None = None, interrupt_after: All | list[str] | None = None, webhook: str | None = None, + on_run_completed: OnCompletionBehavior | None = None, multitask_strategy: str | None = None, headers: Mapping[str, str] | None = None, params: QueryParamTypes | None = None, @@ -3083,6 +3084,10 @@ class CronClient: interrupt_before: Nodes to interrupt immediately before they get executed. interrupt_after: Nodes to Nodes to interrupt immediately after they get executed. webhook: Webhook to call after LangGraph API call is done. + on_run_completed: What to do with the thread after the run completes. + Must be one of 'delete' (default) or 'keep'. 'delete' removes the thread + after execution. 'keep' creates a new thread for each execution but does not + clean them up. Clients are responsible for cleaning up kept threads. multitask_strategy: Multitask strategy to use. Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'. headers: Optional custom headers to include with the request. @@ -3120,6 +3125,7 @@ class CronClient: "interrupt_before": interrupt_before, "interrupt_after": interrupt_after, "webhook": webhook, + "on_run_completed": on_run_completed, } if multitask_strategy: payload["multitask_strategy"] = multitask_strategy @@ -6356,6 +6362,7 @@ class SyncCronClient: interrupt_before: All | list[str] | None = None, interrupt_after: All | list[str] | None = None, webhook: str | None = None, + on_run_completed: OnCompletionBehavior | None = None, multitask_strategy: str | None = None, headers: Mapping[str, str] | None = None, params: QueryParamTypes | None = None, @@ -6375,6 +6382,10 @@ class SyncCronClient: interrupt_before: Nodes to interrupt immediately before they get executed. interrupt_after: Nodes to Nodes to interrupt immediately after they get executed. webhook: Webhook to call after LangGraph API call is done. + on_run_completed: What to do with the thread after the run completes. + Must be one of 'delete' (default) or 'keep'. 'delete' removes the thread + after execution. 'keep' creates a new thread for each execution but does not + clean them up. Clients are responsible for cleaning up kept threads. multitask_strategy: Multitask strategy to use. Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'. headers: Optional custom headers to include with the request. @@ -6412,6 +6423,7 @@ class SyncCronClient: "interrupt_after": interrupt_after, "webhook": webhook, "checkpoint_during": checkpoint_during, + "on_run_completed": on_run_completed, "multitask_strategy": multitask_strategy, } payload = {k: v for k, v in payload.items() if v is not None} diff --git a/libs/sdk-py/langgraph_sdk/schema.py b/libs/sdk-py/langgraph_sdk/schema.py index bee967e2c..fa66b4d92 100644 --- a/libs/sdk-py/langgraph_sdk/schema.py +++ b/libs/sdk-py/langgraph_sdk/schema.py @@ -354,6 +354,8 @@ class Cron(TypedDict): """The ID of the assistant.""" thread_id: str | None """The ID of the thread.""" + on_run_completed: OnCompletionBehavior | None + """What to do with the thread after the run completes. Only applicable for stateless crons.""" end_time: datetime | None """The end date to stop running the cron.""" schedule: str