langgraph-sdk 0.2.3__tar.gz → 0.2.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langgraph-sdk
3
- Version: 0.2.3
3
+ Version: 0.2.5
4
4
  Summary: SDK for interacting with LangGraph API
5
5
  Project-URL: Repository, https://www.github.com/langchain-ai/langgraph
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  from langgraph_sdk.auth import Auth
2
2
  from langgraph_sdk.client import get_client, get_sync_client
3
3
 
4
- __version__ = "0.2.3"
4
+ __version__ = "0.2.5"
5
5
 
6
6
  __all__ = ["Auth", "get_client", "get_sync_client"]
@@ -489,6 +489,9 @@ class ThreadsSearch(typing.TypedDict, total=False):
489
489
  offset: int
490
490
  """Offset for pagination."""
491
491
 
492
+ ids: Sequence[UUID] | None
493
+ """typing.Optional list of thread IDs to filter by."""
494
+
492
495
  thread_id: UUID | None
493
496
  """typing.Optional thread ID to filter by."""
494
497
 
@@ -15,6 +15,7 @@ import logging
15
15
  import os
16
16
  import re
17
17
  import sys
18
+ import warnings
18
19
  from collections.abc import AsyncIterator, Iterator, Mapping, Sequence
19
20
  from types import TracebackType
