mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-13 21:27:52 +02:00
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 <cwlbraa@langchain.dev> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.5
parent
d066a321bc
commit
454af21896
@@ -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"]
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user