langgraph-api 0.2.86__py3-none-any.whl → 0.2.88__py3-none-any.whl

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.

Potentially problematic release.


This version of langgraph-api might be problematic. Click here for more details.

langgraph_api/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.2.86"
1
+ __version__ = "0.2.88"
@@ -14,7 +14,6 @@ from langgraph_api.config import (
14
14
  LANGSMITH_AUTH_VERIFY_TENANT_ID,
15
15
  LANGSMITH_TENANT_ID,
16
16
  )
17
- from langgraph_api.utils.cache import LRUCache
18
17
 
19
18
 
20
19
  class AuthDict(TypedDict):
@@ -31,6 +30,8 @@ class AuthCacheEntry(TypedDict):
31
30
 
32
31
  class LangsmithAuthBackend(AuthenticationBackend):
33
32
  def __init__(self):
33
+ from langgraph_api.utils.cache import LRUCache
34
+
34
35
  self._cache = LRUCache[AuthCacheEntry](max_size=1000, ttl=60)
35
36
 
36
37
  def _get_cache_key(self, headers):
langgraph_api/config.py CHANGED
@@ -6,6 +6,8 @@ import orjson
6
6
  from starlette.config import Config, undefined
7
7
  from starlette.datastructures import CommaSeparatedStrings
8
8
 
9
+ from langgraph_api import traceblock
10
+
9
11
  # types
10
12
 
11
13
 