20
21
  from typing import (
@@ -45,6 +46,7 @@ from langgraph_sdk.schema import (
45
46
  CronSelectField,
46
47
  CronSortBy,
47
48
  DisconnectMode,
49
+ Durability,
48
50
  GraphSchema,
49
51
  IfNotExists,
50
52
  Item,
@@ -69,6 +71,7 @@ from langgraph_sdk.schema import (
69
71
  ThreadSortBy,
70
72
  ThreadState,
71
73
  ThreadStatus,
74
+ ThreadStreamMode,
72
75
  ThreadUpdateStateResponse,
73
76
  )
74
77
  from langgraph_sdk.sse import SSEDecoder, aiter_lines_raw, iter_lines_raw
@@ -1306,6 +1309,7 @@ class ThreadsClient:
1306
1309
  *,
1307
1310
  metadata: Json = None,
1308
1311
  values: Json = None,
1312
+ ids: Sequence[str] | None = None,
1309
1313
  status: ThreadStatus | None = None,
1310
1314
  limit: int = 10,
1311
1315
  offset: int = 0,
@@ -1320,6 +1324,7 @@ class ThreadsClient:
1320
1324
  Args:
1321
1325
  metadata: Thread metadata to filter on.
1322
1326
  values: State values to filter on.
1327
+ ids: List of thread IDs to filter by.
1323
1328
  status: Thread status to filter on.
1324
1329
  Must be one of 'idle', 'busy', 'interrupted' or 'error'.
1325
1330
  limit: Limit on number of threads to return.
@@ -1353,6 +1358,8 @@ class ThreadsClient:
1353
1358
  payload["metadata"] = metadata
1354
1359
  if values:
1355
1360
  payload["values"] = values
1361
+ if ids:
1362
+ payload["ids"] = ids
1356
1363
  if status:
1357
1364
  payload["status"] = status
1358
1365
  if sort_by:
@@ -1682,6 +1689,53 @@ class ThreadsClient:
1682
1689
  params=params,
1683
1690
  )
1684
1691
 
1692
+ async def join_stream(
1693
+ self,
1694
+ thread_id: str,
1695
+ *,
1696
+ last_event_id: str | None = None,
1697
+ stream_mode: ThreadStreamMode | Sequence[ThreadStreamMode] = "run_modes",
1698
+ headers: Mapping[str, str] | None = None,
1699
+ params: QueryParamTypes | None = None,
1700
+ ) -> AsyncIterator[StreamPart]:
1701
+ """Get a stream of events for a thread.
1702
+
1703
+ Args:
1704
+ thread_id: The ID of the thread to get the stream for.
1705
+ last_event_id: The ID of the last event to get.
1706
+ headers: Optional custom headers to include with the request.
1707
+ params: Optional query parameters to include with the request.
1708
+
1709
+ Returns:
1710
+ Iterator[StreamPart]: An iterator of stream parts.
1711
+
1712
+ ???+ example "Example Usage"
1713
+
1714
+ ```python
1715
+
1716
+ for chunk in client.threads.join_stream(
1717
+ thread_id="my_thread_id",
1718
+ last_event_id="my_event_id",
1719
+ ):
1720
+ print(chunk)
1721
+ ```
1722
+
1723
+ """ # noqa: E501
1724
+ query_params = {
1725
+ "stream_mode": stream_mode,
1726
+ }
1727
+ if params:
1728
+ query_params.update(params)
1729
+ return self.http.stream(
1730
+ f"/threads/{thread_id}/stream",
1731
+ "GET",
1732
+ headers={
1733
+ **({"Last-Event-ID": last_event_id} if last_event_id else {}),
1734
+ **(headers or {}),
1735
+ },
1736
+ params=query_params,
1737
+ )
1738
+
1685
1739
 
1686
1740
  class RunsClient:
1687
1741
  """Client for managing runs in LangGraph.
@@ -1772,7 +1826,7 @@ class RunsClient:
1772
1826
  context: Context | None = None,
1773
1827
  checkpoint: Checkpoint | None = None,
1774
1828
  checkpoint_id: str | None = None,
1775
- checkpoint_during: bool | None = None,
1829
+ checkpoint_during: bool | None = None, # deprecated
1776
1830
  interrupt_before: All | Sequence[str] | None = None,
1777
1831
  interrupt_after: All | Sequence[str] | None = None,
1778
1832
  feedback_keys: Sequence[str] | None = None,
@@ -1785,6 +1839,7 @@ class RunsClient:
1785
1839
  headers: Mapping[str, str] | None = None,
1786
1840
  params: QueryParamTypes | None = None,
1787
1841
  on_run_created: Callable[[RunCreateMetadata], None] | None = None,
1842
+ durability: Durability | None = None,
1788
1843
  ) -> AsyncIterator[StreamPart]:
1789
1844
  """Create a run and stream the results.
1790
1845
 
@@ -1804,7 +1859,7 @@ class RunsClient:
1804
1859
  context: Static context to add to the assistant.
1805
1860
  !!! version-added "Supported with langgraph>=0.6.0"
1806
1861
  checkpoint: The checkpoint to resume from.
1807
- checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
1862
+ checkpoint_during: (deprecated) Whether to checkpoint during the run (or only at the end/interruption).
1808
1863
  interrupt_before: Nodes to interrupt immediately before they get executed.
1809
1864
  interrupt_after: Nodes to Nodes to interrupt immediately after they get executed.
1810
1865
  feedback_keys: Feedback keys to assign to run.
@@ -1822,6 +1877,10 @@ class RunsClient:
1822
1877
  headers: Optional custom headers to include with the request.
1823
1878
  params: Optional query parameters to include with the request.
1824
1879
  on_run_created: Callback when a run is created.
1880
+ durability: The durability to use for the run. Values are "sync", "async", or "exit".
1881
+ "async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True
1882
+ "sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False
1883
+ "exit" means checkpoints are only persisted when the run exits, does not save intermediate steps
1825
1884
 
1826
1885
  Returns:
1827
1886
  AsyncIterator[StreamPart]: Asynchronous iterator of stream results.
@@ -1857,6 +1916,13 @@ class RunsClient:
1857
1916
  ```
1858
1917
 
1859
1918
  """ # noqa: E501
1919
+ if checkpoint_during is not None:
1920
+ warnings.warn(
1921
+ "`checkpoint_during` is deprecated and will be removed in a future version. Use `durability` instead.",
1922
+ DeprecationWarning,
1923
+ stacklevel=2,
1924
+ )
1925
+
1860
1926
  payload = {
1861
1927
  "input": input,
1862
1928
  "command": (
@@ -1881,6 +1947,7 @@ class RunsClient:
1881
1947
  "on_disconnect": on_disconnect,
1882
1948
  "on_completion": on_completion,
1883
1949
  "after_seconds": after_seconds,
1950
+ "durability": durability,
1884
1951
  }
1885
1952
  endpoint = (
1886
1953
  f"/threads/{thread_id}/runs/stream"
@@ -1971,7 +2038,7 @@ class RunsClient:
1971
2038
  context: Context | None = None,
1972
2039
  checkpoint: Checkpoint | None = None,
1973
2040
  checkpoint_id: str | None = None,
1974
- checkpoint_during: bool | None = None,
2041
+ checkpoint_during: bool | None = None, # deprecated
1975
2042
  interrupt_before: All | Sequence[str] | None = None,
1976
2043
  interrupt_after: All | Sequence[str] | None = None,
1977
2044
  webhook: str | None = None,
@@ -1982,6 +2049,7 @@ class RunsClient:
1982
2049
  headers: Mapping[str, str] | None = None,
1983
2050
  params: QueryParamTypes | None = None,
1984
2051
  on_run_created: Callable[[RunCreateMetadata], None] | None = None,
2052
+ durability: Durability | None = None,
1985
2053
  ) -> Run:
1986
2054
  """Create a background run.
1987
2055
 
@@ -2001,7 +2069,7 @@ class RunsClient:
2001
2069
  context: Static context to add to the assistant.
2002
2070
  !!! version-added "Supported with langgraph>=0.6.0"
2003
2071
  checkpoint: The checkpoint to resume from.
2004
- checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
2072
+ checkpoint_during: (deprecated) Whether to checkpoint during the run (or only at the end/interruption).
2005
2073
  interrupt_before: Nodes to interrupt immediately before they get executed.
2006
2074
  interrupt_after: Nodes to Nodes to interrupt immediately after they get executed.
2007
2075
  webhook: Webhook to call after LangGraph API call is done.
@@ -2015,6 +2083,10 @@ class RunsClient:
2015
2083
  Use to schedule future runs.
2016
2084
  headers: Optional custom headers to include with the request.
2017
2085
  on_run_created: Optional callback to call when a run is created.
2086
+ durability: The durability to use for the run. Values are "sync", "async", or "exit".
2087
+ "async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True
2088
+ "sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False
2089
+ "exit" means checkpoints are only persisted when the run exits, does not save intermediate steps
2018
2090
 
2019
2091
  Returns:
2020
2092
  Run: The created background run.
@@ -2090,6 +2162,12 @@ class RunsClient:
2090
2162
  }
2091
2163
  ```
2092
2164
  """ # noqa: E501
2165
+ if checkpoint_during is not None:
2166
+ warnings.warn(
2167
+ "`checkpoint_during` is deprecated and will be removed in a future version. Use `durability` instead.",
2168
+ DeprecationWarning,
2169
+ stacklevel=2,
2170
+ )
2093
2171
  payload = {
2094
2172
  "input": input,
2095
2173
  "command": (
@@ -2112,6 +2190,7 @@ class RunsClient:
2112
2190
  "if_not_exists": if_not_exists,
2113
2191
  "on_completion": on_completion,
2114
2192
  "after_seconds": after_seconds,
2193
+ "durability": durability,
2115
2194
  }
2116
2195
  payload = {k: v for k, v in payload.items() if v is not None}
2117
2196
 
@@ -2209,7 +2288,7 @@ class RunsClient:
2209
2288
  context: Context | None = None,
2210
2289
  checkpoint: Checkpoint | None = None,
2211
2290
  checkpoint_id: str | None = None,
2212
- checkpoint_during: bool | None = None,
2291
+ checkpoint_during: bool | None = None, # deprecated
2213
2292
  interrupt_before: All | Sequence[str] | None = None,
2214
2293
  interrupt_after: All | Sequence[str] | None = None,
2215
2294
  webhook: str | None = None,
@@ -2222,6 +2301,7 @@ class RunsClient:
2222
2301
  headers: Mapping[str, str] | None = None,
2223
2302
  params: QueryParamTypes | None = None,
2224
2303
  on_run_created: Callable[[RunCreateMetadata], None] | None = None,
2304
+ durability: Durability | None = None,
2225
2305
  ) -> list[dict] | dict[str, Any]:
2226
2306
  """Create a run, wait until it finishes and return the final state.
2227
2307
 
@@ -2237,7 +2317,7 @@ class RunsClient:
2237
2317
  context: Static context to add to the assistant.
2238
2318
  !!! version-added "Supported with langgraph>=0.6.0"
2239
2319
  checkpoint: The checkpoint to resume from.
2240
- checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
2320
+ checkpoint_during: (deprecated) Whether to checkpoint during the run (or only at the end/interruption).
2241
2321
  interrupt_before: Nodes to interrupt immediately before they get executed.
2242
2322
  interrupt_after: Nodes to Nodes to interrupt immediately after they get executed.
2243
2323
  webhook: Webhook to call after LangGraph API call is done.
@@ -2253,6 +2333,10 @@ class RunsClient:
2253
2333
  Use to schedule future runs.
2254
2334
  headers: Optional custom headers to include with the request.
2255
2335
  on_run_created: Optional callback to call when a run is created.
2336
+ durability: The durability to use for the run. Values are "sync", "async", or "exit".
2337
+ "async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True
2338
+ "sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False
2339
+ "exit" means checkpoints are only persisted when the run exits, does not save intermediate steps
2256
2340
 
2257
2341
  Returns:
2258
2342
  Union[list[dict], dict[str, Any]]: The output of the run.
@@ -2306,6 +2390,12 @@ class RunsClient:
2306
2390
  ```
2307
2391
 
2308
2392
  """ # noqa: E501
2393
+ if checkpoint_during is not None:
2394
+ warnings.warn(
2395
+ "`checkpoint_during` is deprecated and will be removed in a future version. Use `durability` instead.",
2396
+ DeprecationWarning,
2397
+ stacklevel=2,
2398
+ )
2309
2399
  payload = {
2310
2400
  "input": input,
2311
2401
  "command": (
@@ -2326,6 +2416,7 @@ class RunsClient:
2326
2416
  "on_disconnect": on_disconnect,
2327
2417
  "on_completion": on_completion,
2328
2418
  "after_seconds": after_seconds,
2419
+ "durability": durability,
2329
2420
  }
2330
2421
  endpoint = (
2331
2422
  f"/threads/{thread_id}/runs/wait" if thread_id is not None else "/runs/wait"
@@ -4367,6 +4458,7 @@ class SyncThreadsClient:
4367
4458
  *,
4368
4459
  metadata: Json = None,
4369
4460
  values: Json = None,
4461
+ ids: Sequence[str] | None = None,
4370
4462
  status: ThreadStatus | None = None,
4371
4463
  limit: int = 10,
4372
4464
  offset: int = 0,
@@ -4381,6 +4473,7 @@ class SyncThreadsClient:
4381
4473
  Args:
4382
4474
  metadata: Thread metadata to filter on.
4383
4475
  values: State values to filter on.
4476
+ ids: List of thread IDs to filter by.
4384
4477
  status: Thread status to filter on.
4385
4478
  Must be one of 'idle', 'busy', 'interrupted' or 'error'.
4386
4479
  limit: Limit on number of threads to return.
@@ -4410,6 +4503,8 @@ class SyncThreadsClient:
4410
4503
  payload["metadata"] = metadata
4411
4504
  if values:
4412
4505
  payload["values"] = values
4506
+ if ids:
4507
+ payload["ids"] = ids
4413
4508
  if status:
4414
4509
  payload["status"] = status
4415
4510
  if sort_by:
@@ -4733,6 +4828,54 @@ class SyncThreadsClient:
4733
4828
  params=params,
4734
4829
  )
4735
4830
 
4831
+ def join_stream(
4832
+ self,
4833
+ thread_id: str,
4834
+ *,
4835
+ stream_mode: ThreadStreamMode | Sequence[ThreadStreamMode] = "run_modes",
4836
+ last_event_id: str | None = None,
4837
+ headers: Mapping[str, str] | None = None,
4838
+ params: QueryParamTypes | None = None,
4839
+ ) -> Iterator[StreamPart]:
4840
+ """Get a stream of events for a thread.
4841
+
4842
+ Args:
4843
+ thread_id: The ID of the thread to get the stream for.
4844
+ last_event_id: The ID of the last event to get.
4845
+ headers: Optional custom headers to include with the request.
4846
+ params: Optional query parameters to include with the request.
4847
+
4848
+ Returns:
4849
+ Iterator[StreamPart]: An iterator of stream parts.
4850
+
4851
+ ???+ example "Example Usage"
4852
+
4853
+ ```python
4854
+
4855
+ for chunk in client.threads.join_stream(
4856
+ thread_id="my_thread_id",
4857
+ last_event_id="my_event_id",
4858
+ stream_mode="run_modes",
4859
+ ):
4860
+ print(chunk)
4861
+ ```
4862
+
4863
+ """ # noqa: E501
4864
+ query_params = {
4865
+ "stream_mode": stream_mode,
4866
+ }
4867
+ if params:
4868
+ query_params.update(params)
4869
+ return self.http.stream(
4870
+ f"/threads/{thread_id}/stream",
4871
+ "GET",
4872
+ headers={
4873
+ **({"Last-Event-ID": last_event_id} if last_event_id else {}),
4874
+ **(headers or {}),
4875
+ },
4876
+ params=query_params,
4877
+ )
4878
+
4736
4879
 
4737
4880
  class SyncRunsClient:
4738
4881
  """Synchronous client for managing runs in LangGraph.
@@ -4823,7 +4966,7 @@ class SyncRunsClient:
4823
4966
  context: Context | None = None,
4824
4967
  checkpoint: Checkpoint | None = None,
4825
4968
  checkpoint_id: str | None = None,
4826
- checkpoint_during: bool | None = None,
4969
+ checkpoint_during: bool | None = None, # deprecated
4827
4970
  interrupt_before: All | Sequence[str] | None = None,
4828
4971
  interrupt_after: All | Sequence[str] | None = None,
4829
4972
  feedback_keys: Sequence[str] | None = None,
@@ -4836,6 +4979,7 @@ class SyncRunsClient:
4836
4979
  headers: Mapping[str, str] | None = None,
4837
4980
  params: QueryParamTypes | None = None,
4838
4981
  on_run_created: Callable[[RunCreateMetadata], None] | None = None,
4982
+ durability: Durability | None = None,
4839
4983
  ) -> Iterator[StreamPart]:
4840
4984
  """Create a run and stream the results.
4841
4985
 
@@ -4855,7 +4999,7 @@ class SyncRunsClient:
4855
4999
  context: Static context to add to the assistant.
4856
5000
  !!! version-added "Supported with langgraph>=0.6.0"
4857
5001
  checkpoint: The checkpoint to resume from.
4858
- checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
5002
+ checkpoint_during: (deprecated) Whether to checkpoint during the run (or only at the end/interruption).
4859
5003
  interrupt_before: Nodes to interrupt immediately before they get executed.
4860
5004
  interrupt_after: Nodes to Nodes to interrupt immediately after they get executed.
4861
5005
  feedback_keys: Feedback keys to assign to run.
@@ -4872,6 +5016,11 @@ class SyncRunsClient:
4872
5016
  Use to schedule future runs.
4873
5017
  headers: Optional custom headers to include with the request.
4874
5018
  on_run_created: Optional callback to call when a run is created.
5019
+ durability: The durability to use for the run. Values are "sync", "async", or "exit".
5020
+ "async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True
5021
+ "sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False
5022
+ "exit" means checkpoints are only persisted when the run exits, does not save intermediate steps
5023
+
4875
5024
 
4876
5025
  Returns:
4877
5026
  Iterator[StreamPart]: Iterator of stream results.
@@ -4904,6 +5053,12 @@ class SyncRunsClient:
4904
5053
  StreamPart(event='end', data=None)
4905
5054
  ```
4906
5055
  """ # noqa: E501
5056
+ if checkpoint_during is not None:
5057
+ warnings.warn(
5058
+ "`checkpoint_during` is deprecated and will be removed in a future version. Use `durability` instead.",
5059
+ DeprecationWarning,
5060
+ stacklevel=2,
5061
+ )
4907
5062
  payload = {
4908
5063
  "input": input,
4909
5064
  "command": (
@@ -4928,6 +5083,7 @@ class SyncRunsClient:
4928
5083
  "on_disconnect": on_disconnect,
4929
5084
  "on_completion": on_completion,
4930
5085
  "after_seconds": after_seconds,
5086
+ "durability": durability,
4931
5087
  }
4932
5088
  endpoint = (
4933
5089
  f"/threads/{thread_id}/runs/stream"
@@ -5018,7 +5174,7 @@ class SyncRunsClient:
5018
5174
  context: Context | None = None,
5019
5175
  checkpoint: Checkpoint | None = None,
5020
5176
  checkpoint_id: str | None = None,
5021
- checkpoint_during: bool | None = None,
5177
+ checkpoint_during: bool | None = None, # deprecated
5022
5178
  interrupt_before: All | Sequence[str] | None = None,
5023
5179
  interrupt_after: All | Sequence[str] | None = None,
5024
5180
  webhook: str | None = None,
@@ -5029,6 +5185,7 @@ class SyncRunsClient:
5029
5185
  headers: Mapping[str, str] | None = None,
5030
5186
  params: QueryParamTypes | None = None,
5031
5187
  on_run_created: Callable[[RunCreateMetadata], None] | None = None,
5188
+ durability: Durability | None = None,
5032
5189
  ) -> Run:
5033
5190
  """Create a background run.
5034
5191
 
@@ -5048,7 +5205,7 @@ class SyncRunsClient:
5048
5205
  context: Static context to add to the assistant.
5049
5206
  !!! version-added "Supported with langgraph>=0.6.0"
5050
5207
  checkpoint: The checkpoint to resume from.
5051
- checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
5208
+ checkpoint_during: (deprecated) Whether to checkpoint during the run (or only at the end/interruption).
5052
5209
  interrupt_before: Nodes to interrupt immediately before they get executed.
5053
5210
  interrupt_after: Nodes to Nodes to interrupt immediately after they get executed.
5054
5211
  webhook: Webhook to call after LangGraph API call is done.
@@ -5062,6 +5219,10 @@ class SyncRunsClient:
5062
5219
  Use to schedule future runs.
5063
5220
  headers: Optional custom headers to include with the request.
5064
5221
  on_run_created: Optional callback to call when a run is created.
5222
+ durability: The durability to use for the run. Values are "sync", "async", or "exit".
5223
+ "async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True
5224
+ "sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False
5225
+ "exit" means checkpoints are only persisted when the run exits, does not save intermediate steps
5065
5226
 
5066
5227
  Returns:
5067
5228
  Run: The created background run.
@@ -5137,6 +5298,12 @@ class SyncRunsClient:
5137
5298
  }
