langgraph-api 0.2.126__py3-none-any.whl → 0.2.128__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.126"
1
+ __version__ = "0.2.128"
@@ -275,6 +275,13 @@ async def create_valid_run(
275
275
  config = payload.get("config") or {}
276
276
  context = payload.get("context") or {}
277
277
  configurable = config.setdefault("configurable", {})
278
+
279
+ if configurable and context:
280
+ raise HTTPException(
281
+ status_code=400,
282
+ detail="Cannot specify both configurable and context. Prefer setting context alone. Context was introduced in LangGraph 0.6.0 and is the long term planned replacement for configurable.",
283
+ )
284
+
278
285
  if checkpoint_id:
279
286
  configurable["checkpoint_id"] = str(checkpoint_id)
280
287
  if checkpoint := payload.get("checkpoint"):
@@ -300,6 +307,12 @@ async def create_valid_run(
300
307
  configurable["__after_seconds__"] = after_seconds
301
308
  put_time_start = time.time()
302
309
  if_not_exists = payload.get("if_not_exists", "reject")
310
+
311
+ # Keep config and context in sync
312
+ # Configurable is either A) just internal config or B) internal config + user config (and context is empty). Either way, configurable is the default.
313
+ context = {**context, **configurable}
314
+ config["configurable"] = context
315
+
303
316
  run_coro = Runs.put(
304
317
  conn,
305
318
  assistant_id,
langgraph_api/stream.py CHANGED
@@ -348,7 +348,17 @@ async def astream_state(
348
348
  yield "feedback", feedback_urls
349
349
 
350
350
 
351
- async def consume(stream: AnyStream, run_id: str, resumable: bool = False) -> None:
351
+ async def consume(
352
+ stream: AnyStream,
353
+ run_id: str,
354
+ resumable: bool = False,
355
+ stream_modes: set[StreamMode] | None = None,
356
+ ) -> None:
357
+ stream_modes = stream_modes or set()
358
+ if "messages-tuple" in stream_modes:
359
+ stream_modes.add("messages")
360
+ stream_modes.add("metadata")
361
+
352
362
  async with aclosing(stream):
353
363
  try:
354
364
  async for mode, payload in stream:
@@ -356,7 +366,7 @@ async def consume(stream: AnyStream, run_id: str, resumable: bool = False) -> No
356
366
  run_id,
357
367
  mode,
358
368
  await run_in_executor(None, json_dumpb, payload),
359
- resumable=resumable,
369
+ resumable=resumable and mode.split("|")[0] in stream_modes,
360
370
  )
361
371
  except Exception as e:
362
372
  if isinstance(e, ExceptionGroup):
@@ -365,7 +375,6 @@ async def consume(stream: AnyStream, run_id: str, resumable: bool = False) -> No
365
375
  run_id,
366
376
  "error",
367
377
  await run_in_executor(None, json_dumpb, e),
368
- resumable=resumable,
369
378
  )
370
379
  raise e
371
380
 
langgraph_api/worker.py CHANGED
@@ -20,7 +20,7 @@ from langgraph_api.config import (
20
20
  from langgraph_api.errors import UserInterrupt, UserRollback, UserTimeout
21
21
  from langgraph_api.js.errors import RemoteException
22
22
  from langgraph_api.metadata import incr_runs
23
- from langgraph_api.schema import Run
23
+ from langgraph_api.schema import Run, StreamMode
24
24
  from langgraph_api.state import state_snapshot_to_thread_state
25
25
  from langgraph_api.stream import AnyStream, astream_state, consume
26
26
  from langgraph_api.utils import with_user
@@ -54,6 +54,7 @@ async def set_auth_ctx_for_run(
54
54
  user = normalize_user(user)
55
55
  # Reapply normalization to the kwargs
56
56
  run_kwargs["config"]["configurable"]["langgraph_auth_user"] = user
57
+ run_kwargs["context"]["langgraph_auth_user"] = user
57
58
  except Exception:
58
59
  user = SimpleUser(user_id) if user_id is not None else None
59
60
  permissions = None
@@ -130,9 +131,11 @@ async def worker(
130
131
  break
131
132
 
132
133
  # Wrap the graph execution to separate user errors from server errors
133
- async def wrap_user_errors(stream: AnyStream, run_id: str, resumable: bool):
134
+ async def wrap_user_errors(
135
+ stream: AnyStream, run_id: str, resumable: bool, stream_modes: set[StreamMode]
136
+ ):
134
137
  try:
135
- await consume(stream, run_id, resumable)
138
+ await consume(stream, run_id, resumable, stream_modes)
136
139
  except Exception as e:
137
140
  if not isinstance(e, UserRollback | UserInterrupt):
138
141
  logger.error(
@@ -184,8 +187,11 @@ async def worker(
184
187
  on_checkpoint=on_checkpoint,
185
188
  on_task_result=on_task_result,
186
189
  )
190
+ stream_modes: set[StreamMode] = set(
191
+ run["kwargs"].get("stream_mode", [])
192
+ )
187
193
  await asyncio.wait_for(
188
- wrap_user_errors(stream, run_id, resumable),
194
+ wrap_user_errors(stream, run_id, resumable, stream_modes),
189
195
  BG_JOB_TIMEOUT_SECS,
190
196
  )
191
197
  except (Exception, asyncio.CancelledError) as ee:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langgraph-api
3
- Version: 0.2.126
3
+ Version: 0.2.128
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
@@ -1,4 +1,4 @@
1
- langgraph_api/__init__.py,sha256=MJXz1iIiYzSsVkIx-r66BL7rUK8vsMX6Q89086HsRSU,24
1
+ langgraph_api/__init__.py,sha256=mxT2nps5QgA-B4fLdRmfWEWc4sx0YKxh3Dl4H6yEbUQ,24
2
2
  langgraph_api/asgi_transport.py,sha256=eqifhHxNnxvI7jJqrY1_8RjL4Fp9NdN4prEub2FWBt8,5091
3
3
  langgraph_api/asyncio.py,sha256=Wv4Rwm-a-Cf6JpfgJmVuVlXQ7SlwrjbTn0eq1ux8I2Q,9652
4
4
  langgraph_api/cli.py,sha256=xQojITwmmKSJw48Lr2regcnRPRq2FJqWlPpeyr5TgbU,16158
@@ -21,13 +21,13 @@ langgraph_api/server.py,sha256=KBnMFt3f9RVLVu_NqyeRc13D_Lq62Rk_2czZKEUMU5E,6994
21
21
  langgraph_api/sse.py,sha256=SLdtZmTdh5D8fbWrQjuY9HYLd2dg8Rmi6ZMmFMVc2iE,4204
22
22
  langgraph_api/state.py,sha256=P2mCo-0bqPu2v9FSFGJtUCjPPNvv6wLUKQh8SdxAtc8,4387
23
23
  langgraph_api/store.py,sha256=srRI0fQXNFo_RSUs4apucr4BEp_KrIseJksZXs32MlQ,4635
24
- langgraph_api/stream.py,sha256=RvO0mYEzU7XTSQz2PDvj3KzMO_T2Hpmsbwff0GoRDmI,15741
24
+ langgraph_api/stream.py,sha256=tZfwOvG-wQNURdfQ_chfUO93JGZYc8iShlkbgukrQhY,15960
25
25
  langgraph_api/thread_ttl.py,sha256=7H3gFlWcUiODPoaEzcwB0LR61uvcuyjD0ew_4BztB7k,1902
26
26
  langgraph_api/traceblock.py,sha256=2aWS6TKGTcQ0G1fOtnjVrzkpeGvDsR0spDbfddEqgRU,594
27
27
  langgraph_api/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  langgraph_api/validation.py,sha256=zMuKmwUEBjBgFMwAaeLZmatwGVijKv2sOYtYg7gfRtc,4950
29
29
  langgraph_api/webhook.py,sha256=VCJp4dI5E1oSJ15XP34cnPiOi8Ya8Q1BnBwVGadOpLI,1636
30
- langgraph_api/worker.py,sha256=LVvjvigurlDgpNjFcbAvRH7744fE01Lirrg2ZlHtORE,14245
30
+ langgraph_api/worker.py,sha256=psxipp6bFlJrN5erGKV7D1wm2olrfggPvMqKoWk7SE4,14518
31
31
  langgraph_api/api/__init__.py,sha256=WHy6oNLWtH1K7AxmmsU9RD-Vm6WP-Ov16xS8Ey9YCmQ,6090
32
32
  langgraph_api/api/assistants.py,sha256=ecHaID71ReTAZF4qsJzDe5L-2T5iOL2v8p6kQVHLKFk,16009
33
33
  langgraph_api/api/mcp.py,sha256=qe10ZRMN3f-Hli-9TI8nbQyWvMeBb72YB1PZVbyqBQw,14418
@@ -74,7 +74,7 @@ langgraph_api/middleware/http_logger.py,sha256=tUdWuIKtDa2EkFtG_kCjw1Wkgv7gbGH3h
74
74
  langgraph_api/middleware/private_network.py,sha256=eYgdyU8AzU2XJu362i1L8aSFoQRiV7_aLBPw7_EgeqI,2111
75
75
  langgraph_api/middleware/request_id.py,sha256=SDj3Yi3WvTbFQ2ewrPQBjAV8sYReOJGeIiuoHeZpR9g,1242
76
76
  langgraph_api/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
77
- langgraph_api/models/run.py,sha256=Yn1VuAAzxLMb9akOw8mLMWgx2cxPhJiIZ4-lYe75guQ,14808
77
+ langgraph_api/models/run.py,sha256=UmkZm9IL_ET3QNA8xVPFHTAcXXZ4htQDMQuPKzaWKPA,15383
78
78
  langgraph_api/tunneling/cloudflare.py,sha256=iKb6tj-VWPlDchHFjuQyep2Dpb-w2NGfJKt-WJG9LH0,3650
79
79
  langgraph_api/utils/__init__.py,sha256=EQu0PShwHhxUI_9mDFgqlAf5_y5bX8TEk723P5iby24,4161
80
80
  langgraph_api/utils/cache.py,sha256=SrtIWYibbrNeZzLXLUGBFhJPkMVNQnVxR5giiYGHEfI,1810
@@ -95,8 +95,8 @@ langgraph_runtime/store.py,sha256=7mowndlsIroGHv3NpTSOZDJR0lCuaYMBoTnTrewjslw,11
95
95
  LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
96
96
  logging.json,sha256=3RNjSADZmDq38eHePMm1CbP6qZ71AmpBtLwCmKU9Zgo,379
97
97
  openapi.json,sha256=SPCrzYpta2xTl-WE2W6qwosYdQqLeB8qpzaYEbcK44k,150725
98
- langgraph_api-0.2.126.dist-info/METADATA,sha256=2nFffECkS7whKzQeFOf4N-BWWgyRgAbKq1VVLqDIIA4,3890
99
- langgraph_api-0.2.126.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
100
- langgraph_api-0.2.126.dist-info/entry_points.txt,sha256=hGedv8n7cgi41PypMfinwS_HfCwA7xJIfS0jAp8htV8,78
101
- langgraph_api-0.2.126.dist-info/licenses/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
102
- langgraph_api-0.2.126.dist-info/RECORD,,
98
+ langgraph_api-0.2.128.dist-info/METADATA,sha256=1gOWC24pl8KN1ymA6h8ONc4DhnTkFWH-fLf5ILi6Oo4,3890
99
+ langgraph_api-0.2.128.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
100
+ langgraph_api-0.2.128.dist-info/entry_points.txt,sha256=hGedv8n7cgi41PypMfinwS_HfCwA7xJIfS0jAp8htV8,78
101
+ langgraph_api-0.2.128.dist-info/licenses/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
102
+ langgraph_api-0.2.128.dist-info/RECORD,,