diff --git a/libs/langgraph/tests/test_pregel.py b/libs/langgraph/tests/test_pregel.py index 46dc876f7..48c15e133 100644 --- a/libs/langgraph/tests/test_pregel.py +++ b/libs/langgraph/tests/test_pregel.py @@ -15016,16 +15016,16 @@ def test_command_goto_with_static_breakpoints( class State(TypedDict): """The graph state.""" - foo: str + foo: Annotated[str, operator.add] def node1(state: State): return { - "foo": state["foo"] + "|node-1", + "foo": "|node-1", } def node2(state: State): return { - "foo": state["foo"] + "|node-2", + "foo": "|node-2", } builder = StateGraph(State) @@ -15041,4 +15041,4 @@ def test_command_goto_with_static_breakpoints( # Start the graph and interrupt at the first node graph.invoke({"foo": "abc"}, config) result = graph.invoke(Command(goto=["node2"]), config) - assert result == {"foo": "abc|node-2"} + assert result == {"foo": "abc|node-1|node-2|node-2"} diff --git a/libs/langgraph/tests/test_pregel_async.py b/libs/langgraph/tests/test_pregel_async.py index 5cc7f3312..cde54ae7c 100644 --- a/libs/langgraph/tests/test_pregel_async.py +++ b/libs/langgraph/tests/test_pregel_async.py @@ -13295,3 +13295,39 @@ async def test_multistep_plan(checkpointer_name: str): ], "plan": [], } + + +@pytest.mark.parametrize("checkpointer_name", ALL_CHECKPOINTERS_ASYNC) +async def test_command_goto_with_static_breakpoints(checkpointer_name: str) -> None: + """Use Command goto with static breakpoints.""" + + class State(TypedDict): + """The graph state.""" + + foo: Annotated[str, operator.add] + + def node1(state: State): + return { + "foo": "|node-1", + } + + def node2(state: State): + return { + "foo": "|node-2", + } + + builder = StateGraph(State) + builder.add_node("node1", node1) + builder.add_node("node2", node2) + builder.add_edge(START, "node1") + builder.add_edge("node1", "node2") + + async with awith_checkpointer(checkpointer_name) as checkpointer: + graph = builder.compile(checkpointer=checkpointer, interrupt_before=["node1"]) + + config = {"configurable": {"thread_id": str(uuid.uuid4())}} + + # Start the graph and interrupt at the first node + await graph.ainvoke({"foo": "abc"}, config) + result = await graph.ainvoke(Command(goto=["node2"]), config) + assert result == {"foo": "abc|node-1|node-2|node-2"}