fix(langgraph): require langgraph-api>=0.9.0 for DeltaChannel

Use a `>=` bound (raise below 0.9.0) and simplify the check: drop the
module-level constant and the early-return ladder. Verified end-to-end
against real langgraph-api releases — 0.8.6 raises, 0.10.0 compiles.

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
This commit is contained in:
Sydney Runkle
2026-06-15 11:30:27 +00:00
co-authored by open-swe[bot] <open-swe@users.noreply.github.com>
parent 9752282073
commit 8cbd400a11
2 changed files with 15 additions and 22 deletions
+9 -16
View File
@@ -122,17 +122,13 @@ def _warn_invalid_state_schema(schema: type[Any] | Any) -> None:
)
_MIN_DELTA_CHANNEL_API_VERSION = Version("0.9.0")
def _check_delta_channel_api_support(channels: Mapping[str, Any]) -> None:
"""Raise if a `DeltaChannel` graph runs under an API server too old to support it.
`DeltaChannel` reconstruction depends on server-side support added in
`langgraph-api>0.9.0`. When running under an older API server, delta
channels fail at runtime, so we raise at compile time with an upgrade
hint. The check is skipped when `langgraph-api` is not installed (e.g.
local execution), since there is no API server to be incompatible.
`DeltaChannel` reconstruction needs server-side support added in
`langgraph-api>=0.9.0`, so we raise at compile time when an older API
server is installed. Skipped when `langgraph-api` is absent (local
execution) or the graph has no delta channel.
"""
if not any(isinstance(c, DeltaChannel) for c in channels.values()):
return
@@ -140,14 +136,11 @@ def _check_delta_channel_api_support(channels: Mapping[str, Any]) -> None:
api_version = metadata.version("langgraph-api")
except metadata.PackageNotFoundError:
return
if Version(api_version) > _MIN_DELTA_CHANNEL_API_VERSION:
return
raise RuntimeError(
f"`DeltaChannel` requires `langgraph-api>0.9.0`, but the installed "
f"version is {api_version}. Upgrade `langgraph-api` "
"(e.g. `pip install -U langgraph-api`) to use graphs that rely on "
"`DeltaChannel`."
)
if Version(api_version) < Version("0.9.0"):
raise RuntimeError(
f"`DeltaChannel` requires `langgraph-api>=0.9.0`, but {api_version} "
"is installed. Upgrade with `pip install -U langgraph-api`."
)
def _get_node_name(node: StateNode[Any, ContextT]) -> str:
@@ -1,7 +1,7 @@
"""Compile-time check that `DeltaChannel` graphs run under a supported API server.
`DeltaChannel` reconstruction relies on server-side support added in
`langgraph-api>0.9.0`. When running under an older API server, delta channels
`langgraph-api>=0.9.0`. When running under an older API server, delta channels
fail at runtime, so `StateGraph.compile` raises with an upgrade hint. The check
is skipped when `langgraph-api` is not installed (local execution).
"""
@@ -57,17 +57,17 @@ def api_version(monkeypatch: pytest.MonkeyPatch):
def test_delta_graph_raises_for_old_api(api_version) -> None:
api_version("0.9.0")
with pytest.raises(RuntimeError, match="requires `langgraph-api>0.9.0`"):
api_version("0.8.9")
with pytest.raises(RuntimeError, match="requires `langgraph-api>=0.9.0`"):
_delta_graph().compile()
def test_delta_graph_ok_for_new_api(api_version) -> None:
api_version("0.9.1")
def test_delta_graph_ok_for_min_api(api_version) -> None:
api_version("0.9.0")
_delta_graph().compile()
def test_delta_graph_ok_for_much_newer_api(api_version) -> None:
def test_delta_graph_ok_for_newer_api(api_version) -> None:
api_version("0.11.2")
_delta_graph().compile()