langgraph-runtime-inmem 0.39.0.dev5__tar.gz → 0.39.0.dev7__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.
- {langgraph_runtime_inmem-0.39.0.dev5 → langgraph_runtime_inmem-0.39.0.dev7}/PKG-INFO +1 -1
- {langgraph_runtime_inmem-0.39.0.dev5 → langgraph_runtime_inmem-0.39.0.dev7}/langgraph_runtime_inmem/__init__.py +1 -1
- {langgraph_runtime_inmem-0.39.0.dev5 → langgraph_runtime_inmem-0.39.0.dev7}/langgraph_runtime_inmem/ops.py +48 -6
- {langgraph_runtime_inmem-0.39.0.dev5 → langgraph_runtime_inmem-0.39.0.dev7}/.gitignore +0 -0
- {langgraph_runtime_inmem-0.39.0.dev5 → langgraph_runtime_inmem-0.39.0.dev7}/Makefile +0 -0
- {langgraph_runtime_inmem-0.39.0.dev5 → langgraph_runtime_inmem-0.39.0.dev7}/README.md +0 -0
- {langgraph_runtime_inmem-0.39.0.dev5 → langgraph_runtime_inmem-0.39.0.dev7}/langgraph_runtime_inmem/_persistence.py +0 -0
- {langgraph_runtime_inmem-0.39.0.dev5 → langgraph_runtime_inmem-0.39.0.dev7}/langgraph_runtime_inmem/checkpoint.py +0 -0
- {langgraph_runtime_inmem-0.39.0.dev5 → langgraph_runtime_inmem-0.39.0.dev7}/langgraph_runtime_inmem/database.py +0 -0
- {langgraph_runtime_inmem-0.39.0.dev5 → langgraph_runtime_inmem-0.39.0.dev7}/langgraph_runtime_inmem/encryption.py +0 -0
- {langgraph_runtime_inmem-0.39.0.dev5 → langgraph_runtime_inmem-0.39.0.dev7}/langgraph_runtime_inmem/inmem_stream.py +0 -0
- {langgraph_runtime_inmem-0.39.0.dev5 → langgraph_runtime_inmem-0.39.0.dev7}/langgraph_runtime_inmem/lifespan.py +0 -0
- {langgraph_runtime_inmem-0.39.0.dev5 → langgraph_runtime_inmem-0.39.0.dev7}/langgraph_runtime_inmem/metrics.py +0 -0
- {langgraph_runtime_inmem-0.39.0.dev5 → langgraph_runtime_inmem-0.39.0.dev7}/langgraph_runtime_inmem/queue.py +0 -0
- {langgraph_runtime_inmem-0.39.0.dev5 → langgraph_runtime_inmem-0.39.0.dev7}/langgraph_runtime_inmem/retry.py +0 -0
- {langgraph_runtime_inmem-0.39.0.dev5 → langgraph_runtime_inmem-0.39.0.dev7}/langgraph_runtime_inmem/routes.py +0 -0
- {langgraph_runtime_inmem-0.39.0.dev5 → langgraph_runtime_inmem-0.39.0.dev7}/langgraph_runtime_inmem/store.py +0 -0
- {langgraph_runtime_inmem-0.39.0.dev5 → langgraph_runtime_inmem-0.39.0.dev7}/pyproject.toml +0 -0
- {langgraph_runtime_inmem-0.39.0.dev5 → langgraph_runtime_inmem-0.39.0.dev7}/uv.lock +0 -0
|
@@ -194,6 +194,8 @@ async def _save_thread_status(
|
|
|
194
194
|
checkpoint: CheckpointPayload | None,
|
|
195
195
|
exception: BaseException | None,
|
|
196
196
|
now: datetime,
|
|
197
|
+
*,
|
|
198
|
+
refused: bool = False,
|
|
197
199
|
) -> None:
|
|
198
200
|
"""Write a thread's status and error from the facts this update knows.
|
|
199
201
|
|
|
@@ -201,21 +203,26 @@ async def _save_thread_status(
|
|
|
201
203
|
Without a checkpoint there is nothing to replace values, interrupts and
|
|
202
204
|
has_next with, so the thread keeps the ones it already has. has_next is
|
|
203
205
|
recorded only once the thread is saved, so a failed save can't leave the two
|
|
204
|
-
apart.
|
|
206
|
+
apart. A resume that strict mode refused ran nothing, so the thread keeps the
|
|
207
|
+
error, or lack of one, it had.
|
|
205
208
|
"""
|
|
206
209
|
from langgraph_api.serde import json_dumpb, json_loads # noqa: PLC0415
|
|
207
210
|
|
|
208
|
-
failure = _thread_failure(exception)
|
|
211
|
+
failure = None if refused else _thread_failure(exception)
|
|
209
212
|
has_next = None if checkpoint is None else bool(checkpoint["next"])
|
|
210
213
|
|
|
211
214
|
update: dict = {
|
|
212
215
|
"updated_at": now,
|
|
213
216
|
"state_updated_at": now,
|
|
214
217
|
"status": _thread_status(
|
|
215
|
-
conn,
|
|
218
|
+
conn,
|
|
219
|
+
thread_id,
|
|
220
|
+
failed=None if refused else failure is not None,
|
|
221
|
+
has_next=has_next,
|
|
216
222
|
),
|
|
217
|
-
"error": json_loads(json_dumpb(failure)) if failure else None,
|
|
218
223
|
}
|
|
224
|
+
if not refused:
|
|
225
|
+
update["error"] = json_loads(json_dumpb(failure)) if failure else None
|
|
219
226
|
if checkpoint is not None:
|
|
220
227
|
update["values"] = json_loads(json_dumpb(checkpoint["values"]))
|
|
221
228
|
update["interrupts"] = json_loads(
|
|
@@ -236,7 +243,8 @@ async def _save_thread_status(
|
|
|
236
243
|
# facts apart from the thread.
|
|
237
244
|
if has_next is not None:
|
|
238
245
|
_thread_has_next(conn)[thread_id] = has_next
|
|
239
|
-
|
|
246
|
+
if not refused:
|
|
247
|
+
_thread_failed(conn)[thread_id] = failure is not None
|
|
240
248
|
|
|
241
249
|
|
|
242
250
|
def _run_stream_mode_matches(event_mode: str, stream_mode: list[str] | None) -> bool:
|
|
@@ -1015,6 +1023,13 @@ def _is_jsonb_value_contained(superset: Any, subset: Any) -> bool:
|
|
|
1015
1023
|
return superset == subset
|
|
1016
1024
|
|
|
1017
1025
|
|
|
1026
|
+
def _in_time_range(
|
|
1027
|
+
value: datetime, after: datetime | None, before: datetime | None
|
|
1028
|
+
) -> bool:
|
|
1029
|
+
"""Check value against an [after, before) range; None bounds are open."""
|
|
1030
|
+
return (after is None or value >= after) and (before is None or value < before)
|
|
1031
|
+
|
|
1032
|
+
|
|
1018
1033
|
def bytes_decoder(obj):
|
|
1019
1034
|
"""Custom JSON decoder that converts base64 back to bytes."""
|
|
1020
1035
|
if "__type__" in obj and obj["__type__"] == "bytes":
|
|
@@ -1117,6 +1132,8 @@ class Threads(Authenticated):
|
|
|
1117
1132
|
select: list[ThreadSelectField] | None = None,
|
|
1118
1133
|
extract: dict[str, str] | None = None,
|
|
1119
1134
|
exclude_metadata: list[dict[str, Any]] | None = None,
|
|
1135
|
+
created_after: datetime | None = None,
|
|
1136
|
+
created_before: datetime | None = None,
|
|
1120
1137
|
ctx: Auth.types.BaseAuthContext | None = None,
|
|
1121
1138
|
) -> tuple[AsyncIterator[Thread], int]:
|
|
1122
1139
|
threads = conn.store["threads"]
|
|
@@ -1165,6 +1182,9 @@ class Threads(Authenticated):
|
|
|
1165
1182
|
):
|
|
1166
1183
|
continue
|
|
1167
1184
|
|
|
1185
|
+
if not _in_time_range(thread["created_at"], created_after, created_before):
|
|
1186
|
+
continue
|
|
1187
|
+
|
|
1168
1188
|
if (
|
|
1169
1189
|
values
|
|
1170
1190
|
and "values" in thread
|
|
@@ -1526,6 +1546,8 @@ class Threads(Authenticated):
|
|
|
1526
1546
|
graph_id: str,
|
|
1527
1547
|
checkpoint: CheckpointPayload | None = None,
|
|
1528
1548
|
exception: BaseException | None = None,
|
|
1549
|
+
*,
|
|
1550
|
+
refused_resume: bool = False,
|
|
1529
1551
|
) -> None:
|
|
1530
1552
|
"""Set the status of both thread and run atomically in a single query.
|
|
1531
1553
|
|
|
@@ -1539,6 +1561,8 @@ class Threads(Authenticated):
|
|
|
1539
1561
|
run_status: New status for the run (or "rollback" to delete the run)
|
|
1540
1562
|
checkpoint: Checkpoint payload for thread status calculation
|
|
1541
1563
|
exception: Exception that occurred (affects thread status)
|
|
1564
|
+
refused_resume: Strict resume refused the run's answer before anything
|
|
1565
|
+
ran, so the thread keeps its error, or lack of one, as it was.
|
|
1542
1566
|
"""
|
|
1543
1567
|
# No auth since it's internal
|
|
1544
1568
|
thread_id = _ensure_uuid(thread_id)
|
|
@@ -1569,13 +1593,21 @@ class Threads(Authenticated):
|
|
|
1569
1593
|
if run.get("cancel_action") == "rollback":
|
|
1570
1594
|
# A rollback recorded while the run ran wins over the signal its worker saw first, as in Go.
|
|
1571
1595
|
run_status, checkpoint, exception = "rollback", None, None
|
|
1596
|
+
refused_resume = False
|
|
1572
1597
|
if run_status == "rollback":
|
|
1573
1598
|
await Runs.delete(conn, run_id, thread_id=run["thread_id"])
|
|
1574
1599
|
else:
|
|
1575
1600
|
run.update({"status": run_status, "updated_at": now})
|
|
1576
1601
|
thread["metadata"]["graph_id"] = graph_id
|
|
1577
1602
|
await _save_thread_status(
|
|
1578
|
-
conn,
|
|
1603
|
+
conn,
|
|
1604
|
+
thread_id,
|
|
1605
|
+
thread,
|
|
1606
|
+
stored_thread,
|
|
1607
|
+
checkpoint,
|
|
1608
|
+
exception,
|
|
1609
|
+
now,
|
|
1610
|
+
refused=refused_resume,
|
|
1579
1611
|
)
|
|
1580
1612
|
|
|
1581
1613
|
@staticmethod
|
|
@@ -2609,6 +2641,8 @@ class Threads(Authenticated):
|
|
|
2609
2641
|
values: MetadataInput = None,
|
|
2610
2642
|
status: ThreadStatus | None = None,
|
|
2611
2643
|
exclude_metadata: list[dict[str, Any]] | None = None,
|
|
2644
|
+
created_after: datetime | None = None,
|
|
2645
|
+
created_before: datetime | None = None,
|
|
2612
2646
|
ctx: Auth.types.BaseAuthContext | None = None,
|
|
2613
2647
|
) -> int:
|
|
2614
2648
|
"""Get count of threads."""
|
|
@@ -2643,6 +2677,9 @@ class Threads(Authenticated):
|
|
|
2643
2677
|
):
|
|
2644
2678
|
continue
|
|
2645
2679
|
|
|
2680
|
+
if not _in_time_range(thread["created_at"], created_after, created_before):
|
|
2681
|
+
continue
|
|
2682
|
+
|
|
2646
2683
|
if (
|
|
2647
2684
|
values
|
|
2648
2685
|
and "values" in thread
|
|
@@ -3133,6 +3170,11 @@ class Runs(Authenticated):
|
|
|
3133
3170
|
else None
|
|
3134
3171
|
)
|
|
3135
3172
|
|
|
3173
|
+
# A run that cancels the runs in flight replaces them, so refusing its
|
|
3174
|
+
# answer would stop the agent mid-turn: it never resumes strictly.
|
|
3175
|
+
if multitask_strategy in ("interrupt", "rollback") and inflight_runs:
|
|
3176
|
+
kwargs = {k: v for k, v in kwargs.items() if k != "strict_resume"}
|
|
3177
|
+
|
|
3136
3178
|
# Create new run
|
|
3137
3179
|
configurable = Runs._merge_jsonb(
|
|
3138
3180
|
Runs._get_configurable(assistant["config"]),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|