Compare commits

...
34 changed files with 67 additions and 459 deletions

No files matched your search

@@ -104,7 +104,6 @@ class AsyncPostgresStore(AsyncBatchedBaseStore, BasePostgresStore[_ainternal.Con
Make sure to:
1. Call `setup()` before first use to create necessary tables and indexes
2. Have the pgvector extension available to use vector search
3. Use Python 3.10+ for async functionality
Note:
Semantic search is disabled by default. You can enable it by providing an `index` configuration
+1 -5
View File
@@ -2,13 +2,9 @@ import os
import pathlib
import re
import shlex
import tomllib
from dataclasses import dataclass
try:
import tomllib
except ModuleNotFoundError: # pragma: no cover - exercised on Python 3.10.
import tomli as tomllib
import click
import pathspec
+3 -4
View File
@@ -14,17 +14,16 @@ license-files = ['LICENSE']
dependencies = [
"click>=8.1.7",
"httpx>=0.24.0",
"langgraph-sdk>=0.1.0 ; python_version >= '3.11'",
"langgraph-sdk>=0.1.0",
"pathspec>=0.11.0",
"python-dotenv>=0.8.0",
"tomli>=2.0.1 ; python_version < '3.11'",
]
[tool.hatch.version]
path = "langgraph_cli/__init__.py"
[project.optional-dependencies]
inmem = [
"langgraph-api>=0.5.35,<1.0.0 ; python_version >= '3.11'",
"langgraph-runtime-inmem>=0.7 ; python_version >= '3.11'",
"langgraph-api>=0.5.35,<1.0.0",
"langgraph-runtime-inmem>=0.7",
]
[project.urls]
+3 -4
View File
@@ -1046,12 +1046,11 @@ test = [
requires-dist = [
{ name = "click", specifier = ">=8.1.7" },
{ name = "httpx", specifier = ">=0.24.0" },
{ name = "langgraph-api", marker = "python_full_version >= '3.11' and extra == 'inmem'", specifier = ">=0.5.35,<1.0.0" },
{ name = "langgraph-runtime-inmem", marker = "python_full_version >= '3.11' and extra == 'inmem'", specifier = ">=0.7" },
{ name = "langgraph-sdk", marker = "python_full_version >= '3.11'", specifier = ">=0.1.0" },
{ name = "langgraph-api", marker = "extra == 'inmem'", specifier = ">=0.5.35,<1.0.0" },
{ name = "langgraph-runtime-inmem", marker = "extra == 'inmem'", specifier = ">=0.7" },
{ name = "langgraph-sdk", specifier = ">=0.1.0" },
{ name = "pathspec", specifier = ">=0.11.0" },
{ name = "python-dotenv", specifier = ">=0.8.0" },
{ name = "tomli", marker = "python_full_version < '3.11'", specifier = ">=2.0.1" },
]
provides-extras = ["inmem"]
@@ -12,7 +12,6 @@ from typing import TypeVar, cast
T = TypeVar("T")
AnyFuture = asyncio.Future | concurrent.futures.Future
CONTEXT_NOT_SUPPORTED = sys.version_info < (3, 11)
EAGER_NOT_SUPPORTED = sys.version_info < (3, 12)
@@ -162,9 +161,7 @@ def _ensure_future(
)
try:
if CONTEXT_NOT_SUPPORTED:
return loop.create_task(coro_or_future, name=name)
elif EAGER_NOT_SUPPORTED or lazy:
if EAGER_NOT_SUPPORTED or lazy:
return loop.create_task(coro_or_future, name=name, context=context)
else:
return asyncio.eager_task_factory(
+39 -81
View File
@@ -5,7 +5,6 @@ import copy
import enum
import inspect
import logging
import sys
import warnings
from collections.abc import (
AsyncIterator,
@@ -185,8 +184,7 @@ def create_task_in_config_context(
return context.run(lambda: asyncio.create_task(coro_factory()))
# Kept as a (str, Enum) subclass rather than enum.StrEnum for backward
# compatibility with Python < 3.11: str() of a member stays "Class.MEMBER".
# Preserve str() output ("Class.MEMBER", not the value) for backward compatibility.
class StrEnum(str, enum.Enum): # noqa: UP042
"""A string enum."""
@@ -194,8 +192,6 @@ class StrEnum(str, enum.Enum): # noqa: UP042
# Special type to denote any type is accepted
ANY_TYPE = object()
ASYNCIO_ACCEPTS_CONTEXT = sys.version_info >= (3, 11)
# List of keyword arguments that can be injected into nodes / tasks / tools at runtime.
# A named argument may appear multiple times if it appears with distinct types.
KWARGS_CONFIG_KEYS: tuple[tuple[str, tuple[Any, ...], str, Any], ...] = (
@@ -535,17 +531,14 @@ class RunnableCallable(Runnable):
try:
child_config = patch_config(config, callbacks=run_manager.get_child())
coro = cast(Coroutine[None, None, Any], self.afunc(*args, **kwargs))
if ASYNCIO_ACCEPTS_CONTEXT:
for h in run_manager.handlers:
if isinstance(h, LangChainTracer):
run = h.run_map.get(str(run_manager.run_id))
break
else:
run = None
with set_config_context(child_config, run) as context:
ret = await asyncio.create_task(coro, context=context)
for h in run_manager.handlers:
if isinstance(h, LangChainTracer):
run = h.run_map.get(str(run_manager.run_id))
break
else:
ret = await coro
run = None
with set_config_context(child_config, run) as context:
ret = await asyncio.create_task(coro, context=context)
except BaseException as e:
await run_manager.on_chain_error(e)
raise
@@ -824,21 +817,18 @@ class RunnableSeq(Runnable):
# 1st step is the actual node,
# others are writers which don't need to be run in context
if i == 0:
if ASYNCIO_ACCEPTS_CONTEXT:
# get the run object
for h in run_manager.handlers:
if isinstance(h, LangChainTracer):
run = h.run_map.get(str(run_manager.run_id))
break
else:
run = None
# run in context
with set_config_context(config, run) as context:
input = await asyncio.create_task(
step.ainvoke(input, config, **kwargs), context=context
)
# get the run object
for h in run_manager.handlers:
if isinstance(h, LangChainTracer):
run = h.run_map.get(str(run_manager.run_id))
break
else:
input = await step.ainvoke(input, config, **kwargs)
run = None
# run in context
with set_config_context(config, run) as context:
input = await asyncio.create_task(
step.ainvoke(input, config, **kwargs), context=context
)
else:
input = await step.ainvoke(input, config)
# finish the root run
@@ -915,64 +905,30 @@ class RunnableSeq(Runnable):
# transform the input stream of each step with the next
# steps that don't natively support transforming an input stream will
# buffer input in memory until all available, and then start emitting output
if ASYNCIO_ACCEPTS_CONTEXT:
# get the run object
for h in run_manager.handlers:
if isinstance(h, LangChainTracer):
run = h.run_map.get(str(run_manager.run_id))
break
else:
run = None
# create first step config
config = patch_config(
config,
callbacks=run_manager.get_child(f"seq:step:{1}"),
)
# run all in context
with set_config_context(config, run) as context:
try:
async with AsyncExitStack() as stack:
for idx, step in enumerate(self.steps):
if idx == 0:
aiterator = step.astream(input, config, **kwargs)
else:
config = patch_config(
config,
callbacks=run_manager.get_child(
f"seq:step:{idx + 1}"
),
)
aiterator = step.atransform(aiterator, config)
if hasattr(aiterator, "aclose"):
stack.push_async_callback(aiterator.aclose)
# populates streamed_output in astream_log() output if needed
for h in run_manager.handlers:
if _is_stream_handler(h):
aiterator = h.tap_output_aiter(
run_manager.run_id, aiterator
)
# consume into final output
output = await asyncio.create_task(
_consume_aiter(aiterator), context=context
)
# sequence doesn't emit output, yield to mark as generator
yield
except BaseException as e:
await run_manager.on_chain_error(e)
raise
else:
await self._aend(run_manager, output)
# get the run object
for h in run_manager.handlers:
if isinstance(h, LangChainTracer):
run = h.run_map.get(str(run_manager.run_id))
break
else:
run = None
# create first step config
config = patch_config(
config,
callbacks=run_manager.get_child(f"seq:step:{1}"),
)
# run all in context
with set_config_context(config, run) as context:
try:
async with AsyncExitStack() as stack:
for idx, step in enumerate(self.steps):
config = patch_config(
config,
callbacks=run_manager.get_child(f"seq:step:{idx + 1}"),
)
if idx == 0:
aiterator = step.astream(input, config, **kwargs)
else:
config = patch_config(
config,
callbacks=run_manager.get_child(f"seq:step:{idx + 1}"),
)
aiterator = step.atransform(aiterator, config)
if hasattr(aiterator, "aclose"):
stack.push_async_callback(aiterator.aclose)
@@ -983,7 +939,9 @@ class RunnableSeq(Runnable):
run_manager.run_id, aiterator
)
# consume into final output
output = await _consume_aiter(aiterator)
output = await asyncio.create_task(
_consume_aiter(aiterator), context=context
)
# sequence doesn't emit output, yield to mark as generator
yield
except BaseException as e:
-11
View File
@@ -40,12 +40,6 @@ def get_store() -> BaseStore:
...
```
!!! warning "Async with Python < 3.11"
If you are using Python < 3.11 and are running LangGraph asynchronously,
`get_store()` won't work since it uses [`contextvar`](https://docs.python.org/3/library/contextvars.html) propagation (only available in [Python >= 3.11](https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task)).
Example: Using with `StateGraph`
```python
from typing_extensions import TypedDict
@@ -119,11 +113,6 @@ def get_stream_writer() -> StreamWriter:
Can be called from inside any [`StateGraph`][langgraph.graph.StateGraph] node or
functional API [`task`][langgraph.func.task].
!!! warning "Async with Python < 3.11"
If you are using Python < 3.11 and are running LangGraph asynchronously,
`get_stream_writer()` won't work since it uses [`contextvar`](https://docs.python.org/3/library/contextvars.html) propagation (only available in [Python >= 3.11](https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task)).
Example: Using with `StateGraph`
```python
from typing_extensions import TypedDict
+3 -6
View File
@@ -2,7 +2,6 @@ from __future__ import annotations
import binascii
import itertools
import sys
import threading
from collections import defaultdict, deque
from collections.abc import Callable, Iterable, Mapping, Sequence
@@ -90,7 +89,6 @@ from langgraph.types import (
)
GetNextVersion = Callable[[V | None, None], V]
SUPPORTS_EXC_NOTES = sys.version_info >= (3, 11)
class WritesProtocol(Protocol):
@@ -646,10 +644,9 @@ def prepare_single_task(
if val is MISSING:
return
except Exception as exc:
if SUPPORTS_EXC_NOTES:
exc.add_note(
f"Before task with name '{name}' and path '{task_path[:3]}'"
)
exc.add_note(
f"Before task with name '{name}' and path '{task_path[:3]}'"
)
raise
metadata = {
+8 -13
View File
@@ -18,7 +18,7 @@ from langchain_core.runnables import RunnableConfig
from langchain_core.runnables.config import get_executor_for_config
from typing_extensions import ParamSpec
from langgraph._internal._future import CONTEXT_NOT_SUPPORTED, run_coroutine_threadsafe
from langgraph._internal._future import run_coroutine_threadsafe
from langgraph.errors import GraphBubbleUp
P = ParamSpec("P")
@@ -160,18 +160,13 @@ class AsyncBackgroundExecutor(AbstractAsyncContextManager):
coro = cast(Coroutine[None, None, T], fn(*args, **kwargs))
if self.semaphore:
coro = gated(self.semaphore, coro)
if CONTEXT_NOT_SUPPORTED:
task = run_coroutine_threadsafe(
coro, self.loop, name=__name__, lazy=__next_tick__
)
else:
task = run_coroutine_threadsafe(
coro,
self.loop,
name=__name__,
context=copy_context(),
lazy=__next_tick__,
)
task = run_coroutine_threadsafe(
coro,
self.loop,
name=__name__,
context=copy_context(),
lazy=__next_tick__,
)
self.tasks[task] = (__cancel_on_exit__, __reraise_on_exit__)
task.add_done_callback(self.done)
return task
+3 -16
View File
@@ -3,7 +3,6 @@ from __future__ import annotations
import asyncio
import logging
import random
import sys
import threading
import time
import weakref
@@ -51,12 +50,6 @@ from langgraph.runtime import ExecutionInfo, Runtime
from langgraph.types import Command, PregelExecutableTask, RetryPolicy, TimeoutPolicy
logger = logging.getLogger(__name__)
SUPPORTS_EXC_NOTES = sys.version_info >= (3, 11)
# `asyncio.Task.cancelling()` was added in Python 3.11. It reports the number of
# pending cancel requests on the task: ``0`` means no external code asked us to
# cancel — so a ``CancelledError`` observed here was raised by the task body
# itself (the user's node) rather than by pregel cancelling sibling tasks.
SUPPORTS_TASK_CANCELLING = sys.version_info >= (3, 11)
def _timeout_secs(value: float | timedelta) -> float:
@@ -325,12 +318,8 @@ def _is_user_raised_cancelled() -> bool:
signal we use to convert the exception into a regular
:class:`NodeCancelledError`.
Returns ``False`` when we can't tell (``cancelling()`` unavailable, or no
current task — neither should happen in practice from ``arun_with_retry``)
so framework-initiated cancellation continues to propagate unchanged.
Returns `False` if there is no current task.
"""
if not SUPPORTS_TASK_CANCELLING:
return False
current = asyncio.current_task()
if current is None:
return False
@@ -659,8 +648,7 @@ def run_with_retry(
# treating the task as a silent tear-down (LSD-1507).
raise NodeCancelledError(task.name) from exc
except Exception as exc:
if SUPPORTS_EXC_NOTES:
exc.add_note(f"During task with name '{task.name}' and id '{task.id}'")
exc.add_note(f"During task with name '{task.name}' and id '{task.id}'")
if not retry_policy:
raise
@@ -807,8 +795,7 @@ async def arun_with_retry(
raise
except Exception as exc:
_finish_timed_attempt(config, attempt_ctx, exc)
if SUPPORTS_EXC_NOTES:
exc.add_note(f"During task with name '{task.name}' and id '{task.id}'")
exc.add_note(f"During task with name '{task.name}' and id '{task.id}'")
if not retry_policy:
raise
@@ -1,5 +1,4 @@
import operator
import sys
import time
from collections import defaultdict
from typing import Annotated, Literal
@@ -17,11 +16,6 @@ from tests.any_str import AnyDict, AnyObject, AnyStr
pytestmark = pytest.mark.anyio
NEEDS_CONTEXTVARS = pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ is required for async contextvars support",
)
def get_expected_history(*, exc_task_results: int = 0) -> list[StateSnapshot]:
return [
@@ -1470,7 +1464,6 @@ def make_state_graph() -> StateGraph:
return workflow
@NEEDS_CONTEXTVARS
@pytest.mark.parametrize("source,target", [("2-start:*", "3"), ("2-quadratic", "3")])
def test_migrate_checkpoints(source: str, target: str) -> None:
# Check that the migration function works as expected
@@ -1508,7 +1501,6 @@ def test_migrate_checkpoints(source: str, target: str) -> None:
)
@NEEDS_CONTEXTVARS
def test_latest_checkpoint_state_graph(
sync_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -1549,7 +1541,6 @@ def test_latest_checkpoint_state_graph(
assert history[5] == expected_history[5]
@NEEDS_CONTEXTVARS
async def test_latest_checkpoint_state_graph_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -1595,7 +1586,6 @@ async def test_latest_checkpoint_state_graph_async(
assert history[5] == expected_history[5]
@NEEDS_CONTEXTVARS
@pytest.mark.parametrize("checkpoint_version", ["3", "2-start:*", "2-quadratic"])
def test_saved_checkpoint_state_graph(
sync_checkpointer: BaseCheckpointSaver,
@@ -1661,7 +1651,6 @@ def test_saved_checkpoint_state_graph(
)
@NEEDS_CONTEXTVARS
@pytest.mark.parametrize("checkpoint_version", ["3", "2-start:*", "2-quadratic"])
async def test_saved_checkpoint_state_graph_async(
async_checkpointer: BaseCheckpointSaver,
@@ -4,7 +4,6 @@ Every graph carries a `DeltaChannel` and a plain reducer channel fed the same
values; the plain channel needs no replay, so it is the oracle.
"""
import sys
import threading
from collections.abc import Sequence
from operator import add
@@ -30,10 +29,6 @@ from langgraph.types import (
)
pytestmark = pytest.mark.anyio
NEEDS_CONTEXTVARS = pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ is required for async contextvars support",
)
def _append(current: list | None, writes: Sequence[Any]) -> list:
@@ -825,7 +820,6 @@ def test_resume_that_replaces_the_pending_sends_drops_the_finished_task(
)
@NEEDS_CONTEXTVARS
async def test_aresume_that_replaces_the_pending_sends_drops_the_finished_task(
async_checkpointer: BaseCheckpointSaver, durability: Durability
) -> None:
@@ -862,7 +856,6 @@ def test_replay_interrupted_in_its_first_step_still_seals_the_fork(
)
@NEEDS_CONTEXTVARS
async def test_areplay_interrupted_in_its_first_step_still_seals_the_fork(
async_checkpointer: BaseCheckpointSaver, durability: Durability
) -> None:
@@ -1,6 +1,5 @@
from __future__ import annotations
import sys
from typing import Any
import pytest
@@ -18,11 +17,6 @@ from langgraph.callbacks import (
from langgraph.graph import START, StateGraph
from langgraph.types import Command, Interrupt, interrupt
NEEDS_CONTEXTVARS = pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ is required for async contextvars support",
)
class _GraphEventHandler(GraphCallbackHandler):
def __init__(self) -> None:
@@ -131,7 +125,6 @@ def test_graph_callbacks_interrupt_and_resume_sync() -> None:
@pytest.mark.anyio
@NEEDS_CONTEXTVARS
async def test_graph_callbacks_interrupt_and_resume_async() -> None:
graph = _build_interrupt_graph()
handler = _GraphEventHandler()
@@ -211,7 +204,6 @@ def test_graph_callbacks_raise_error_propagates_sync() -> None:
@pytest.mark.anyio
@NEEDS_CONTEXTVARS
async def test_graph_callbacks_continue_when_handler_raises_async() -> None:
graph = _build_interrupt_graph()
raising_interrupt_handler = _AsyncRaisingGraphEventHandler(raise_on_interrupt=True)
@@ -241,7 +233,6 @@ async def test_graph_callbacks_continue_when_handler_raises_async() -> None:
@pytest.mark.anyio
@NEEDS_CONTEXTVARS
async def test_graph_callbacks_raise_error_propagates_async() -> None:
graph = _build_interrupt_graph()
raising_handler = _AsyncRaisingGraphEventHandler(
@@ -320,7 +311,6 @@ def test_non_graph_handler_does_not_receive_lifecycle_events() -> None:
@pytest.mark.anyio
@NEEDS_CONTEXTVARS
async def test_non_graph_handler_does_not_receive_lifecycle_events_async() -> None:
"""Async variant: non-GraphCallbackHandler should not interfere."""
graph = _build_interrupt_graph()
@@ -8,7 +8,6 @@ still need an answer.
"""
import operator
import sys
import uuid
from collections import Counter
from typing import Annotated, Any
@@ -32,11 +31,6 @@ from langgraph.types import Command, Durability, Interrupt, Send, interrupt
pytestmark = pytest.mark.anyio
NEEDS_CONTEXTVARS = pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ is required for async contextvars support",
)
class State(TypedDict, total=False):
log: Annotated[list[str], operator.add]
@@ -229,7 +223,6 @@ def test_resume_at_the_latest_checkpoint_does_not_rerun_finished_task(
assert calls == {"a": 2, "b": 3}, "resuming B ran the finished A again"
@NEEDS_CONTEXTVARS
async def test_finished_task_does_not_report_answered_interrupt_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -301,7 +294,6 @@ def test_task_paused_at_second_question_stays_pending(
assert snapshot.interrupts == ()
@NEEDS_CONTEXTVARS
async def test_task_paused_at_second_question_stays_pending_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -440,7 +432,6 @@ def test_task_finished_with_falsy_result(
@pytest.mark.parametrize("a_returns", [None, {"count": 0}], ids=["none", "zero"])
@NEEDS_CONTEXTVARS
async def test_task_finished_with_falsy_result_async(
async_checkpointer: BaseCheckpointSaver, a_returns: Any
) -> None:
@@ -1,6 +1,5 @@
import asyncio
import operator
import sys
from dataclasses import dataclass
from typing import Annotated, Any
@@ -256,10 +255,6 @@ def test_interrupt_response_schema_invalid_resume_after_earlier_interrupt(
}
@pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ is required for async contextvars support",
)
async def test_invalid_resume_lets_other_answered_tasks_finish(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -1,7 +1,6 @@
import asyncio
import operator
import re
import sys
from typing import (
Annotated,
Literal,
@@ -3524,10 +3523,6 @@ async def test_send_to_nested_graphs(async_checkpointer: BaseCheckpointSaver) ->
}
@pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ is required for async contextvars support",
)
async def test_weather_subgraph(
async_checkpointer: BaseCheckpointSaver,
) -> None:
-56
View File
@@ -5,7 +5,6 @@ import gc
import logging
import operator
import random
import sys
import uuid
from collections import Counter, defaultdict, deque
from dataclasses import replace
@@ -101,11 +100,6 @@ logger = logging.getLogger(__name__)
pytestmark = pytest.mark.anyio
NEEDS_CONTEXTVARS = pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ is required for async contextvars support",
)
async def test_checkpoint_errors() -> None:
class FaultyGetCheckpointer(InMemorySaver):
@@ -233,7 +227,6 @@ async def test_checkpoint_errors() -> None:
pass
@NEEDS_CONTEXTVARS
async def test_request_drain_allows_inflight_acall_scheduling(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -606,7 +599,6 @@ async def test_node_cancellation_on_other_node_exception_two() -> None:
await graph.ainvoke({"hello": "world"})
@NEEDS_CONTEXTVARS
async def test_dynamic_interrupt(async_checkpointer: BaseCheckpointSaver) -> None:
class State(TypedDict):
my_key: Annotated[str, operator.add]
@@ -757,7 +749,6 @@ async def test_dynamic_interrupt(async_checkpointer: BaseCheckpointSaver) -> Non
)
@NEEDS_CONTEXTVARS
async def test_dynamic_interrupt_subgraph(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -932,7 +923,6 @@ async def test_dynamic_interrupt_subgraph(
)
@NEEDS_CONTEXTVARS
async def test_partial_pending_checkpoint(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -1105,7 +1095,6 @@ async def test_partial_pending_checkpoint(
)
@NEEDS_CONTEXTVARS
async def test_node_not_cancelled_on_other_node_interrupted(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -2285,7 +2274,6 @@ async def test_send_sequences(async_checkpointer: BaseCheckpointSaver) -> None:
]
@NEEDS_CONTEXTVARS
async def test_imp_task(
async_checkpointer: BaseCheckpointSaver, durability: Durability
) -> None:
@@ -2340,7 +2328,6 @@ async def test_imp_task(
assert mapper_calls == 2
@NEEDS_CONTEXTVARS
async def test_imp_nested(
async_checkpointer: BaseCheckpointSaver, durability: Durability
) -> None:
@@ -2404,7 +2391,6 @@ async def test_imp_nested(
]
@NEEDS_CONTEXTVARS
async def test_imp_task_cancel(
async_checkpointer: BaseCheckpointSaver, durability: Durability
) -> None:
@@ -2455,7 +2441,6 @@ async def test_imp_task_cancel(
assert mapper_cancels == 2
@NEEDS_CONTEXTVARS
async def test_imp_sync_from_async(
async_checkpointer: BaseCheckpointSaver, durability: Durability
) -> None:
@@ -2489,7 +2474,6 @@ async def test_imp_sync_from_async(
]
@NEEDS_CONTEXTVARS
async def test_imp_stream_order(
async_checkpointer: BaseCheckpointSaver, durability: Durability
) -> None:
@@ -2524,10 +2508,6 @@ async def test_imp_stream_order(
]
@pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Requires Python 3.11 or higher for context management",
)
async def test_send_dedupe_on_resume(
async_checkpointer: BaseCheckpointSaver, durability: Durability
) -> None:
@@ -5079,7 +5059,6 @@ async def test_subgraph_durability_inherited(
assert len(checkpoints) == 1
@NEEDS_CONTEXTVARS
async def test_subgraph_checkpoint_true_interrupt(
async_checkpointer: BaseCheckpointSaver, durability: Durability
) -> None:
@@ -5209,7 +5188,6 @@ async def test_stream_subgraphs_during_execution(
]
@NEEDS_CONTEXTVARS
async def test_stream_buffering_single_node(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -6252,7 +6230,6 @@ async def test_delta_channel_durability_exit_stores_snapshot_async() -> None:
assert [m.content for m in state.values["messages"]] == ["hello", "reply"]
@NEEDS_CONTEXTVARS
async def test_interrupt_subgraph(async_checkpointer: BaseCheckpointSaver) -> None:
class State(TypedDict):
baz: str
@@ -6283,7 +6260,6 @@ async def test_interrupt_subgraph(async_checkpointer: BaseCheckpointSaver) -> No
assert await graph.ainvoke(Command(resume="bar"), thread1)
@NEEDS_CONTEXTVARS
async def test_interrupt_multiple(async_checkpointer: BaseCheckpointSaver):
class State(TypedDict):
my_key: Annotated[str, operator.add]
@@ -6341,7 +6317,6 @@ async def test_interrupt_multiple(async_checkpointer: BaseCheckpointSaver):
]
@NEEDS_CONTEXTVARS
async def test_interrupt_loop(async_checkpointer: BaseCheckpointSaver) -> None:
class State(TypedDict):
age: int
@@ -6418,7 +6393,6 @@ async def test_interrupt_loop(async_checkpointer: BaseCheckpointSaver) -> None:
]
@NEEDS_CONTEXTVARS
async def test_interrupt_functional(async_checkpointer: BaseCheckpointSaver) -> None:
@task
async def foo(state: dict) -> dict:
@@ -6444,7 +6418,6 @@ async def test_interrupt_functional(async_checkpointer: BaseCheckpointSaver) ->
assert res == {"a": "foobar", "b": "bar"}
@NEEDS_CONTEXTVARS
async def test_interrupt_task_functional(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -6640,7 +6613,6 @@ async def test_parallel_node_execution():
assert duration < 3.0
@NEEDS_CONTEXTVARS
async def test_multiple_interrupt_state_persistence(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -6827,7 +6799,6 @@ async def test_multiple_updates() -> None:
]
@NEEDS_CONTEXTVARS
async def test_task_in_subgraph_node_returns_its_value_with_tools_mode() -> None:
class State(TypedDict):
out: int | None
@@ -6852,7 +6823,6 @@ async def test_task_in_subgraph_node_returns_its_value_with_tools_mode() -> None
assert chunks[-1] == ("values", {"out": 42})
@NEEDS_CONTEXTVARS
async def test_falsy_return_from_task(async_checkpointer: BaseCheckpointSaver) -> None:
"""Test with a falsy return from a task."""
@@ -6871,7 +6841,6 @@ async def test_falsy_return_from_task(async_checkpointer: BaseCheckpointSaver) -
await graph.ainvoke(Command(resume="123"), configurable)
@NEEDS_CONTEXTVARS
async def test_multiple_interrupts_functional(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -6909,7 +6878,6 @@ async def test_multiple_interrupts_functional(
assert counter == 3
@NEEDS_CONTEXTVARS
async def test_multiple_interrupts_functional_cache(
async_checkpointer: BaseCheckpointSaver, cache: BaseCache
):
@@ -6981,7 +6949,6 @@ async def test_multiple_interrupts_functional_cache(
assert counter == 6
@NEEDS_CONTEXTVARS
async def test_double_interrupt_subgraph(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -7085,7 +7052,6 @@ async def test_double_interrupt_subgraph(
]
@NEEDS_CONTEXTVARS
async def test_async_streaming_with_functional_api() -> None:
"""Test streaming with functional API.
@@ -7122,7 +7088,6 @@ async def test_async_streaming_with_functional_api() -> None:
assert delta > time_delay
@NEEDS_CONTEXTVARS
async def test_multiple_subgraphs(async_checkpointer: BaseCheckpointSaver) -> None:
class State(TypedDict):
a: int
@@ -7195,7 +7160,6 @@ async def test_multiple_subgraphs(async_checkpointer: BaseCheckpointSaver) -> No
}
@NEEDS_CONTEXTVARS
async def test_multiple_subgraphs_functional(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -7243,7 +7207,6 @@ async def test_multiple_subgraphs_functional(
assert await parent_call_multiple_subgraphs.ainvoke([2, 3], config) == [5, 6]
@NEEDS_CONTEXTVARS
async def test_multiple_subgraphs_mixed_entrypoint(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -7306,7 +7269,6 @@ async def test_multiple_subgraphs_mixed_entrypoint(
assert await parent_call_multiple_subgraphs.ainvoke([2, 3], config) == [5, 6]
@NEEDS_CONTEXTVARS
async def test_multiple_subgraphs_mixed_state_graph(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -7377,7 +7339,6 @@ async def test_multiple_subgraphs_mixed_state_graph(
}
@NEEDS_CONTEXTVARS
async def test_multiple_subgraphs_checkpointer(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -7460,7 +7421,6 @@ async def test_multiple_subgraphs_checkpointer(
]
@NEEDS_CONTEXTVARS
async def test_async_entrypoint_without_checkpointer() -> None:
"""Test no checkpointer."""
states = []
@@ -7616,7 +7576,6 @@ async def test_entrypoint_from_async_generator() -> None:
yield "b"
@NEEDS_CONTEXTVARS
@pytest.mark.parametrize("timeout", [None, 30])
@pytest.mark.parametrize("version", ["v1", "v2"])
async def test_awaited_task_returns_its_value_under_astream_events(
@@ -7650,7 +7609,6 @@ async def test_awaited_task_returns_its_value_under_astream_events(
assert outputs == [{"doubled": 42, "zeroed": 0}]
@NEEDS_CONTEXTVARS
async def test_named_tasks_functional() -> None:
class Foo:
async def foo(self, value: str) -> dict:
@@ -7702,7 +7660,6 @@ async def test_named_tasks_functional() -> None:
]
@NEEDS_CONTEXTVARS
async def test_overriding_injectable_args_with_async_task(
async_store: BaseStore,
) -> None:
@@ -7966,7 +7923,6 @@ async def test_stream_messages_dedupe_state(
assert chunks[0][1]["langgraph_node"] == "call_model"
@NEEDS_CONTEXTVARS
async def test_interrupt_subgraph_reenter_checkpointer_true(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -8078,7 +8034,6 @@ async def test_interrupt_subgraph_reenter_checkpointer_true(
assert bar_values == [None, "barbaz", "quxbaz"]
@NEEDS_CONTEXTVARS
async def test_handles_multiple_interrupts_from_tasks(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -8139,7 +8094,6 @@ async def test_handles_multiple_interrupts_from_tasks(
assert result[1] == "Added Will!"
@NEEDS_CONTEXTVARS
async def test_interrupts_in_tasks_surfaced_once(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -8194,7 +8148,6 @@ async def test_interrupts_in_tasks_surfaced_once(
assert result[1] == "Added Will!"
@NEEDS_CONTEXTVARS
async def test_task_before_interrupt_resume(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -8245,7 +8198,6 @@ async def test_task_before_interrupt_resume(
assert result == {"answers": ["answer1", "answer2"]}
@NEEDS_CONTEXTVARS
async def test_multiple_tasks_before_interrupt_resume(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -8285,7 +8237,6 @@ async def test_multiple_tasks_before_interrupt_resume(
assert result == {"computed": 12, "answer": "continue"}
@NEEDS_CONTEXTVARS
async def test_no_redundant_put_writes_for_cached_task(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -8329,7 +8280,6 @@ async def test_no_redundant_put_writes_for_cached_task(
)
@NEEDS_CONTEXTVARS
async def test_node_before_interrupt_resume_graph_api(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -8383,7 +8333,6 @@ async def test_node_before_interrupt_resume_graph_api(
}
@NEEDS_CONTEXTVARS
async def test_multiple_nodes_before_interrupt_resume_graph_api(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -8429,7 +8378,6 @@ async def test_multiple_nodes_before_interrupt_resume_graph_api(
assert result == {"value": 12, "answer": "continue"}
@NEEDS_CONTEXTVARS
async def test_node_before_multiple_interrupt_cycles_graph_api(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -8874,7 +8822,6 @@ async def test_draw_invalid():
}
@NEEDS_CONTEXTVARS
async def test_imp_exception(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -9534,7 +9481,6 @@ async def test_subgraph_streaming_node_output_messages_async() -> None:
assert [m.content for m in in_node] == ["hi there"]
@NEEDS_CONTEXTVARS
async def test_null_resume_disallowed_with_multiple_interrupts(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -9637,7 +9583,6 @@ async def test_astream_waiter_cleanup_on_cancel(
assert all(t.done() for t in recorded_tasks)
@NEEDS_CONTEXTVARS
async def test_interrupt_stream_mode_values(async_checkpointer: BaseCheckpointSaver):
"""Test that interrupts are surfaced on 'values' stream mode"""
@@ -9831,7 +9776,6 @@ async def test_graph_error_handler_async_runtime_info() -> None:
assert isinstance(captured["from_node_error"], BaseException)
@NEEDS_CONTEXTVARS
async def test_graph_error_handler_does_not_swallow_interrupt_concurrent() -> None:
"""When a graph error handler is configured and a node calls interrupt()
concurrently with other nodes, the interrupt must still be raised — not
@@ -4,7 +4,6 @@ from __future__ import annotations
import asyncio
import operator
import sys
import time
from typing import Annotated, Any
@@ -25,11 +24,6 @@ from langgraph.stream.run_stream import AsyncGraphRunStream, GraphRunStream
from langgraph.stream.transformers import MessagesTransformer, ValuesTransformer
from langgraph.types import StreamWriter, interrupt
NEEDS_CONTEXTVARS = pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ is required for async contextvars support",
)
TS = int(time.time() * 1000)
@@ -560,7 +554,6 @@ class TestStreamV2SyncInterrupt:
@pytest.mark.anyio
@NEEDS_CONTEXTVARS
class TestStreamV2Async:
async def test_values_projection(self) -> None:
run = await _build_simple_graph().astream_events(
@@ -788,7 +781,6 @@ class TestStreamV2Async:
@pytest.mark.anyio
@NEEDS_CONTEXTVARS
class TestStreamV2AsyncErrors:
async def test_error_propagation_output(self) -> None:
run = await _build_error_graph().astream_events(
@@ -829,7 +821,6 @@ class TestStreamV2AsyncErrors:
@pytest.mark.anyio
@NEEDS_CONTEXTVARS
class TestStreamV2AsyncInterrupt:
async def test_interrupted(self) -> None:
run = await _build_interrupt_graph().astream_events(
@@ -1669,7 +1660,6 @@ class TestAsyncTransformerLane:
# ---------------------------------------------------------------------------
@NEEDS_CONTEXTVARS
class TestMemoryBounds:
def test_sync_subscribed_buffer_stays_at_most_one_between_yields(self) -> None:
run = _build_simple_graph().stream_events(
@@ -1,5 +1,4 @@
import operator
import sys
from collections.abc import Callable
from contextlib import contextmanager
from threading import Event
@@ -32,10 +31,6 @@ pytestmark = [
pytest.mark.skipif(NO_DOCKER, reason="needs Postgres"),
]
NEEDS_CONTEXTVARS = pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ is required for async contextvars support",
)
SYNC = [
_checkpointer_postgres,
@@ -444,7 +439,6 @@ def test_keep_latest_refuses_a_batch_with_a_delta_channel_thread(
assert delta_graph.get_state(_config("delta")) == delta_before
@NEEDS_CONTEXTVARS
@pytest.mark.parametrize("make_checkpointer", ASYNC)
async def test_akeep_latest_keeps_a_pending_interrupt_resumable(
make_checkpointer: Any,
@@ -35,10 +35,6 @@ if NO_DOCKER:
pytestmark = pytest.mark.anyio
NEEDS_CONTEXTVARS = pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ is required for async contextvars support",
)
SKIP_PYTHON_314 = pytest.mark.skipif(
sys.version_info >= (3, 14),
@@ -1460,7 +1456,6 @@ def get_message_dict(msg: BaseMessage | dict):
}
@NEEDS_CONTEXTVARS
@SKIP_PYTHON_314
async def test_remote_graph_basic_invoke(remote_graph: RemoteGraph) -> None:
# Basic smoke test of the remote graph
@@ -1497,7 +1492,6 @@ uid_pattern = re.compile(
)
@NEEDS_CONTEXTVARS
@SKIP_PYTHON_314
async def test_remote_graph_stream_messages_tuple(
nested_graph: Pregel, nested_remote_graph: Pregel
-25
View File
@@ -1,7 +1,6 @@
import asyncio
import contextlib
import operator
import sys
import threading
import time
from collections import deque
@@ -68,23 +67,6 @@ from langgraph.types import (
interrupt,
)
NEEDS_CONTEXTVARS = pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ is required for async contextvars support",
)
# `asyncio.Task.cancelling()` is Python 3.11+. The LSD-1507 fix in
# `langgraph/pregel/_retry.py` falls back to a no-op on 3.10 (preserves the
# existing CancelledError-as-silent-tear-down behaviour) because there is no
# reliable way to distinguish user-raised from framework-initiated
# cancellation without that API. Tests for the converted behaviour gate on
# the same Python version boundary.
NEEDS_TASK_CANCELLING = pytest.mark.skipif(
sys.version_info < (3, 11),
reason="LSD-1507 user-cancellation conversion requires Python 3.11+ "
"(asyncio.Task.cancelling)",
)
def test_should_retry_on_single_exception():
"""Test retry with a single exception type."""
@@ -1508,7 +1490,6 @@ async def test_state_graph_add_node_timeout_composes_with_retry():
assert len(attempts) == 2
@NEEDS_CONTEXTVARS
@pytest.mark.anyio
async def test_task_decorator_timeout_e2e():
@task(timeout=TimeoutPolicy(idle_timeout=0.05))
@@ -1524,7 +1505,6 @@ async def test_task_decorator_timeout_e2e():
await workflow.ainvoke(1)
@NEEDS_CONTEXTVARS
@pytest.mark.anyio
async def test_task_decorator_preserves_user_idle_timeout_kwarg():
@task(timeout=TimeoutPolicy(idle_timeout=1.0))
@@ -1539,7 +1519,6 @@ async def test_task_decorator_preserves_user_idle_timeout_kwarg():
assert await workflow.ainvoke(5) == 5
@NEEDS_CONTEXTVARS
@pytest.mark.anyio
async def test_task_decorator_preserves_user_timeout_kwarg():
@task(timeout=1.0)
@@ -2865,7 +2844,6 @@ def test_error_handler_resumes_after_crash_multiple_nodes():
assert "recovered_b:b" in result["results"]
@NEEDS_TASK_CANCELLING
@pytest.mark.anyio
async def test_arun_with_retry_user_raised_cancelled_becomes_node_cancelled():
class UserCancelsProc:
@@ -2881,7 +2859,6 @@ async def test_arun_with_retry_user_raised_cancelled_becomes_node_cancelled():
assert isinstance(excinfo.value.__cause__, asyncio.CancelledError)
@NEEDS_TASK_CANCELLING
@pytest.mark.anyio
async def test_arun_with_retry_user_raised_cancelled_with_timeout_policy():
"""The timeout path runs the node in a child task; the conversion must
@@ -2913,7 +2890,6 @@ def test_run_with_retry_sync_node_raising_cancelled_becomes_node_cancelled():
assert isinstance(excinfo.value.__cause__, asyncio.CancelledError)
@NEEDS_TASK_CANCELLING
@pytest.mark.anyio
async def test_arun_with_retry_external_cancel_propagates_as_cancelled():
"""When the asyncio task running ``arun_with_retry`` is cancelled from the
@@ -2953,7 +2929,6 @@ async def test_arun_with_retry_external_cancel_propagates_as_cancelled():
assert not isinstance(observed[0], NodeCancelledError)
@NEEDS_TASK_CANCELLING
@pytest.mark.anyio
async def test_pregel_user_raised_cancellederror_fails_run():
"""End-to-end: a two-branch graph where one branch raises
@@ -8,7 +8,6 @@ from __future__ import annotations
import copy
import operator
import sys
from dataclasses import dataclass
from typing import Annotated, Any, TypeVar, assert_type
@@ -61,11 +60,6 @@ from langgraph.types import (
)
from tests.fake_chat import FakeChatModel
NEEDS_CONTEXTVARS = pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ is required for async contextvars support",
)
# --- state and graph builders ---
@@ -589,7 +583,6 @@ class TestV2StreamAsync:
assert isinstance(metadata, dict)
assert "langgraph_node" in metadata
@NEEDS_CONTEXTVARS
@pytest.mark.anyio
async def test_custom(self) -> None:
graph = _make_custom_graph()
@@ -724,7 +717,6 @@ class TestV2InvokeAsync:
assert result["value"] == "x_a_b"
assert result["items"] == ["a", "b"]
@NEEDS_CONTEXTVARS
@pytest.mark.anyio
async def test_ainvoke_v2_graph_output_with_interrupts(self) -> None:
def my_node(state: SimpleState) -> dict[str, Any]:
@@ -9,7 +9,6 @@ results through a single stream_events(version="v3") / astream_events(version="v
from __future__ import annotations
import operator
import sys
from typing import Annotated, Any
import pytest
@@ -28,12 +27,6 @@ from langgraph.stream import StreamChannel, StreamTransformer
from langgraph.stream._types import ProtocolEvent
from langgraph.types import StreamWriter, interrupt
NEEDS_CONTEXTVARS = pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ is required for async contextvars support",
)
# ---------------------------------------------------------------------------
# State and graph builders
# ---------------------------------------------------------------------------
@@ -531,7 +524,6 @@ class TestStreamV2E2EErrors:
@pytest.mark.anyio
@NEEDS_CONTEXTVARS
class TestStreamV2E2EAsync:
async def test_all_projections_async(self) -> None:
"""Async run exercises values projection."""
@@ -22,7 +22,6 @@ and v3's explicit-default semantics preserved.
from __future__ import annotations
import sys
from collections.abc import AsyncIterator, Callable
from dataclasses import dataclass
from typing import Any
@@ -36,11 +35,6 @@ from langgraph.errors import GraphDrained
from langgraph.graph import StateGraph
from langgraph.runtime import RunControl, Runtime
NEEDS_CONTEXTVARS = pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ is required for async contextvars support",
)
@dataclass
class _Ctx:
@@ -91,7 +85,6 @@ class TestKwargForwardingSync:
@pytest.mark.anyio
@NEEDS_CONTEXTVARS
class TestKwargForwardingAsync:
async def test_context_reaches_node(self) -> None:
run = await _build_context_reading_graph().astream_events(
@@ -1,4 +1,3 @@
import sys
from typing import Any
import pytest
@@ -13,11 +12,6 @@ from langgraph.graph.state import CompiledStateGraph
pytestmark = pytest.mark.anyio
NEEDS_CONTEXTVARS = pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ is required for async contextvars support",
)
@tool
def echo(text: str) -> str:
@@ -112,7 +106,6 @@ def test_task_events_stream_under_the_graph_namespace(
assert [_summary(part) for part in parts] == _CHAT_AND_ECHO_EVENTS
@NEEDS_CONTEXTVARS
@_TASK_CALLERS
@pytest.mark.parametrize("subgraphs", [False, True])
async def test_task_events_stream_under_the_graph_namespace_async(
@@ -186,7 +179,6 @@ def test_child_graph_streams_only_to_the_node_streaming_it(
assert len(received) == len(_CHAT_AND_ECHO_EVENTS)
@NEEDS_CONTEXTVARS
@_CHILD_CONFIGS
async def test_child_graph_streams_only_to_the_node_streaming_it_async(
child_config: dict | None,
@@ -232,7 +224,6 @@ def test_child_graph_on_its_own_thread_streams_to_a_caller_streaming_subgraphs(
assert [_summary(part) for part in parts] == _CHAT_AND_ECHO_EVENTS
@NEEDS_CONTEXTVARS
@_OWN_THREAD_CONFIGS
async def test_child_graph_on_its_own_thread_streams_to_a_caller_streaming_subgraphs_async(
child_config: dict,
@@ -269,7 +260,6 @@ def test_node_gets_the_events_of_every_subgraph_it_streams() -> None:
assert counts == [len(_CHAT_AND_ECHO_EVENTS)] * 2
@NEEDS_CONTEXTVARS
async def test_node_gets_the_events_of_every_subgraph_it_streams_async() -> None:
sub = _one_node_graph(_achat_and_echo)
counts = []
@@ -1,5 +1,4 @@
import operator
import sys
import uuid
from typing import Annotated
@@ -17,10 +16,6 @@ from langgraph.graph.state import CompiledStateGraph
from langgraph.types import Command, Durability, Interrupt, RetryPolicy, interrupt
pytestmark = pytest.mark.anyio
NEEDS_CONTEXTVARS = pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ is required for async contextvars support",
)
UNKNOWN_ID = "0" * 32
@@ -395,7 +390,6 @@ def test_a_superseded_checkpoint_is_not_checked(
graph.invoke(Command(resume={ids["a?"]: "again", ids["b?"]: "again"}), pinned)
@NEEDS_CONTEXTVARS
async def test_unknown_id_is_refused_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -410,7 +404,6 @@ async def test_unknown_id_is_refused_async(
assert {i.value for i in state.interrupts} == {"a?", "b?"}
@NEEDS_CONTEXTVARS
async def test_a_retried_node_reuses_its_answer_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -12,7 +12,6 @@ one where no subgraph is declared, such as a subagent a tool invokes, and
finding the subgraph a namespace names.
"""
import sys
from typing import Annotated, Any
from uuid import uuid4
@@ -30,11 +29,6 @@ from tests.any_str import AnyStr
pytestmark = pytest.mark.anyio
NEEDS_CONTEXTVARS = pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ is required for async contextvars support",
)
class ParentState(TypedDict):
result: str
@@ -43,7 +37,6 @@ class ParentState(TypedDict):
# -- checkpointer=None (stateless) --
@NEEDS_CONTEXTVARS
async def test_stateless_interrupt_resume_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -99,7 +92,6 @@ async def test_stateless_interrupt_resume_async(
assert result == {"result": "Done"}
@NEEDS_CONTEXTVARS
async def test_stateless_state_resets_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -161,7 +153,6 @@ async def test_stateless_state_resets_async(
]
@NEEDS_CONTEXTVARS
async def test_stateless_state_resets_with_interrupt_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -246,7 +237,6 @@ async def test_stateless_state_resets_with_interrupt_async(
# -- checkpointer=False --
@NEEDS_CONTEXTVARS
async def test_checkpointer_false_no_persistence_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -311,7 +301,6 @@ async def test_checkpointer_false_no_persistence_async(
# -- checkpointer=True (stateful) --
@NEEDS_CONTEXTVARS
async def test_stateful_state_accumulates_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -385,7 +374,6 @@ async def test_stateful_state_accumulates_async(
]
@NEEDS_CONTEXTVARS
async def test_stateful_state_accumulates_with_interrupt_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -477,7 +465,6 @@ async def test_stateful_state_accumulates_with_interrupt_async(
]
@NEEDS_CONTEXTVARS
async def test_stateful_interrupt_resume_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -570,7 +557,6 @@ async def test_stateful_interrupt_resume_async(
]
@NEEDS_CONTEXTVARS
async def test_stateful_namespace_isolation_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -669,7 +655,6 @@ async def test_stateful_namespace_isolation_async(
]
@NEEDS_CONTEXTVARS
async def test_child_with_own_thread_id_keeps_namespace_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -791,7 +776,6 @@ async def _run_tool_subgraph(
return parent, (await _namespace_configs(parent))["tools"]
@NEEDS_CONTEXTVARS
async def test_undeclared_subgraph_get_state_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -807,7 +791,6 @@ async def test_undeclared_subgraph_get_state_async(
assert state.config["configurable"]["checkpoint_ns"] == AnyStr("tools:")
@NEEDS_CONTEXTVARS
async def test_undeclared_subgraph_get_state_history_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -827,7 +810,6 @@ async def test_undeclared_subgraph_get_state_history_async(
}
@NEEDS_CONTEXTVARS
async def test_undeclared_subgraph_update_state_raises_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -841,7 +823,6 @@ async def test_undeclared_subgraph_update_state_raises_async(
assert len([s async for s in parent.aget_state_history(ns_config)]) == 3
@NEEDS_CONTEXTVARS
@pytest.mark.parametrize(
("parent_schema", "subagent_schema"),
[(DeltaMessagesState, NotesState), (MessagesState, DeltaNotesState)],
@@ -875,7 +856,6 @@ async def test_undeclared_subgraph_read_across_messages_channel_types_async(
]
@NEEDS_CONTEXTVARS
@pytest.mark.parametrize("review_declared", [False, True])
async def test_prefix_named_namespaces_resolve_to_their_own_graph_async(
async_checkpointer: BaseCheckpointSaver, review_declared: bool
@@ -17,7 +17,6 @@ Key concepts:
"""
import operator
import sys
from typing import Annotated
import pytest
@@ -30,11 +29,6 @@ from langgraph.types import Command, interrupt
pytestmark = pytest.mark.anyio
NEEDS_CONTEXTVARS = pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ is required for async contextvars support",
)
class State(TypedDict):
value: Annotated[list[str], operator.add]
@@ -75,7 +69,6 @@ def _checkpoint_summary(history: list) -> list[dict]:
# ---------------------------------------------------------------------------
@NEEDS_CONTEXTVARS
async def test_replay_reruns_nodes_after_checkpoint(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -119,7 +112,6 @@ async def test_replay_reruns_nodes_after_checkpoint(
assert "node_a" not in called
@NEEDS_CONTEXTVARS
async def test_replay_from_final_checkpoint_is_noop(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -151,7 +143,6 @@ async def test_replay_from_final_checkpoint_is_noop(
assert called == []
@NEEDS_CONTEXTVARS
async def test_fork_reruns_with_modified_state(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -191,7 +182,6 @@ async def test_fork_reruns_with_modified_state(
assert fork_result == {"value": ["a", "x", "b"]}
@NEEDS_CONTEXTVARS
async def test_multiple_forks_from_same_checkpoint(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -236,7 +226,6 @@ async def test_multiple_forks_from_same_checkpoint(
# ---------------------------------------------------------------------------
@NEEDS_CONTEXTVARS
async def test_replay_from_before_interrupt_refires(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -296,7 +285,6 @@ async def test_replay_from_before_interrupt_refires(
assert call_count["node_b"] == 1 # NOT re-executed (after interrupt)
@NEEDS_CONTEXTVARS
async def test_replay_interrupt_stable_across_replays(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -347,7 +335,6 @@ async def test_replay_interrupt_stable_across_replays(
assert all(r["value"] == results[0]["value"] for r in results)
@NEEDS_CONTEXTVARS
async def test_fork_from_before_interrupt_refires(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -400,7 +387,6 @@ async def test_fork_from_before_interrupt_refires(
assert final == {"value": ["a", "forked", "human:world", "b"]}
@NEEDS_CONTEXTVARS
async def test_fork_from_interrupt_checkpoint_refires(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -461,7 +447,6 @@ async def test_fork_from_interrupt_checkpoint_refires(
# ---------------------------------------------------------------------------
@NEEDS_CONTEXTVARS
async def test_sequential_interrupts_fork_from_middle(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -541,7 +526,6 @@ async def test_sequential_interrupts_fork_from_middle(
assert "interrupt_2" not in called
@NEEDS_CONTEXTVARS
async def test_multiple_interrupts_in_one_node(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -593,7 +577,6 @@ async def test_multiple_interrupts_in_one_node(
# ---------------------------------------------------------------------------
@NEEDS_CONTEXTVARS
async def test_subgraph_replay_from_before(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -656,7 +639,6 @@ async def test_subgraph_replay_from_before(
assert "parent_node" not in called
@NEEDS_CONTEXTVARS
async def test_subgraph_fork_from_before(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -724,7 +706,6 @@ async def test_subgraph_fork_from_before(
# ---------------------------------------------------------------------------
@NEEDS_CONTEXTVARS
async def test_subgraph_interrupt_replay_from_parent(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -797,7 +778,6 @@ async def test_subgraph_interrupt_replay_from_parent(
assert "__interrupt__" in replay_result
@NEEDS_CONTEXTVARS
async def test_subgraph_interrupt_replay_from_interrupt_checkpoint(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -877,7 +857,6 @@ async def test_subgraph_interrupt_replay_from_interrupt_checkpoint(
assert "__interrupt__" in replay_result
@NEEDS_CONTEXTVARS
async def test_subgraph_interrupt_full_flow(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -971,7 +950,6 @@ async def test_subgraph_interrupt_full_flow(
assert "post" in final_result["value"]
@NEEDS_CONTEXTVARS
async def test_subgraph_interrupt_full_flow_no_sub_checkpointer(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -1059,7 +1037,6 @@ async def test_subgraph_interrupt_full_flow_no_sub_checkpointer(
assert "post" in final_result["value"]
@NEEDS_CONTEXTVARS
async def test_subgraph_time_travel_to_first_interrupt_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -1132,7 +1109,6 @@ async def test_subgraph_time_travel_to_first_interrupt_async(
assert "ask_1" in called
@NEEDS_CONTEXTVARS
async def test_subgraph_time_travel_to_second_interrupt_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -1207,7 +1183,6 @@ async def test_subgraph_time_travel_to_second_interrupt_async(
assert "ask_1" not in called
@NEEDS_CONTEXTVARS
async def test_subgraph_time_travel_after_completion_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -1269,7 +1244,6 @@ async def test_subgraph_time_travel_after_completion_async(
assert "ask_2:answer_2" in replay_result["value"]
@NEEDS_CONTEXTVARS
async def test_replay_from_before_interrupt_then_resume_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -1365,7 +1339,6 @@ async def test_replay_from_before_interrupt_then_resume_async(
]
@NEEDS_CONTEXTVARS
async def test_subgraph_time_travel_resume_from_first_interrupt_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -1474,7 +1447,6 @@ async def test_subgraph_time_travel_resume_from_first_interrupt_async(
]
@NEEDS_CONTEXTVARS
async def test_subgraph_time_travel_resume_from_second_interrupt_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -1579,7 +1551,6 @@ async def test_subgraph_time_travel_resume_from_second_interrupt_async(
]
@NEEDS_CONTEXTVARS
async def test_subgraph_time_travel_checkpoint_pattern_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -1654,7 +1625,6 @@ async def test_subgraph_time_travel_checkpoint_pattern_async(
]
@NEEDS_CONTEXTVARS
async def test_3_levels_deep_time_travel_to_first_interrupt_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -1732,7 +1702,6 @@ async def test_3_levels_deep_time_travel_to_first_interrupt_async(
assert "ask_1" in called
@NEEDS_CONTEXTVARS
async def test_3_levels_deep_time_travel_to_second_interrupt_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -1811,7 +1780,6 @@ async def test_3_levels_deep_time_travel_to_second_interrupt_async(
assert "ask_1" not in called
@NEEDS_CONTEXTVARS
async def test_3_levels_deep_time_travel_to_middle_subgraph_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -1883,7 +1851,6 @@ async def test_3_levels_deep_time_travel_to_middle_subgraph_async(
assert "__interrupt__" in fork_result
@NEEDS_CONTEXTVARS
async def test_3_levels_deep_middle_has_interrupts_async(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -1995,7 +1962,6 @@ async def test_3_levels_deep_middle_has_interrupts_async(
# ---------------------------------------------------------------------------
@NEEDS_CONTEXTVARS
async def test_copy_fork_retriggers_interrupt(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -2048,7 +2014,6 @@ async def test_copy_fork_retriggers_interrupt(
assert final == {"value": ["a", "human:new_answer", "b"]}
@NEEDS_CONTEXTVARS
async def test_copy_fork_creates_sibling_checkpoint(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -2087,7 +2052,6 @@ async def test_copy_fork_creates_sibling_checkpoint(
assert regular_state.metadata["source"] == "update"
@NEEDS_CONTEXTVARS
async def test_update_state_with_none_values(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -2137,7 +2101,6 @@ async def test_update_state_with_none_values(
# ---------------------------------------------------------------------------
@NEEDS_CONTEXTVARS
async def test_get_state_with_subgraphs_returns_subgraph_state(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -2182,7 +2145,6 @@ async def test_get_state_with_subgraphs_returns_subgraph_state(
assert "thread_id" in sub_config["configurable"]
@NEEDS_CONTEXTVARS
async def test_checkpoint_ns_accessible_in_subgraph(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -2229,10 +2191,6 @@ async def test_checkpoint_ns_accessible_in_subgraph(
# ---------------------------------------------------------------------------
@pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ required for async test",
)
async def test_stateful_subgraph_retains_state_on_parent_replay(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -2315,10 +2273,6 @@ async def test_stateful_subgraph_retains_state_on_parent_replay(
assert started[0] == ("step_a", {"value": ["a:a1", "b:b1"]})
@pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ required for async test",
)
async def test_stateful_subgraph_retains_state_on_parent_fork(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -2391,16 +2345,11 @@ async def test_stateful_subgraph_retains_state_on_parent_fork(
assert observed[0] == ("step_a", {"value": ["a:a1", "b:b1"]})
@pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ required for async test",
)
# ---------------------------------------------------------------------------
# Section 8: Append-only checkpoint history (branching / forking)
# ---------------------------------------------------------------------------
@NEEDS_CONTEXTVARS
async def test_replay_creates_branch_preserving_old_checkpoints(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -2525,7 +2474,6 @@ async def test_replay_creates_branch_preserving_old_checkpoints(
assert latest.config["configurable"]["checkpoint_id"] not in original_ids
@NEEDS_CONTEXTVARS
async def test_replay_creates_branch_in_subgraph(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -2619,7 +2567,6 @@ async def test_replay_creates_branch_in_subgraph(
assert latest.values == {"value": ["p_start", "p_end"], "sub_value": ["sub2"]}
@NEEDS_CONTEXTVARS
async def test_fork_creates_branch_preserving_old_checkpoints(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -2746,7 +2693,6 @@ async def test_fork_creates_branch_preserving_old_checkpoints(
assert latest.config["configurable"]["checkpoint_id"] not in original_ids
@NEEDS_CONTEXTVARS
async def test_fork_creates_branch_in_subgraph(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -2844,7 +2790,6 @@ async def test_fork_creates_branch_in_subgraph(
}
@NEEDS_CONTEXTVARS
async def test_stateless_subgraph_starts_fresh_on_parent_replay(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -2925,7 +2870,6 @@ async def test_stateless_subgraph_starts_fresh_on_parent_replay(
assert started[0] == ("step_a", {"value": []})
@NEEDS_CONTEXTVARS
async def test_stateful_subgraph_loads_latest_after_replay(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -2989,7 +2933,6 @@ async def test_stateful_subgraph_loads_latest_after_replay(
assert observed[0] == ("sub_step", {"value": ["s", "s"]})
@NEEDS_CONTEXTVARS
async def test_three_level_nested_subgraph_loads_state_on_replay(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -3081,7 +3024,6 @@ async def test_three_level_nested_subgraph_loads_state_on_replay(
]
@NEEDS_CONTEXTVARS
async def test_three_level_nested_subgraph_loads_state_on_fork(
async_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -3158,7 +3100,6 @@ async def test_three_level_nested_subgraph_loads_state_on_fork(
]
@NEEDS_CONTEXTVARS
async def test_replay_from_first_invocation_checkpoint(
async_checkpointer: BaseCheckpointSaver,
) -> None:
+2 -3
View File
@@ -13,7 +13,6 @@ from langchain_core.runnables import RunnableConfig
from typing_extensions import TypedDict
from langgraph._internal._runnable import (
ASYNCIO_ACCEPTS_CONTEXT,
RunnableCallable,
RunnableSeq,
)
@@ -227,7 +226,7 @@ async def test_trace_policy_scrubs_tracer_not_messages_stream_async() -> None:
]
assert streamed == ["model reply", "from node"]
_assert_scrubbed_node_run(tracer, model_is_child=ASYNCIO_ACCEPTS_CONTEXT)
_assert_scrubbed_node_run(tracer, model_is_child=True)
@pytest.mark.anyio
@@ -252,7 +251,7 @@ async def test_trace_policy_scrubs_tracer_not_astream_events() -> None:
"model reply",
"from node",
]
_assert_scrubbed_node_run(tracer, model_is_child=ASYNCIO_ACCEPTS_CONTEXT)
_assert_scrubbed_node_run(tracer, model_is_child=True)
class _HandlerWithTapMethods(BaseCallbackHandler):
@@ -1,5 +1,4 @@
import json
import sys
import time
from collections.abc import Callable
from typing import Any, TypeVar
@@ -59,7 +58,6 @@ def wait_for(
@pytest.mark.skip("This test times out in CI")
async def test_nested_tracing():
lt_py_311 = sys.version_info < (3, 11)
mock_client = _get_mock_client()
class State(TypedDict):
@@ -70,10 +68,7 @@ async def test_nested_tracing():
return await child_graph.ainvoke(content)
async def parent_node(state: State, config: RunnableConfig) -> State:
if lt_py_311:
result = await some_traceable(state, langsmith_extra={"config": config})
else:
result = await some_traceable(state)
result = await some_traceable(state)
return {"value": f"parent_{result['value']}"}
async def child_node(state: State) -> State:
-5
View File
@@ -1,7 +1,6 @@
import copy
import functools
import pickle
import sys
import uuid
from collections.abc import Callable
from dataclasses import dataclass
@@ -146,10 +145,6 @@ def test_runnable_callable_tracing_nested(rt_graph: CompiledStateGraph) -> None:
assert isinstance(res["node_run_id"], uuid.UUID)
@pytest.mark.skipif(
sys.version_info < (3, 11),
reason="Python 3.11+ is required for async contextvars support",
)
async def test_runnable_callable_tracing_nested_async(
rt_graph: CompiledStateGraph,
) -> None:
+3 -4
View File
@@ -1705,12 +1705,11 @@ inmem = [
requires-dist = [
{ name = "click", specifier = ">=8.1.7" },
{ name = "httpx", specifier = ">=0.24.0" },
{ name = "langgraph-api", marker = "python_full_version >= '3.11' and extra == 'inmem'", specifier = ">=0.5.35,<1.0.0" },
{ name = "langgraph-runtime-inmem", marker = "python_full_version >= '3.11' and extra == 'inmem'", specifier = ">=0.7" },
{ name = "langgraph-sdk", marker = "python_full_version >= '3.11'", specifier = ">=0.1.0" },
{ name = "langgraph-api", marker = "extra == 'inmem'", specifier = ">=0.5.35,<1.0.0" },
{ name = "langgraph-runtime-inmem", marker = "extra == 'inmem'", specifier = ">=0.7" },
{ name = "langgraph-sdk", specifier = ">=0.1.0" },
{ name = "pathspec", specifier = ">=0.11.0" },
{ name = "python-dotenv", specifier = ">=0.8.0" },
{ name = "tomli", marker = "python_full_version < '3.11'", specifier = ">=2.0.1" },
]
provides-extras = ["inmem"]
@@ -7,11 +7,9 @@ declared as NotRequired in the custom state schema, the ToolNode should graceful
handle missing fields by injecting None instead of raising KeyError.
"""
import sys
from typing import Annotated, NotRequired
from unittest.mock import Mock
import pytest
from langchain_core.messages import AIMessage, AnyMessage, HumanMessage, ToolMessage
from langchain_core.tools import tool
from langgraph.graph.message import add_messages
@@ -78,10 +76,6 @@ def _create_config_with_runtime(store=None, state=None):
}
@pytest.mark.skipif(
sys.version_info < (3, 11),
reason="InjectedState field extraction from Optional[Annotated[...]] not supported on Python <3.11",
)
def test_injected_state_not_required_field_missing_injects_none():
"""Test that InjectedState with NotRequired field injects None when field is missing.
@@ -113,10 +107,6 @@ def test_injected_state_not_required_field_missing_injects_none():
assert "No city provided" in tool_msg.content
@pytest.mark.skipif(
sys.version_info < (3, 11),
reason="InjectedState field extraction from Optional[Annotated[...]] not supported on Python <3.11",
)
def test_injected_state_not_required_field_present_works():
"""Test that InjectedState with NotRequired field works when field IS present."""
tool_node = ToolNode([get_weather])
@@ -146,10 +136,6 @@ def test_injected_state_not_required_field_present_works():
assert "San Francisco" in tool_msg.content
@pytest.mark.skipif(
sys.version_info < (3, 11),
reason="InjectedState field extraction from Optional[Annotated[...]] not supported on Python <3.11",
)
def test_create_react_agent_injected_state_not_required_field_missing():
"""Test create_react_agent with InjectedState using NotRequired field that is missing.
@@ -180,10 +166,6 @@ def test_create_react_agent_injected_state_not_required_field_missing():
assert "No city provided" in tool_messages[0].content
@pytest.mark.skipif(
sys.version_info < (3, 11),
reason="InjectedState field extraction from Optional[Annotated[...]] not supported on Python <3.11",
)
def test_create_react_agent_injected_state_not_required_field_present():
"""Test create_react_agent with InjectedState using NotRequired field that IS present."""
model = FakeToolCallingModel(
-9
View File
@@ -1,14 +1,10 @@
from __future__ import annotations
import logging
import sys
from typing import Any, cast
import httpx
import orjson
logger = logging.getLogger(__name__)
class LangGraphError(Exception):
pass
@@ -215,9 +211,6 @@ async def _araise_for_status_typed(r: httpx.Response) -> None:
return
body = await _adecode_error_body(r)
err = _map_status_error(r, body)
# Log for older Python versions without Exception notes
if not (sys.version_info >= (3, 11)):
logger.error(f"Error from langgraph-api: {getattr(err, 'message', '')}")
raise err
@@ -226,6 +219,4 @@ def _raise_for_status_typed(r: httpx.Response) -> None:
return
body = _decode_error_body(r)
err = _map_status_error(r, body)
if not (sys.version_info >= (3, 11)):
logger.error(f"Error from langgraph-api: {getattr(err, 'message', '')}")
raise err