Compare commits

...
Author SHA1 Message Date
Elior Nataf Lackritz 7830b91a24 release(langgraph): 1.2.23 (#9742)
Bumps langgraph from 1.2.22 to 1.2.23, and raises the langgraph-prebuilt
floor to 1.1.3 so upgrading langgraph also brings the `ToolNode` side of
#9728.

Includes:

- Give tool calls dispatched with `Send` the same typed state as an edge
(#9728)
- Avoid warning races in dynamic schemas (#9716)
2026-11-19 00:28:16 -05:00
Elior Nataf Lackritz a03c71268e release(prebuilt): 1.1.3 (#9741)
Bumps langgraph-prebuilt from 1.1.2 to 1.1.3.

Includes:

- `ToolNode` gives tool calls sent with `Send("tools", [tool_call])` the
graph's typed state, with langgraph 1.2.23 (#9728)
- State overrides from `wrap_tool_call` now reach the tool (#9730)
2026-11-19 00:21:06 -05:00
Elior Nataf Lackritz 292106d223 fix(langgraph,prebuilt): give Send-dispatched tool calls the same state as an edge (#9728)
**Problem.** When tool calls reach `ToolNode` as a bare list,
`Send("tools", [tool_call])`, tools get the state as a plain dict of
channel values. That is the dispatch `create_agent` uses since #7594 and
langchain-ai/langchain#36960. On a graph whose state is a Pydantic model
or a dataclass, `ToolRuntime.state` and `InjectedState` (typed or not)
get a dict, and values that entered as JSON input stay dicts too, so a
`list[Item]` field arrives as a list of dicts. The same tools reached
through an edge, or through a `ToolCallWithContext` Send, get the model.

**Why.** `StateGraph` coerces state to the schema when it builds a
node's input, and a Send task's input is the Send arg. `ToolNode` reads
the state itself through `CONFIG_KEY_READ`, which returns raw channel
values, and it can't coerce them because it doesn't know the graph's
schema.

**Fix.** Pregel gives each Send task a `CONFIG_KEY_READ_STATE` function
that returns the state the node would get from an edge: its input keys,
managed values included, coerced to its input schema. It is the same
`_proc_input` call that builds a pull task's input. `ToolNode` uses it
for bare tool-call lists. Every other task sets the key to `None`, so a
graph running inside a Send task, such as a subagent called from a tool,
never reads its parent's state. Both packages change together because
`ToolNode` is the only reader of the key.

**Compatibility.** On the bare-list path, Pydantic and dataclass graphs
now get the model instead of a dict, and TypedDict graphs get the tools
node's input keys instead of every channel. Both match what an edge
delivers. `create_agent` graphs (TypedDict state, no managed values) see
the same state as before. With an older `langgraph` that doesn't set the
key, `ToolNode` keeps today's behavior.

`test_tool_node_send_tool_call_gets_same_state_as_edge` fails on main
for the Pydantic and dataclass schemas.
`test_tool_node_in_graph_run_by_send_gets_that_graphs_state` fails if
the other tasks stop setting the key to `None`.
2026-11-18 23:55:29 -05:00
9 changed files with 99 additions and 11 deletions

No files matched your search

@@ -37,6 +37,10 @@ CONFIG_KEY_SEND = sys.intern("__pregel_send")
# holds the `write` function that accepts writes to state/edges/reserved keys
CONFIG_KEY_READ = sys.intern("__pregel_read")
# holds the `read` function that returns a copy of the current state
CONFIG_KEY_READ_STATE = sys.intern("__pregel_read_state")
# holds a function that returns the state as the task's node gets it from an edge,
# set on Send tasks, whose input is the Send arg instead. Other tasks set it to None
# so a graph running inside a Send task never reads its parent's state
CONFIG_KEY_CALL = sys.intern("__pregel_call")
# holds the `call` function that accepts a node/func, args and returns a future
CONFIG_KEY_CHECKPOINTER = sys.intern("__pregel_checkpointer")
+13
View File
@@ -42,6 +42,7 @@ from langgraph._internal._constants import (
CONFIG_KEY_CHECKPOINTER,
CONFIG_KEY_NODE_ERROR,
CONFIG_KEY_READ,
CONFIG_KEY_READ_STATE,
CONFIG_KEY_RESUME_MAP,
CONFIG_KEY_RUNTIME,
CONFIG_KEY_SCRATCHPAD,
@@ -734,6 +735,7 @@ def prepare_single_task(
triggers,
),
),
CONFIG_KEY_READ_STATE: None,
CONFIG_KEY_CHECKPOINTER: (
checkpointer
or configurable.get(CONFIG_KEY_CHECKPOINTER)
@@ -911,6 +913,7 @@ def prepare_push_task_functional(
managed,
PregelTaskWrites(in_progress_task_path, name, writes, triggers),
),
CONFIG_KEY_READ_STATE: None,
CONFIG_KEY_CHECKPOINTER: (
checkpointer or configurable.get(CONFIG_KEY_CHECKPOINTER)
),
@@ -1081,6 +1084,15 @@ def prepare_push_task_send(
translated_task_path, packet.node, writes, triggers
),
),
CONFIG_KEY_READ_STATE: partial(
_proc_input,
proc,
managed,
channels,
for_execution=True,
scratchpad=scratchpad,
input_cache=None,
),
CONFIG_KEY_CHECKPOINTER: (
checkpointer or configurable.get(CONFIG_KEY_CHECKPOINTER)
),
@@ -1222,6 +1234,7 @@ def prepare_node_error_handler_task(
PUSH_TRIGGER,
),
),
CONFIG_KEY_READ_STATE: None,
CONFIG_KEY_CHECKPOINTER: (
checkpointer or configurable.get(CONFIG_KEY_CHECKPOINTER)
),
+2 -2
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "langgraph"
version = "1.2.22"
version = "1.2.23"
description = "Building stateful, multi-actor applications with LLMs"
authors = []
requires-python = ">=3.10"
@@ -27,7 +27,7 @@ dependencies = [
"langchain-core>=1.4.7,<2",
"langgraph-checkpoint>=4.3.0,<5.0.0",
"langgraph-sdk>=0.4.6,<0.5.0",
"langgraph-prebuilt>=1.1.0,<1.2.0",
"langgraph-prebuilt>=1.1.3,<1.2.0",
"xxhash>=3.5.0",
"pydantic>=2.7.4",
]
+2 -2
View File
@@ -1440,7 +1440,7 @@ wheels = [
[[package]]
name = "langgraph"
version = "1.2.22"
version = "1.2.23"
source = { editable = "." }
dependencies = [
{ name = "langchain-core" },
@@ -1827,7 +1827,7 @@ test = [
[[package]]
name = "langgraph-prebuilt"
version = "1.1.2"
version = "1.1.3"
source = { editable = "../prebuilt" }
dependencies = [
{ name = "langchain-core" },
+12 -2
View File
@@ -107,6 +107,12 @@ except ImportError: # `langgraph` before `is_invalid_resume` never marks resume
return False
try:
from langgraph._internal._constants import CONFIG_KEY_READ_STATE
except ImportError: # `langgraph` before `CONFIG_KEY_READ_STATE` never sets the key
CONFIG_KEY_READ_STATE = "__pregel_read_state"
# right now we use a dict as the default, can change this to AgentState, but depends
# on if this lives in LangChain or LangGraph... ideally would have some typed
# messages key
@@ -1332,7 +1338,8 @@ class ToolNode(RunnableCallable):
- `ToolCallWithContext` dict — legacy Send payload carrying an inlined
state snapshot; return `input["state"]`.
- list of `ToolCall` dicts — new Send payload with no inlined state;
hydrate state from channels via `CONFIG_KEY_READ`.
read the state this node would get from an edge, coerced to its
input schema (raw channel values on older `langgraph`).
- regular graph state (dict/list/BaseModel) — return `input` as-is.
"""
if isinstance(input, dict) and input.get("__type") == "tool_call_with_context":
@@ -1343,7 +1350,10 @@ class ToolNode(RunnableCallable):
and isinstance(input[-1], dict)
and input[-1].get("type") == "tool_call"
):
read = config.get(CONF, {}).get(CONFIG_KEY_READ)
conf = config.get(CONF, {})
if (read_state := conf.get(CONFIG_KEY_READ_STATE)) is not None:
return read_state()
read = conf.get(CONFIG_KEY_READ)
if read is None:
return {}
# Pregel installs CONFIG_KEY_READ as
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "langgraph-prebuilt"
version = "1.1.2"
version = "1.1.3"
description = "Library with high-level APIs for creating and executing LangGraph agents and tools."
authors = []
requires-python = ">=3.10"
+61
View File
@@ -3,6 +3,7 @@ import dataclasses
import json
import sys
import warnings
from collections.abc import Callable
from functools import partial
from typing import (
Annotated,
@@ -1573,6 +1574,66 @@ def test_tool_node_inject_state(schema_: type[T]) -> None:
assert tool_message.content == "hi?"
@pytest.mark.parametrize("schema_", _INJECTED_STATE_SCHEMAS)
def test_tool_node_send_tool_call_gets_same_state_as_edge(schema_: type[T]) -> None:
call = ToolCall(name="record", args={}, id="call_1", type="tool_call")
seen: list[tuple[type, type]] = []
def record(runtime: ToolRuntime, state: Annotated[T, InjectedState]) -> str:
"""Record the state types the tool gets."""
seen.append((type(runtime.state), type(state)))
return "ok"
def agent(state: Any) -> dict:
return {"messages": [AIMessage("", tool_calls=[call])]}
def state_types(route: Callable[[Any], str | list[Send]]) -> tuple[type, type]:
seen.clear()
graph = (
StateGraph(schema_)
.add_node("agent", agent)
.add_node("tools", ToolNode([record]))
.add_edge(START, "agent")
.add_conditional_edges("agent", route, ["tools"])
.compile()
)
graph.invoke({"messages": [], "foo": "bar"})
return seen[0]
by_send = state_types(lambda _: [Send("tools", [call])])
by_edge = state_types(lambda _: "tools")
assert by_send == by_edge
def test_tool_node_in_graph_run_by_send_gets_that_graphs_state() -> None:
call = ToolCall(name="record", args={}, id="call_1", type="tool_call")
seen: list[Any] = []
def record(runtime: ToolRuntime) -> str:
"""Record the state the tool gets."""
seen.append(runtime.state)
return "ok"
class State(TypedDict):
value: str
def call_tools(state: State) -> dict:
ToolNode([record]).invoke([call])
return {}
inner = StateGraph(State).add_node(call_tools).add_edge(START, "call_tools")
outer = (
StateGraph(State)
.add_node("inner", inner.compile())
.add_conditional_edges(
START, lambda _: [Send("inner", {"value": "inner"})], ["inner"]
)
.compile()
)
outer.invoke({"value": "outer"})
assert seen == [{"value": "inner"}]
def test_tool_node_inject_store() -> None:
store = InMemoryStore()
namespace = ("test",)
+2 -2
View File
@@ -381,7 +381,7 @@ wheels = [
[[package]]
name = "langgraph"
version = "1.2.22"
version = "1.2.23"
source = { editable = "../langgraph" }
dependencies = [
{ name = "langchain-core" },
@@ -607,7 +607,7 @@ test = [
[[package]]
name = "langgraph-prebuilt"
version = "1.1.2"
version = "1.1.3"
source = { editable = "." }
dependencies = [
{ name = "langchain-core" },
+2 -2
View File
@@ -394,7 +394,7 @@ wheels = [
[[package]]
name = "langgraph"
version = "1.2.22"
version = "1.2.23"
source = { editable = "../langgraph" }
dependencies = [
{ name = "langchain-core" },
@@ -526,7 +526,7 @@ test = [
[[package]]
name = "langgraph-prebuilt"
version = "1.1.2"
version = "1.1.3"
source = { editable = "../prebuilt" }
dependencies = [
{ name = "langchain-core" },