5138
5299
  ```
5139
5300
  """ # noqa: E501
5301
+ if checkpoint_during is not None:
5302
+ warnings.warn(
5303
+ "`checkpoint_during` is deprecated and will be removed in a future version. Use `durability` instead.",
5304
+ DeprecationWarning,
5305
+ stacklevel=2,
5306
+ )
5140
5307
  payload = {
5141
5308
  "input": input,
5142
5309
  "command": (
@@ -5159,6 +5326,7 @@ class SyncRunsClient:
5159
5326
  "if_not_exists": if_not_exists,
5160
5327
  "on_completion": on_completion,
5161
5328
  "after_seconds": after_seconds,
5329
+ "durability": durability,
5162
5330
  }
5163
5331
  payload = {k: v for k, v in payload.items() if v is not None}
5164
5332
 
@@ -5254,7 +5422,7 @@ class SyncRunsClient:
5254
5422
  metadata: Mapping[str, Any] | None = None,
5255
5423
  config: Config | None = None,
5256
5424
  context: Context | None = None,
5257
- checkpoint_during: bool | None = None,
5425
+ checkpoint_during: bool | None = None, # deprecated
5258
5426
  checkpoint: Checkpoint | None = None,
5259
5427
  checkpoint_id: str | None = None,
5260
5428
  interrupt_before: All | Sequence[str] | None = None,
@@ -5269,6 +5437,7 @@ class SyncRunsClient:
5269
5437
  headers: Mapping[str, str] | None = None,
5270
5438
  params: QueryParamTypes | None = None,
5271
5439
  on_run_created: Callable[[RunCreateMetadata], None] | None = None,
5440
+ durability: Durability | None = None,
5272
5441
  ) -> list[dict] | dict[str, Any]:
5273
5442
  """Create a run, wait until it finishes and return the final state.
5274
5443
 
@@ -5284,7 +5453,7 @@ class SyncRunsClient:
5284
5453
  context: Static context to add to the assistant.
5285
5454
  !!! version-added "Supported with langgraph>=0.6.0"
5286
5455
  checkpoint: The checkpoint to resume from.
5287
- checkpoint_during: Whether to checkpoint during the run (or only at the end/interruption).
5456
+ checkpoint_during: (deprecated) Whether to checkpoint during the run (or only at the end/interruption).
5288
5457
  interrupt_before: Nodes to interrupt immediately before they get executed.
5289
5458
  interrupt_after: Nodes to Nodes to interrupt immediately after they get executed.
5290
5459
  webhook: Webhook to call after LangGraph API call is done.
@@ -5301,6 +5470,10 @@ class SyncRunsClient:
5301
5470
  raise_error: Whether to raise an error if the run fails.
5302
5471
  headers: Optional custom headers to include with the request.
5303
5472
  on_run_created: Optional callback to call when a run is created.
5473
+ durability: The durability to use for the run. Values are "sync", "async", or "exit".
5474
+ "async" means checkpoints are persisted async while next graph step executes, replaces checkpoint_during=True
5475
+ "sync" means checkpoints are persisted sync after graph step executes, replaces checkpoint_during=False
5476
+ "exit" means checkpoints are only persisted when the run exits, does not save intermediate steps
5304
5477
 
5305
5478
  Returns:
5306
5479
  Union[list[dict], dict[str, Any]]: The output of the run.
@@ -5355,6 +5528,12 @@ class SyncRunsClient:
5355
5528
  ```
