diff --git a/libs/langgraph/langgraph/types.py b/libs/langgraph/langgraph/types.py index 5fbc304b7..a400e4de9 100644 --- a/libs/langgraph/langgraph/types.py +++ b/libs/langgraph/langgraph/types.py @@ -507,6 +507,7 @@ def interrupt(value: Any) -> Any: # find previous resume values if scratchpad.resume: if idx < len(scratchpad.resume): + conf[CONFIG_KEY_SEND]([(RESUME, scratchpad.resume)]) return scratchpad.resume[idx] # find current resume value v = scratchpad.get_null_resume(True) diff --git a/libs/langgraph/tests/conftest.py b/libs/langgraph/tests/conftest.py index 4ef30b918..465cdc9d5 100644 --- a/libs/langgraph/tests/conftest.py +++ b/libs/langgraph/tests/conftest.py @@ -69,7 +69,7 @@ def cache(request: pytest.FixtureRequest) -> Iterator[BaseCache]: elif request.param == "redis": # Get worker ID for parallel test isolation worker_id = getattr(request.config, "workerinput", {}).get("workerid", "master") - + redis_client = redis.Redis( host="localhost", port=6379, db=0, decode_responses=False ) diff --git a/libs/langgraph/tests/test_pregel.py b/libs/langgraph/tests/test_pregel.py index 71283b673..8c9dda4fa 100644 --- a/libs/langgraph/tests/test_pregel.py +++ b/libs/langgraph/tests/test_pregel.py @@ -4805,7 +4805,10 @@ def test_interrupt_subgraph(sync_checkpointer: BaseCheckpointSaver): assert graph.invoke(Command(resume="bar"), thread1) -def test_interrupt_multiple(sync_checkpointer: BaseCheckpointSaver): +@pytest.mark.parametrize("resume_style", ["null", "map"]) +def test_interrupt_multiple( + sync_checkpointer: BaseCheckpointSaver, resume_style: Literal["null", "map"] +): class State(TypedDict): my_key: Annotated[str, operator.add] @@ -4821,7 +4824,8 @@ def test_interrupt_multiple(sync_checkpointer: BaseCheckpointSaver): graph = builder.compile(checkpointer=sync_checkpointer) thread1 = {"configurable": {"thread_id": "1"}} - assert [e for e in graph.stream({"my_key": "DE", "market": "DE"}, thread1)] == [ + result = [e for e in graph.stream({"my_key": "DE", "market": "DE"}, thread1)] + assert result == [ { "__interrupt__": ( Interrupt( @@ -4832,12 +4836,19 @@ def test_interrupt_multiple(sync_checkpointer: BaseCheckpointSaver): } ] - assert [ + result = [ event for event in graph.stream( - Command(resume="answer 1", update={"my_key": " foofoo "}), thread1 + Command( + resume="answer 1" + if resume_style == "null" + else {result[0]["__interrupt__"][0].id: "answer 1"}, + update={"my_key": " foofoo "}, + ), + thread1, ) - ] == [ + ] + assert result == [ { "__interrupt__": ( Interrupt( @@ -4851,7 +4862,13 @@ def test_interrupt_multiple(sync_checkpointer: BaseCheckpointSaver): assert [ event for event in graph.stream( - Command(resume="answer 2"), thread1, stream_mode="values" + Command( + resume="answer 2" + if resume_style == "null" + else {result[0]["__interrupt__"][0].id: "answer 2"} + ), + thread1, + stream_mode="values", ) ] == [ {"my_key": "DE foofoo "},