@@ -372,3 +374,5 @@ if not os.getenv("LANGCHAIN_REVISION_ID") and (
372
374
  # This is respected by the langsmith SDK env inference
373
375
  # https://github.com/langchain-ai/langsmith-sdk/blob/1b93e4c13b8369d92db891ae3babc3e2254f0e56/python/langsmith/env/_runtime_env.py#L190
374
376
  os.environ["LANGCHAIN_REVISION_ID"] = ref_sha
377
+
378
+ traceblock.patch_requests()
@@ -56,6 +56,7 @@ import {
56
56
  getStaticGraphSchema,
57
57
  } from "@langchain/langgraph-api/schema";
58
58
  import { filterValidExportPath } from "./src/utils/files.mts";
59
+ import { patchFetch } from "./traceblock.mts";
59
60
 
60
61
  const logger = createLogger({
61
62
  level: "debug",
@@ -1114,6 +1115,6 @@ async function getNodesExecutedRequest(
1114
1115
  nodesExecuted = 0;
1115
1116
  return { nodesExecuted: value };
1116
1117
  }
1117
-
1118
+ patchFetch();
1118
1119
  asyncExitHook(() => awaitAllCallbacks(), { wait: 3_000 });
1119
1120
  main();
@@ -0,0 +1,25 @@
1
+ import { overrideFetchImplementation } from "langsmith";
2
+
3
+ const RUNS_RE = /^https:\/\/api\.smith\.langchain\.com\/.*runs(\/|$)/i;
4
+
5
+ export function patchFetch() {
6
+ const shouldBlock =
7
+ typeof process !== "undefined" &&
8
+ !!(process.env && process.env.LANGSMITH_DISABLE_SAAS_RUNS === "true");
9
+
10
+ if (shouldBlock) {
11
+ overrideFetchImplementation(
12
+ async (input: RequestInfo, init?: RequestInit) => {
13
+ const req = input instanceof Request ? input : new Request(input, init);
14
+
15
+ if (req.method.toUpperCase() === "POST" && RUNS_RE.test(req.url)) {
16
+ throw new Error(
17
+ `Policy-blocked POST to ${new URL(req.url).pathname} — run tracking disabled`,
18
+ );
19
+ }
20
+
21
+ return fetch(req);
22
+ },
23
+ );
24
+ }
25
+ }
@@ -312,6 +312,7 @@ async def create_valid_run(
312
312
  after_seconds = payload.get("after_seconds", 0)
313
313
  configurable["__after_seconds__"] = after_seconds
314
314
  put_time_start = time.time()
315
+ if_not_exists = payload.get("if_not_exists", "reject")
315
316
  run_coro = Runs.put(
316
317
  conn,
317
318
  assistant_id,
@@ -337,7 +338,7 @@ async def create_valid_run(
337
338
  multitask_strategy=multitask_strategy,
338
339
  prevent_insert_if_inflight=prevent_insert_if_inflight,
339
340
  after_seconds=after_seconds,
340
- if_not_exists=payload.get("if_not_exists", "reject"),
341
+ if_not_exists=if_not_exists,
341
342
  )
342
343
  run_ = await run_coro
343
344
 
@@ -364,7 +365,7 @@ async def create_valid_run(
364
365
  stream_mode=stream_mode,
365
366
  temporary=temporary,
366
367
  after_seconds=after_seconds,
367
- if_not_exists=payload.get("if_not_exists", "reject"),
368
+ if_not_exists=if_not_exists,
368
369
  run_create_ms=(
369
370
  int(time.time() * 1_000) - request_start_time
370
371
  if request_start_time
@@ -0,0 +1,22 @@
1
+ import os
2
+ from urllib.parse import urlparse
3
+
4
+ from requests.sessions import Session
5
+
6
+ _HOST = "api.smith.langchain.com"
7
+ _PATH_PREFIX = "/runs"
8
+
9
+
10
+ def patch_requests():
11
+ if os.getenv("LANGSMITH_DISABLE_SAAS_RUNS") != "true":
12
+ return
13
+ _orig = Session.request
14
+
15
+ def _guard(self, method, url, *a, **kw):
16
+ if method.upper() == "POST":
17
+ u = urlparse(url)
18
+ if u.hostname == _HOST and _PATH_PREFIX in u.path:
19
+ raise RuntimeError(f"POST to {url} blocked by policy")
20
+ return _orig(self, method, url, *a, **kw)
21
+
22
+ Session.request = _guard
langgraph_api/worker.py CHANGED
@@ -113,6 +113,8 @@ async def worker(
113
113
  run_creation_ms=run_creation_ms,
114
114
  run_queue_ms=ms(run_started_at_dt, run["created_at"]),
115
115
  run_stream_start_ms=ms(run_stream_started_at_dt, run_started_at_dt),
116
+ temporary=temporary,
117
+ resumable=resumable,
116
118
  )
117
119
 
118
120
  def on_checkpoint(checkpoint_arg: CheckpointPayload):
@@ -242,47 +244,55 @@ async def worker(
242
244
  run_id=str(run_id),
243
245
  run_attempt=attempt,
244
246
  )
245
- await Threads.set_joint_status(
246
- conn, run["thread_id"], run_id, status, checkpoint=checkpoint
247
- )
247
+ if not temporary:
248
+ await Threads.set_joint_status(
249
+ conn, run["thread_id"], run_id, status, checkpoint=checkpoint
250
+ )
248
251
  elif isinstance(exception, TimeoutError):
249
252
  status = "timeout"
250
253
  await logger.awarning(
251
254
  "Background run timed out",
252
255
  **log_info,
253
256
  )
254
- await Threads.set_joint_status(
255
- conn, run["thread_id"], run_id, status, checkpoint=checkpoint
256
- )
257
- elif isinstance(exception, UserRollback):
258
- status = "rollback"
259
- try:
257
+ if not temporary:
260
258
  await Threads.set_joint_status(
261
259
  conn, run["thread_id"], run_id, status, checkpoint=checkpoint
262
260
  )
263
- await logger.ainfo(
264
- "Background run rolled back",
265
- **log_info,
266
- )
267
- except HTTPException as e:
268
- if e.status_code == 404:
261
+ elif isinstance(exception, UserRollback):
262
+ status = "rollback"
263
+ if not temporary:
264
+ try:
265
+ await Threads.set_joint_status(
266
+ conn,
267
+ run["thread_id"],
268
+ run_id,
269
+ status,
270
+ checkpoint=checkpoint,
271
+ )
269
272
  await logger.ainfo(
270
- "Ignoring rollback error for missing run",
273
+ "Background run rolled back",
271
274
  **log_info,
272
275
  )
273
- else:
274
- raise
275
-
276
- checkpoint = None # reset the checkpoint
276
+ except HTTPException as e:
277
+ if e.status_code == 404:
278
+ await logger.ainfo(
279
+ "Ignoring rollback error for missing run",
280
+ **log_info,
281
+ )
282
+ else:
283
+ raise
284
+
285
+ checkpoint = None # reset the checkpoint
277
286
  elif isinstance(exception, UserInterrupt):
278
287
  status = "interrupted"
279
288
  await logger.ainfo(
280
289
  "Background run interrupted",
281
290
  **log_info,
282
291
  )
283
- await Threads.set_joint_status(
284
- conn, run["thread_id"], run_id, status, checkpoint, exception
285
- )
292
+ if not temporary:
293
+ await Threads.set_joint_status(
294
+ conn, run["thread_id"], run_id, status, checkpoint, exception
295
+ )
286
296
  elif isinstance(exception, ALL_RETRIABLE_EXCEPTIONS):
287
297
  status = "retry"
288
298
  await logger.awarning(
@@ -290,6 +300,7 @@ async def worker(
290
300
  **log_info,
291
301
  )
292
302
  # Don't update thread status yet.
303
+ # Apply this even for temporary runs, so we retry
293
304
  await Runs.set_status(conn, run_id, "pending")
294
305
  else:
295
306
  status = "error"
@@ -303,13 +314,14 @@ async def worker(
303
314
  exc_info=not isinstance(exception, RemoteException),
304
315
  **log_info,
305
316
  )
306
- await Threads.set_joint_status(
307
- conn, run["thread_id"], run_id, status, checkpoint, exception
308
- )
317
+ if not temporary:
318
+ await Threads.set_joint_status(
319
+ conn, run["thread_id"], run_id, status, checkpoint, exception
320
+ )
309
321
 
310
322
  # delete thread if it's temporary and we don't want to retry
311
323
  if temporary and not isinstance(exception, ALL_RETRIABLE_EXCEPTIONS):
312
- await Threads.delete(conn, run["thread_id"])
324
+ await Threads._delete_with_run(conn, run["thread_id"], run_id)
313
325
 
314
326
  if isinstance(exception, ALL_RETRIABLE_EXCEPTIONS):
315
327
  await logger.awarning("RETRYING", exc_info=exception)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langgraph-api
3
- Version: 0.2.86
3
+ Version: 0.2.88
4
4
  Author-email: Nuno Campos <nuno@langchain.dev>, Will Fu-Hinthorn <will@langchain.dev>
5
5
  License: Elastic-2.0
6
6
  License-File: LICENSE
@@ -11,7 +11,7 @@ Requires-Dist: httpx>=0.25.0
11
11
  Requires-Dist: jsonschema-rs<0.30,>=0.20.0
12
12
  Requires-Dist: langchain-core>=0.3.64
13
13
  Requires-Dist: langgraph-checkpoint>=2.0.23
14
- Requires-Dist: langgraph-runtime-inmem<0.4,>=0.3.0
14
+ Requires-Dist: langgraph-runtime-inmem<0.5,>=0.4.0
15
15
  Requires-Dist: langgraph-sdk>=0.1.71
16
16
  Requires-Dist: langgraph>=0.3.27
17
17
  Requires-Dist: langsmith>=0.3.45
@@ -1,9 +1,9 @@
1
- langgraph_api/__init__.py,sha256=UX0NFs_UycABtPhNbHs9Deehd2GdHX9DySKa6T9arUg,23
1
+ langgraph_api/__init__.py,sha256=KyVs-sgwv8HkCGWN0INHw_LVAcgAVeJmhhH4gGNJ3Ew,23
2
2
  langgraph_api/asgi_transport.py,sha256=eqifhHxNnxvI7jJqrY1_8RjL4Fp9NdN4prEub2FWBt8,5091
3
3
  langgraph_api/asyncio.py,sha256=qrYEqPRrqtGq7E7KjcMC-ALyN79HkRnmp9rM2TAw9L8,9404
4
4
  langgraph_api/cli.py,sha256=-R0fvxg4KNxTkSe7xvDZruF24UMhStJYjpAYlUx3PBk,16018
5
5
  langgraph_api/command.py,sha256=3O9v3i0OPa96ARyJ_oJbLXkfO8rPgDhLCswgO9koTFA,768
6
- langgraph_api/config.py,sha256=j4nohZGUGybr36BtuM72K1phOQjUBEx6_2h77BB78Vs,11822
6
+ langgraph_api/config.py,sha256=MbsxCitbxI7EQgP7UfSv_MpdYyfQEyKIP1ILYr-MhzU,11889
7
7
  langgraph_api/cron_scheduler.py,sha256=CiwZ-U4gDOdG9zl9dlr7mH50USUgNB2Fvb8YTKVRBN4,2625
8
8
  langgraph_api/errors.py,sha256=zlnl3xXIwVG0oGNKKpXf1an9Rn_SBDHSyhe53hU6aLw,1858
9
9
  langgraph_api/graph.py,sha256=pw_3jVZNe0stO5-Y8kLUuC8EJ5tFqdLu9fLpwUz4Hc4,23574
@@ -22,10 +22,11 @@ langgraph_api/state.py,sha256=NLl5YgLKppHJ7zfF0bXjsroXmIGCZez0IlDAKNGVy0g,2365
22
22
  langgraph_api/store.py,sha256=srRI0fQXNFo_RSUs4apucr4BEp_KrIseJksZXs32MlQ,4635
23
23
  langgraph_api/stream.py,sha256=EorM9BD7oiCvkRXlMqnOkBd9P1X3mEagS_oHp-_9aRQ,13669
24
24
  langgraph_api/thread_ttl.py,sha256=-Ox8NFHqUH3wGNdEKMIfAXUubY5WGifIgCaJ7npqLgw,1762
25
+ langgraph_api/traceblock.py,sha256=2aWS6TKGTcQ0G1fOtnjVrzkpeGvDsR0spDbfddEqgRU,594
25
26
  langgraph_api/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
27
  langgraph_api/validation.py,sha256=zMuKmwUEBjBgFMwAaeLZmatwGVijKv2sOYtYg7gfRtc,4950
27
28
  langgraph_api/webhook.py,sha256=VCJp4dI5E1oSJ15XP34cnPiOi8Ya8Q1BnBwVGadOpLI,1636
28
- langgraph_api/worker.py,sha256=HHgdwq79gBLFLiIwaFap_TmBigIu3Tfno_SwsjdyjGU,13675
29
+ langgraph_api/worker.py,sha256=Zy6rHfcOoYg7FLui3KDMDMllslXFfjZ3z9uCgae-uMo,14216
29
30
  langgraph_api/api/__init__.py,sha256=WHy6oNLWtH1K7AxmmsU9RD-Vm6WP-Ov16xS8Ey9YCmQ,6090
30
31
  langgraph_api/api/assistants.py,sha256=w7nXjEknDVHSuP228S8ZLh4bG0nRGnSwVP9pECQOK90,16247
31
32
  langgraph_api/api/mcp.py,sha256=qe10ZRMN3f-Hli-9TI8nbQyWvMeBb72YB1PZVbyqBQw,14418
@@ -41,7 +42,7 @@ langgraph_api/auth/middleware.py,sha256=jDA4t41DUoAArEY_PNoXesIUBJ0nGhh85QzRdn5E
41
42
  langgraph_api/auth/noop.py,sha256=Bk6Nf3p8D_iMVy_OyfPlyiJp_aEwzL-sHrbxoXpCbac,586
42
43
  langgraph_api/auth/studio_user.py,sha256=fojJpexdIZYI1w3awiqOLSwMUiK_M_3p4mlfQI0o-BE,454
43
44
  langgraph_api/auth/langsmith/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
- langgraph_api/auth/langsmith/backend.py,sha256=bmTbbb4UGfO244sDRStxdB78IdQCJuX08Rhs3Bl7iag,3608
45
+ langgraph_api/auth/langsmith/backend.py,sha256=jRD9WL7OhxnUurMt7v1vziIUwpzkE1hR-xmRaRQmpvw,3617
45
46
  langgraph_api/auth/langsmith/client.py,sha256=eKchvAom7hdkUXauD8vHNceBDDUijrFgdTV8bKd7x4Q,3998
46
47
  langgraph_api/js/.gitignore,sha256=l5yI6G_V6F1600I1IjiUKn87f4uYIrBAYU1MOyBBhg4,59
47
48
  langgraph_api/js/.prettierrc,sha256=0es3ovvyNIqIw81rPQsdt1zCQcOdBqyR_DMbFE4Ifms,19
@@ -49,13 +50,14 @@ langgraph_api/js/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
49
50
  langgraph_api/js/base.py,sha256=gjY6K8avI03OrI-Hy6a311fQ_EG5r_x8hUYlc7uqxdE,534
50
51
  langgraph_api/js/build.mts,sha256=bRQo11cglDFXlLN7Y48CQPTSMLenp7MqIWuP1DkSIo0,3139
51
52
  langgraph_api/js/client.http.mts,sha256=AGA-p8J85IcNh2oXZjDxHQ4PnQdJmt-LPcpZp6j0Cws,4687
52
- langgraph_api/js/client.mts,sha256=N9CTH7mbXGSD-gpv-XyruYsHI-rgrObL8cQoAp5s3_U,30986
53
+ langgraph_api/js/client.mts,sha256=Lyug2cIhW6hlxSaxZV_7KPe1aBLQ47oijbqL26joTT8,31046
53
54
  langgraph_api/js/errors.py,sha256=Cm1TKWlUCwZReDC5AQ6SgNIVGD27Qov2xcgHyf8-GXo,361
54
55
  langgraph_api/js/global.d.ts,sha256=j4GhgtQSZ5_cHzjSPcHgMJ8tfBThxrH-pUOrrJGteOU,196
55
56
  langgraph_api/js/package.json,sha256=BpNAO88mbE-Gv4WzQfj1TLktCWGqm6XBqI892ObuOUw,1333
56
57
  langgraph_api/js/remote.py,sha256=B_0cP34AGTW9rL_hJyKIh3P6Z4TvNYNNyc7S2_SOWt4,36880
57
58
  langgraph_api/js/schema.py,sha256=7idnv7URlYUdSNMBXQcw7E4SxaPxCq_Oxwnlml8q5ik,408
58
59
  langgraph_api/js/sse.py,sha256=lsfp4nyJyA1COmlKG9e2gJnTttf_HGCB5wyH8OZBER8,4105
60
+ langgraph_api/js/traceblock.mts,sha256=QtGSN5VpzmGqDfbArrGXkMiONY94pMQ5CgzetT_bKYg,761
59
61
  langgraph_api/js/tsconfig.json,sha256=imCYqVnqFpaBoZPx8k1nO4slHIWBFsSlmCYhO73cpBs,341
60
62
  langgraph_api/js/ui.py,sha256=XNT8iBcyT8XmbIqSQUWd-j_00HsaWB2vRTVabwFBkik,2439
61
63
  langgraph_api/js/yarn.lock,sha256=hrU_DP2qU9772d2W-FiuA5N7z2eAp6qmkw7dDCAEYhw,85562
@@ -71,7 +73,7 @@ langgraph_api/middleware/http_logger.py,sha256=uroMCag49-uPHTt8K3glkl-0RnWL20YEg
71
73
  langgraph_api/middleware/private_network.py,sha256=eYgdyU8AzU2XJu362i1L8aSFoQRiV7_aLBPw7_EgeqI,2111
72
74
  langgraph_api/middleware/request_id.py,sha256=SDj3Yi3WvTbFQ2ewrPQBjAV8sYReOJGeIiuoHeZpR9g,1242
73
75
  langgraph_api/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
- langgraph_api/models/run.py,sha256=j1s9KRfFXgjKUudB9z7IVJ34Klo85PPeaVFtmWHhEdo,14514
76
+ langgraph_api/models/run.py,sha256=AAeny3Pjhkw6RCcV5fri8GWjH4Vcy522dLbki6Qbzxo,14523
75
77
  langgraph_api/tunneling/cloudflare.py,sha256=iKb6tj-VWPlDchHFjuQyep2Dpb-w2NGfJKt-WJG9LH0,3650
76
78
  langgraph_api/utils/__init__.py,sha256=92mSti9GfGdMRRWyESKQW5yV-75Z9icGHnIrBYvdypU,3619
77
79
  langgraph_api/utils/cache.py,sha256=SrtIWYibbrNeZzLXLUGBFhJPkMVNQnVxR5giiYGHEfI,1810
@@ -91,8 +93,8 @@ langgraph_runtime/store.py,sha256=7mowndlsIroGHv3NpTSOZDJR0lCuaYMBoTnTrewjslw,11
91
93
  LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
92
94
  logging.json,sha256=3RNjSADZmDq38eHePMm1CbP6qZ71AmpBtLwCmKU9Zgo,379
93
95
  openapi.json,sha256=p5tn_cNRiFA0HN3L6JfC9Nm16Hgv-BxvAQcJymKhVWI,143296
94
- langgraph_api-0.2.86.dist-info/METADATA,sha256=kYoKk78nUSCT6BKYrjpYPBGF7GFFNODJLvxx6wToGD8,3891
95
- langgraph_api-0.2.86.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
96
- langgraph_api-0.2.86.dist-info/entry_points.txt,sha256=hGedv8n7cgi41PypMfinwS_HfCwA7xJIfS0jAp8htV8,78
97
- langgraph_api-0.2.86.dist-info/licenses/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
98
- langgraph_api-0.2.86.dist-info/RECORD,,
96
+ langgraph_api-0.2.88.dist-info/METADATA,sha256=EdGed7laJc9m3yltzlxMbMad-sxWqC53jdF_qsdZH4E,3891
97
+ langgraph_api-0.2.88.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
98
+ langgraph_api-0.2.88.dist-info/entry_points.txt,sha256=hGedv8n7cgi41PypMfinwS_HfCwA7xJIfS0jAp8htV8,78
99
+ langgraph_api-0.2.88.dist-info/licenses/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
100
+ langgraph_api-0.2.88.dist-info/RECORD,,