From bde0c47cd9b50c3199c575bc0be863323f5236f8 Mon Sep 17 00:00:00 2001 From: Will Fu-Hinthorn Date: Wed, 8 Apr 2026 18:04:55 -0700 Subject: [PATCH] fix: handle non-deterministic ordering in test_imp_nested Nested tasks run concurrently so output order is non-deterministic. Sort intermediate results before comparison, matching the pattern already used by test_imp_task. Co-Authored-By: Claude Opus 4.6 (1M context) --- libs/langgraph/tests/test_pregel.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/libs/langgraph/tests/test_pregel.py b/libs/langgraph/tests/test_pregel.py index d6bfc95cc..95afe3e6e 100644 --- a/libs/langgraph/tests/test_pregel.py +++ b/libs/langgraph/tests/test_pregel.py @@ -1329,20 +1329,22 @@ def test_imp_nested( } thread1 = {"configurable": {"thread_id": "1"}} - assert [*graph.stream([0, 1], thread1, durability=durability)] == [ - {"submapper": "0"}, + result = [*graph.stream([0, 1], thread1, durability=durability)] + # nested tasks run concurrently so output order is non-deterministic + assert sorted(result[:-1], key=lambda d: str(d)) == [ {"mapper": "00"}, - {"submapper": "1"}, {"mapper": "11"}, - { - "__interrupt__": ( - Interrupt( - value="question", - id=AnyStr(), - ), - ) - }, + {"submapper": "0"}, + {"submapper": "1"}, ] + assert result[-1] == { + "__interrupt__": ( + Interrupt( + value="question", + id=AnyStr(), + ), + ) + } assert graph.invoke(Command(resume="answer"), thread1, durability=durability) == [ "00answera",