langgraph-api 0.2.42__py3-none-any.whl → 0.2.44__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.42"
1
+ __version__ = "0.2.44"
langgraph_api/config.py CHANGED
@@ -241,6 +241,9 @@ BG_JOB_ISOLATED_LOOPS = env("BG_JOB_ISOLATED_LOOPS", cast=bool, default=False)
241
241
  BG_JOB_SHUTDOWN_GRACE_PERIOD_SECS = env(
242
242
  "BG_JOB_SHUTDOWN_GRACE_PERIOD_SECS", cast=int, default=3600
243
243
  )
244
+ MAX_STREAM_CHUNK_SIZE_BYTES = env(
245
+ "MAX_STREAM_CHUNK_SIZE_BYTES", cast=int, default=1024 * 1024 * 128
246
+ )
244
247
 
245
248
 
246
249
  def _parse_thread_ttl(value: str | None) -> ThreadTTLConfig | None:
langgraph_api/logging.py CHANGED
@@ -81,23 +81,6 @@ class JSONRenderer:
81
81
  LEVELS = logging.getLevelNamesMapping()
82
82
 
83
83
 
84
- class TapForMetadata:
85
- def __call__(
86
- self, logger: logging.Logger, method_name: str, event_dict: EventDict
87
- ) -> str:
88
- """
89
- Tap WARN and above logs for metadata. Exclude user loggers.
90
- """
91
- if (
92
- event_dict["logger"].startswith("langgraph")
93
- and LEVELS[event_dict["level"].upper()] > LEVELS["INFO"]
94
- ):
95
- from langgraph_api.metadata import append_log
96
-
97
- append_log(event_dict.copy())
98
- return event_dict
99
-
100
-
101
84
  # shared config, for both logging and structlog
102
85
 
103
86
  shared_processors = [
@@ -136,7 +119,6 @@ class Formatter(structlog.stdlib.ProcessorFormatter):
136
119
  super().__init__(
137
120
  processors=[
138
121
  structlog.stdlib.ProcessorFormatter.remove_processors_meta,
139
- TapForMetadata(),
140
122
  renderer,
141
123
  ],
142
124
  foreign_pre_chain=shared_processors,
langgraph_api/metadata.py CHANGED
@@ -35,7 +35,6 @@ else:
35
35
  PLAN = "enterprise" if plus_features_enabled() else "developer"
36
36
  USER_API_URL = os.getenv("LANGGRAPH_API_URL", None)
37
37
 
38
- LOGS: list[dict] = []
39
38
  RUN_COUNTER = 0
40
39
  NODE_COUNTER = 0
41
40
  FROM_TIMESTAMP = datetime.now(UTC).isoformat()
@@ -59,14 +58,6 @@ def incr_nodes(_, *, incr: int = 1) -> None:
59
58
  NODE_COUNTER += incr
60
59
 
61
60
 
62
- def append_log(log: dict) -> None:
63
- if not LANGGRAPH_CLOUD_LICENSE_KEY and not LANGSMITH_API_KEY:
64
- return
65
-
66
- global LOGS
67
- LOGS.append(log)
68
-
69
-
70
61
  async def metadata_loop() -> None:
71
62
  try:
72
63
  from langgraph_api import __version__
@@ -91,8 +82,6 @@ async def metadata_loop() -> None:
91
82
  to_timestamp = datetime.now(UTC).isoformat()
92
83
  nodes = NODE_COUNTER
93
84
  runs = RUN_COUNTER
94
- logs = LOGS.copy()
95
- LOGS.clear()
96
85
  RUN_COUNTER = 0
97
86
  NODE_COUNTER = 0
98
87
  FROM_TIMESTAMP = to_timestamp
@@ -123,7 +112,7 @@ async def metadata_loop() -> None:
123
112
  "langgraph.platform.runs": runs,
124
113
  "langgraph.platform.nodes": nodes,
125
114
  },
126
- "logs": logs,
115
+ "logs": [],
127
116
  }
128
117
  try:
129
118
  await http_request(
langgraph_api/stream.py CHANGED
@@ -207,11 +207,16 @@ async def astream_state(
207
207
  elif "events" in stream_mode:
208
208
  yield "events", event
209
209
  else:
210
+ output_keys = kwargs.pop("output_keys", graph.output_channels)
210
211
  async with (
211
212
  stack,
212
213
  aclosing(
213
214
  graph.astream(
214
- input, config, stream_mode=list(stream_modes_set), **kwargs
215
+ input,
216
+ config,
217
+ stream_mode=list(stream_modes_set),
218
+ output_keys=output_keys,
219
+ **kwargs,
215
220
  )
216
221
  ) as stream,
217
222
  ):
langgraph_api/worker.py CHANGED
@@ -90,11 +90,11 @@ async def worker(
90
90
  if request_created_at is not None
91
91
  else None
92
92
  )
93
-
94
93
  async with (
95
94
  connect() as conn,
96
95
  set_auth_ctx_for_run(run["kwargs"]),
97
96
  Runs.enter(run_id, main_loop) as done,
97
+ AsyncExitStack() as exit_stack,
98
98
  ):
99
99
  temporary = run["kwargs"].get("temporary", False)
100
100
  resumable = run["kwargs"].get("resumable", False)
@@ -156,12 +156,10 @@ async def worker(
156
156
 
157
157
  raise RuntimeError(error_message)
158
158
  if temporary:
159
- stream = astream_state(
160
- AsyncExitStack(), conn, cast(Run, run), attempt, done
161
- )
159
+ stream = astream_state(exit_stack, conn, cast(Run, run), attempt, done)
162
160
  else:
163
161
  stream = astream_state(
164
- AsyncExitStack(),
162
+ exit_stack,
165
163
  conn,
166
164
  cast(Run, run),
167
165
  attempt,
@@ -216,6 +214,8 @@ async def worker(
216
214
  run_ended_at_dt = datetime.now(UTC)
217
215
  run_ended_at = run_ended_at_dt.isoformat()
218
216
  try:
217
+ # Need to close the pipeline to re-use the connection
218
+ await exit_stack.aclose()
219
219
  await Runs.delete(conn, run_id, thread_id=run["thread_id"])
220
220
  await logger.ainfo(
221
221
  "Background run rolled back",
@@ -240,9 +240,6 @@ async def worker(
240
240
  run_created_at=run_created_at,
241
241
  exc=str(e),
242
242
  )
243
- # We need to clean up the transaction early if we want to
244
- # update the thread status with the same connection
245
- await exit.aclose()
246
243
  except HTTPException as e:
247
244
  if e.status_code == 404:
248
245
  await logger.ainfo(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langgraph-api
3
- Version: 0.2.42
3
+ Version: 0.2.44
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,15 +1,15 @@
1
- langgraph_api/__init__.py,sha256=ZfPaHT9jrZeNvdPfDssvO9QlJXdREiFfpk5CG-mKeQQ,23
1
+ langgraph_api/__init__.py,sha256=U9IXTG0wwP5qkavLVbDEmAfwEJjO-1-R5e__z2cNpz0,23
2
2
  langgraph_api/asgi_transport.py,sha256=eqifhHxNnxvI7jJqrY1_8RjL4Fp9NdN4prEub2FWBt8,5091
3
3
  langgraph_api/asyncio.py,sha256=nelZwKL7iOjM5GHj1rVjiPE7igUIKLNKtc-3urxmlfo,9250
4
4
  langgraph_api/cli.py,sha256=9Ou3tGDDY_VVLt5DFle8UviJdpI4ZigC5hElYvq2-To,14519
5
5
  langgraph_api/command.py,sha256=3O9v3i0OPa96ARyJ_oJbLXkfO8rPgDhLCswgO9koTFA,768
6
- langgraph_api/config.py,sha256=DqINcyfxGD5gT0zH6XTZMpx_ujT3G5xmo74esfnqb_0,11007
6
+ langgraph_api/config.py,sha256=pFIZb4t2Vo7HbX0ZMjUNDR7Q7Bpj-stp_TmSmI026yo,11115
7
7
  langgraph_api/cron_scheduler.py,sha256=i87j4pJrcsmsqMKeKUs69gaAjrGaSM3pM3jnXdN5JDQ,2630
8
8
  langgraph_api/errors.py,sha256=Bu_i5drgNTyJcLiyrwVE_6-XrSU50BHf9TDpttki9wQ,1690
9
9
  langgraph_api/graph.py,sha256=MPm8DvInBQsq2em45c2YD5bW6T_G1LlDkAuWq-19gCQ,23240
10
10
  langgraph_api/http.py,sha256=gYbxxjY8aLnsXeJymcJ7G7Nj_yToOGpPYQqmZ1_ggfA,5240
11
- langgraph_api/logging.py,sha256=VJ-lPwHK6UY2ZcK8LQsYhu7h0zODfVov1laxzyujRcU,4490
12
- langgraph_api/metadata.py,sha256=ptaxwmzdx2bUBSc1KRhqgF-Xnm-Zh2gqwSiHpl8LD9c,4482
11
+ langgraph_api/logging.py,sha256=bx6kxV7O2FUnu0ubrgeJuj5q2EjYC4ve1BkbrVfzy28,3953
12
+ langgraph_api/metadata.py,sha256=2sz9ECnbnQtgqN6ptDkRmymaVKfQPgaX-JuDJDJB47c,4254
13
13
  langgraph_api/patch.py,sha256=Dgs0PXHytekX4SUL6KsjjN0hHcOtGLvv1GRGbh6PswU,1408
14
14
  langgraph_api/queue_entrypoint.py,sha256=_41ZveMDdn9bapjA7Ik9FG3r4hyIwXESUM5F1PdlieE,2309
15
15
  langgraph_api/route.py,sha256=4VBkJMeusfiZtLzyUaKm1HwLHTq0g15y2CRiRhM6xyA,4773
@@ -19,12 +19,12 @@ langgraph_api/server.py,sha256=Z_VL-kIphybTRDWBIqHMfRhgCmAFyTRqAGlgnHQF0Zg,6973
19
19
  langgraph_api/sse.py,sha256=F7swfjKBDrlUmXZ_dWuDVHtp-3o1Cpjq1lwp0bJD-nw,4223
20
20
  langgraph_api/state.py,sha256=8jx4IoTCOjTJuwzuXJKKFwo1VseHjNnw_CCq4x1SW14,2284
21
21
  langgraph_api/store.py,sha256=_xGhdwEIMoY1_hIy_oWwxZp4Y7FH833BNJfgFIhT80E,4640
22
- langgraph_api/stream.py,sha256=T1tkUZFr5KlgqvE-QHEh-m80mWAgp2MUT9gFD7HLen0,12670
22
+ langgraph_api/stream.py,sha256=0qLblAQ406bGZEM1zRQKVyU407c9PjcBcgPCKN78ywc,12847
23
23
  langgraph_api/thread_ttl.py,sha256=-Ox8NFHqUH3wGNdEKMIfAXUubY5WGifIgCaJ7npqLgw,1762
24
24
  langgraph_api/utils.py,sha256=92mSti9GfGdMRRWyESKQW5yV-75Z9icGHnIrBYvdypU,3619
25
25
  langgraph_api/validation.py,sha256=zMuKmwUEBjBgFMwAaeLZmatwGVijKv2sOYtYg7gfRtc,4950
26
26
  langgraph_api/webhook.py,sha256=1ncwO0rIZcj-Df9sxSnFEzd1gP1bfS4okeZQS8NSRoE,1382
27
- langgraph_api/worker.py,sha256=sdUKXr19CSMaptg_3cvzUAy4KOUme1ajwSBt1dvSbsg,14587
27
+ langgraph_api/worker.py,sha256=YjMadekwt8t7Mn-pxZe8H-SJfetT31bl3MO2WFGVzBg,14510
28
28
  langgraph_api/api/__init__.py,sha256=YVzpbn5IQotvuuLG9fhS9QMrxXfP4s4EpEMG0n4q3Nw,5625
29
29
  langgraph_api/api/assistants.py,sha256=x_V1rnSGFYjNZFJkZKFN9yNFOqXhqkOSqMDSv3I8VeE,15880
30
30
  langgraph_api/api/mcp.py,sha256=RvRYgANqRzNQzSmgjNkq4RlKTtoEJYil04ot9lsmEtE,14352
@@ -78,8 +78,8 @@ langgraph_runtime/__init__.py,sha256=O4GgSmu33c-Pr8Xzxj_brcK5vkm70iNTcyxEjICFZxA
78
78
  LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
79
79
  logging.json,sha256=3RNjSADZmDq38eHePMm1CbP6qZ71AmpBtLwCmKU9Zgo,379
80
80
  openapi.json,sha256=_4GFDqbq1X9vD4_FxwahuVODJMOHx-U76gkY4rdy3DA,138189
81
- langgraph_api-0.2.42.dist-info/METADATA,sha256=GK8GedSLk6Bg8NPQhNfQAodCid1rz3C4IsQ8a2aEXGk,3892
82
- langgraph_api-0.2.42.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
83
- langgraph_api-0.2.42.dist-info/entry_points.txt,sha256=hGedv8n7cgi41PypMfinwS_HfCwA7xJIfS0jAp8htV8,78
84
- langgraph_api-0.2.42.dist-info/licenses/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
85
- langgraph_api-0.2.42.dist-info/RECORD,,
81
+ langgraph_api-0.2.44.dist-info/METADATA,sha256=9OXLai4MqakDiva3wfVGk3vmX4akdCJ1zKuvNpl62t4,3892
82
+ langgraph_api-0.2.44.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
83
+ langgraph_api-0.2.44.dist-info/entry_points.txt,sha256=hGedv8n7cgi41PypMfinwS_HfCwA7xJIfS0jAp8htV8,78
84
+ langgraph_api-0.2.44.dist-info/licenses/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
85
+ langgraph_api-0.2.44.dist-info/RECORD,,