langgraph/libs/prebuilt/tests
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
..
__snapshots__ prebuilts hitl: fix branching logic + add structural snapshot tests (#4767) 2025-05-21 09:29:59 -04:00
__init__.py langgraph: separate prebuilt into a standalone package (#3589) 2025-02-26 18:33:07 -05:00
any_str.py chore: drop Python 3.9 (and syntax) (#6289) 2025-10-16 20:17:46 -04:00
compose-postgres.yml langgraph: separate prebuilt into a standalone package (#3589) 2025-02-26 18:33:07 -05:00
compose-redis.yml feat(langgraph): implement redis node level cache (#5834) 2025-08-11 09:19:34 -07:00
conftest.py chore(deps): upgrade dependencies with uv lock --upgrade (#6146) 2025-09-14 19:36:43 -04:00
conftest_checkpointer.py chore: drop Python 3.9 (and syntax) (#6289) 2025-10-16 20:17:46 -04:00
conftest_store.py chore: drop Python 3.9 (and syntax) (#6289) 2025-10-16 20:17:46 -04:00
memory_assert.py chore: enforce PLC0415 in tests for the remaining packages (#8547) 2026-08-07 09:40:18 -04:00
messages.py chore(prebuilt): Remove dead code from prebuilt tests (#5555) 2025-07-17 18:45:10 +00:00
model.py chore: drop Python 3.9 (and syntax) (#6289) 2025-10-16 20:17:46 -04:00
test_deprecation.py chore(deps): upgrade dependencies with uv lock --upgrade (#6146) 2025-09-14 19:36:43 -04:00
test_injected_state_not_required.py chore: enforce PLC0415 in tests for the remaining packages (#8547) 2026-08-07 09:40:18 -04:00
test_on_tool_call.py fix(prebuilt): make wrap_tool_call state overrides reach the tool (#9730) 2026-11-18 16:32:59 -05:00
test_react_agent.py feat(checkpoint): Validate checkpointer type at compile time (#6586) 2025-12-15 07:22:47 +00:00
test_react_agent_graph.py chore: drop Python 3.9 (and syntax) (#6289) 2025-10-16 20:17:46 -04:00
test_tool_call_transformer.py fix(langgraph): keep tool results out of v3 messages (#7838) 2026-05-19 11:36:16 -04:00
test_tool_node.py fix(langgraph,prebuilt): give Send-dispatched tool calls the same state as an edge (#9728) 2026-11-18 23:55:29 -05:00
test_tool_node_interceptor_unregistered.py feat: support dynamic tool calling via tool override in wrap_model_call (#6711) 2026-01-22 15:53:43 +00:00
test_tool_node_validation_error_filtering.py chore: port tool node improvements back to langgraph (#6321) 2025-10-29 09:58:06 -07:00
test_validation_node.py feat: adding cursory Python 3.14 support (#6298) 2025-10-17 08:26:52 -04:00