diff --git a/.github/workflows/ci_python.yml b/.github/workflows/ci_python.yml index 5e3ef8b6..2db252e4 100644 --- a/.github/workflows/ci_python.yml +++ b/.github/workflows/ci_python.yml @@ -137,7 +137,7 @@ jobs: run: just --set ci true --set output_dir "${{ github.workspace }}" test-python - name: Run Python LangChain integration tests - if: ${{ inputs.run_integration_langchain == 'true' }} + if: ${{ inputs.run_integration_langchain }} working-directory: ${{ env.NEMO_RELAY_CI_WORKSPACE }} run: just --set ci true --set output_dir "${{ github.workspace }}" test-python-langchain diff --git a/python/tests/integrations/deepagents_tests/test_deepagents_integration.py b/python/tests/integrations/deepagents_tests/test_deepagents_integration.py index a05b0399..ade20de8 100644 --- a/python/tests/integrations/deepagents_tests/test_deepagents_integration.py +++ b/python/tests/integrations/deepagents_tests/test_deepagents_integration.py @@ -75,6 +75,7 @@ def test_before_agent_emits_configuration_mark( with nemo_relay.scope.scope("request", nemo_relay.ScopeType.Agent): middleware.before_agent(MagicMock(name="mock_state"), MagicMock(name="mock_runtime")) + nemo_relay.subscribers.flush() marks = _filter_mark_events(subscribed_events) assert [mark.name for mark in marks] == ["DeepAgents Skills Configured"] assert _mark_metadata(marks[0])["deepagents_kind"] == "skill" @@ -121,6 +122,7 @@ def test_callback_handler_emits_human_in_the_loop_marks( ) ) + nemo_relay.subscribers.flush() marks = _filter_mark_events(subscribed_events) assert [mark.name for mark in marks] == [ "DeepAgents Human In The Loop Interrupt", @@ -159,6 +161,7 @@ def test_callback_handler_falls_back_for_non_hitl_interrupt( ) ) + nemo_relay.subscribers.flush() marks = _filter_mark_events(subscribed_events) assert [mark.name for mark in marks] == ["Graph Interrupt", "Graph Resume"] assert _mark_metadata(marks[0])["integration"] == "langgraph" @@ -255,6 +258,7 @@ def test_e2e_agent( with nemo_relay.scope.scope("deepagents-request", nemo_relay.ScopeType.Agent): result = agent.invoke({"messages": [{"role": "user", "content": "Create a file named turtle."}]}) + nemo_relay.subscribers.flush() assert (tmp_path / "turtle").read_text() == "shell" assert result["messages"][-1].content == "created turtle after reviewer verified turtle" found_write_file_message = False diff --git a/python/tests/integrations/langchain_tests/test_middleware.py b/python/tests/integrations/langchain_tests/test_middleware.py index 7720a4f3..048b9069 100644 --- a/python/tests/integrations/langchain_tests/test_middleware.py +++ b/python/tests/integrations/langchain_tests/test_middleware.py @@ -404,10 +404,12 @@ def event_recorder(event): else: result = agent.invoke(input_payload) finally: + nemo_relay.subscribers.flush() nemo_relay.subscribers.deregister("event_recorder") assert any( message.content == "The weather in San Francisco is sunny and 72 degrees." for message in result["messages"] ) assert result["messages"][-1].content == _DEFAULT_MOCK_RESPONSE_MSG + assert events == expected_events diff --git a/python/tests/integrations/langgraph_tests/test_langgraph_integration.py b/python/tests/integrations/langgraph_tests/test_langgraph_integration.py index 337532bf..464c88df 100644 --- a/python/tests/integrations/langgraph_tests/test_langgraph_integration.py +++ b/python/tests/integrations/langgraph_tests/test_langgraph_integration.py @@ -104,6 +104,8 @@ def test_sync( with nemo_relay.scope.scope("request", nemo_relay.ScopeType.Agent): result = sync_graph.invoke({"value": 1}, config={"callbacks": [callback_handler]}) + nemo_relay.subscribers.flush() + assert result == {"value": 2} assert _events_to_strings(subscribed_events) == self._expected_events @@ -116,6 +118,8 @@ async def test_async( with nemo_relay.scope.scope("request", nemo_relay.ScopeType.Agent): result = await async_graph.ainvoke({"value": 1}, config={"callbacks": [callback_handler]}) + nemo_relay.subscribers.flush() + assert result == {"value": 2} assert _events_to_strings(subscribed_events) == self._expected_events @@ -156,6 +160,7 @@ def test_graph_lifecycle_callbacks_emit_marks( ) ) + nemo_relay.subscribers.flush() assert _events_to_strings(subscribed_events) == expected_event_strings interrupt_event = subscribed_events[1]