5356
5529
 
5357
5530
  """ # noqa: E501
5531
+ if checkpoint_during is not None:
5532
+ warnings.warn(
5533
+ "`checkpoint_during` is deprecated and will be removed in a future version. Use `durability` instead.",
5534
+ DeprecationWarning,
5535
+ stacklevel=2,
5536
+ )
5358
5537
  payload = {
5359
5538
  "input": input,
5360
5539
  "command": (
@@ -5376,6 +5555,7 @@ class SyncRunsClient:
5376
5555
  "on_completion": on_completion,
5377
5556
  "after_seconds": after_seconds,
5378
5557
  "raise_error": raise_error,
5558
+ "durability": durability,
5379
5559
  }
5380
5560
 
5381
5561
  def on_response(res: httpx.Response):
@@ -38,6 +38,14 @@ Represents the status of a thread:
38
38
  - "error": An exception occurred during task processing.
39
39
  """
40
40
 
41
+ ThreadStreamMode = Literal["run_modes", "lifecycle", "state_update"]
42
+ """
43
+ Defines the mode of streaming:
44
+ - "run_modes": Stream the same events as the runs on thread, as well as run_done events.
45
+ - "lifecycle": Stream only run start/end events.
46
+ - "state_update": Stream state updates on the thread.
47
+ """
48
+
41
49
  StreamMode = Literal[
42
50
  "values",
43
51
  "messages",
@@ -91,6 +99,12 @@ Defines action after completion:
91
99
  - "keep": Retain resources after completion.
92
100
  """
93
101
 
102
+ Durability = Literal["sync", "async", "exit"]
103
+ """Durability mode for the graph execution.
104
+ - `"sync"`: Changes are persisted synchronously before the next step starts.
105
+ - `"async"`: Changes are persisted asynchronously while the next step executes.
106
+ - `"exit"`: Changes are persisted only when the graph exits."""
107
+
94
108
  All = Literal["*"]
95
109
  """Represents a wildcard or 'all' selector."""
96
110
 
File without changes
File without changes
File without changes
File without changes
File without changes