From 0e851a6e8a1114822641cb86c9085148076ea022 Mon Sep 17 00:00:00 2001 From: William Fu-Hinthorn <13333726+hinthornw@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:53:54 -0700 Subject: [PATCH] Assert invariants --- libs/langgraph/tests/test_tracing_interops.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/langgraph/tests/test_tracing_interops.py b/libs/langgraph/tests/test_tracing_interops.py index 02f9598510..7cb7a54efe 100644 --- a/libs/langgraph/tests/test_tracing_interops.py +++ b/libs/langgraph/tests/test_tracing_interops.py @@ -53,7 +53,6 @@ def wait_for( raise ValueError(f"Callable did not return within {total_time}") -@pytest.mark.asyncio async def test_nested_tracing(): lt_py_311 = sys.version_info < (3, 11) mock_client = _get_mock_client() @@ -90,8 +89,6 @@ async def child_node(state: State) -> State: assert result == {"value": "parent_child_input"} - # Check POST calls - # Wait until we have a call with the name of "child_node" def get_posts(): post_calls = _get_calls(mock_client, verbs={"POST"}) @@ -102,9 +99,15 @@ def get_posts(): return None, False posts = wait_for(get_posts) + # If the callbacks weren't propagated correctly, we'd + # end up with broken dotted_orders parent_run = next(data for data in posts if data["name"] == "parent_node") child_run = next(data for data in posts if data["name"] == "child_node") traceable_run = next(data for data in posts if data["name"] == "some_traceable") assert child_run["dotted_order"].startswith(traceable_run["dotted_order"]) assert traceable_run["dotted_order"].startswith(parent_run["dotted_order"]) + + assert child_run["parent_run_id"] == traceable_run["id"] + assert traceable_run["parent_run_id"] == parent_run["id"] + assert parent_run["trace_id"] == child_run["trace_id"] == traceable_run["trace_id"]