mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-11 20:27:54 +02:00
Add test to confirm only one root run is produced
This commit is contained in:
@@ -9823,12 +9823,18 @@ def test_send_to_nested_graphs(
|
||||
|
||||
graph = builder.compile(checkpointer=checkpointer)
|
||||
config = {"configurable": {"thread_id": "1"}}
|
||||
tracer = FakeTracer()
|
||||
|
||||
# invoke and pause at nested interrupt
|
||||
assert graph.invoke({"subjects": ["cats", "dogs"]}, config=config) == {
|
||||
assert graph.invoke(
|
||||
{"subjects": ["cats", "dogs"]}, config={**config, "callbacks": [tracer]}
|
||||
) == {
|
||||
"subjects": ["cats", "dogs"],
|
||||
"jokes": [],
|
||||
}
|
||||
assert len(tracer.runs) == 1, "Should produce exactly 1 root run"
|
||||
|
||||
# check state
|
||||
outer_state = graph.get_state(config)
|
||||
assert outer_state == StateSnapshot(
|
||||
values={"subjects": ["cats", "dogs"], "jokes": []},
|
||||
|
||||
@@ -8467,15 +8467,19 @@ async def test_send_to_nested_graphs(checkpointer_name: str) -> None:
|
||||
async with awith_checkpointer(checkpointer_name) as checkpointer:
|
||||
graph = builder.compile(checkpointer=checkpointer)
|
||||
config = {"configurable": {"thread_id": "1"}}
|
||||
tracer = FakeTracer()
|
||||
|
||||
# invoke and pause at nested interrupt
|
||||
assert await graph.ainvoke({"subjects": ["cats", "dogs"]}, config=config) == {
|
||||
assert await graph.ainvoke(
|
||||
{"subjects": ["cats", "dogs"]}, config={**config, "callbacks": [tracer]}
|
||||
) == {
|
||||
"subjects": ["cats", "dogs"],
|
||||
"jokes": [],
|
||||
}
|
||||
assert len(tracer.runs) == 1, "Should produce exactly 1 root run"
|
||||
|
||||
# check state
|
||||
outer_state = await graph.aget_state(config)
|
||||
|
||||
assert outer_state == StateSnapshot(
|
||||
values={"subjects": ["cats", "dogs"], "jokes": []},
|
||||
tasks=(
|
||||
|
||||
Reference in New Issue
Block a user