diff --git a/libs/core/tests/unit_tests/language_models/test_chat_model_streamer.py b/libs/core/tests/unit_tests/language_models/test_chat_model_streamer.py index 643e3c67bfc..79d08c8e93f 100644 --- a/libs/core/tests/unit_tests/language_models/test_chat_model_streamer.py +++ b/libs/core/tests/unit_tests/language_models/test_chat_model_streamer.py @@ -438,7 +438,9 @@ class TestRunnableBindingForwarding: model.received_kwargs = [] bound = model.bind(my_marker="sentinel-async") - stream = await bound.astream_events("test", version="v3") + # RunnableBinding.astream_events is an async generator for v1/v2; + # use _astream_events_v3 to obtain the AsyncChatModelStream directly. + stream = await bound._astream_events_v3("test") _ = await stream assert len(model.received_kwargs) == 1 diff --git a/libs/core/tests/unit_tests/language_models/test_chat_model_v3_stream.py b/libs/core/tests/unit_tests/language_models/test_chat_model_v3_stream.py index 399b9ac1c5a..e803103c4ff 100644 --- a/libs/core/tests/unit_tests/language_models/test_chat_model_v3_stream.py +++ b/libs/core/tests/unit_tests/language_models/test_chat_model_v3_stream.py @@ -717,7 +717,9 @@ class TestStructuredOutputKwargStripping: async def test_astream_events_v3_strips_ls_structured_output_format(self) -> None: model = _RecordingStreamModel() bound = model.bind(ls_structured_output_format={"schema": {"type": "object"}}) - stream = await bound.astream_events("test", version="v3") + # RunnableBinding.astream_events is an async generator for v1/v2; + # use _astream_events_v3 to obtain the AsyncChatModelStream directly. + stream = await bound._astream_events_v3("test") _ = await stream assert ( "ls_structured_output_format" @@ -731,7 +733,9 @@ class TestStructuredOutputKwargStripping: async def test_astream_events_v3_strips_structured_output_format(self) -> None: model = _RecordingStreamModel() bound = model.bind(structured_output_format={"schema": {"type": "object"}}) - stream = await bound.astream_events("test", version="v3") + # RunnableBinding.astream_events is an async generator for v1/v2; + # use _astream_events_v3 to obtain the AsyncChatModelStream directly. + stream = await bound._astream_events_v3("test") _ = await stream assert ( "ls_structured_output_format" diff --git a/libs/langchain_v1/tests/unit_tests/agents/test_agent_streaming.py b/libs/langchain_v1/tests/unit_tests/agents/test_agent_streaming.py index a573c76f343..e0597f43b08 100644 --- a/libs/langchain_v1/tests/unit_tests/agents/test_agent_streaming.py +++ b/libs/langchain_v1/tests/unit_tests/agents/test_agent_streaming.py @@ -60,7 +60,7 @@ class TestAgentStreamV2Sync: model = FakeToolCallingModel(tool_calls=_single_tool_call_script("echo", text="x")) agent = create_agent(model, [echo]) - run = agent.stream_events({"messages": [HumanMessage("hi")]}, version="v3") + run = agent.stream_v2({"messages": [HumanMessage("hi")]}) # Drain so the run closes cleanly. list(run.tool_calls) @@ -70,7 +70,7 @@ class TestAgentStreamV2Sync: model = FakeToolCallingModel(tool_calls=_single_tool_call_script("echo", text="x")) agent = create_agent(model, [echo]) - run = agent.stream_events({"messages": [HumanMessage("hi")]}, version="v3") + run = agent.stream_v2({"messages": [HumanMessage("hi")]}) collected: list[ToolCallStream] = list(run.tool_calls) assert len(collected) == 1 @@ -84,7 +84,7 @@ class TestAgentStreamV2Sync: model = FakeToolCallingModel(tool_calls=_single_tool_call_script("streamer", text="x")) agent = create_agent(model, [streamer]) - run = agent.stream_events({"messages": [HumanMessage("hi")]}, version="v3") + run = agent.stream_v2({"messages": [HumanMessage("hi")]}) tool_calls: list[ToolCallStream] = [] for tc in run.tool_calls: @@ -97,7 +97,7 @@ class TestAgentStreamV2Sync: model = FakeToolCallingModel() # no tool calls scripted agent = create_agent(model, []) - run = agent.stream_events({"messages": [HumanMessage("hi")]}, version="v3") + run = agent.stream_v2({"messages": [HumanMessage("hi")]}) assert list(run.tool_calls) == [] assert run.output is not None @@ -106,7 +106,7 @@ class TestAgentStreamV2Sync: model = FakeToolCallingModel(tool_calls=_single_tool_call_script("echo", text="x")) agent = create_agent(model, [echo]) - run = agent.stream_events({"messages": [HumanMessage("hi")]}, version="v3") + run = agent.stream_v2({"messages": [HumanMessage("hi")]}) # The native `messages` projection is bound as an instance attribute # by `BaseRunStream.__init__` whenever `MessagesTransformer` is # registered. Content population is covered by langgraph tests — @@ -137,10 +137,9 @@ class TestAgentStreamV2Sync: model = FakeToolCallingModel(tool_calls=_single_tool_call_script("echo", text="x")) agent = create_agent(model, [echo]) - run = agent.stream_events( + run = agent.stream_v2( {"messages": [HumanMessage("hi")]}, transformers=[_Marker], - version="v3", ) # Both the agent default and the user transformer are registered. assert "tool_calls" in run._mux.extensions # type: ignore[attr-defined] @@ -157,7 +156,7 @@ class TestAgentStreamV2Sync: model = FakeToolCallingModel(tool_calls=_single_tool_call_script("boom")) agent = create_agent(model, [boom]) - run = agent.stream_events({"messages": [HumanMessage("hi")]}, version="v3") + run = agent.stream_v2({"messages": [HumanMessage("hi")]}) collected: list[ToolCallStream] = [] @@ -180,7 +179,7 @@ class TestAgentStreamV2Async: model = FakeToolCallingModel(tool_calls=_single_tool_call_script("echo", text="x")) agent = create_agent(model, [echo]) - run = await agent.astream_events({"messages": [HumanMessage("hi")]}, version="v3") + run = await agent.astream_v2({"messages": [HumanMessage("hi")]}) async for tc in run.tool_calls: async for _ in tc.output_deltas: pass @@ -190,7 +189,7 @@ class TestAgentStreamV2Async: model = FakeToolCallingModel(tool_calls=_single_tool_call_script("astreamer", text="hi")) agent = create_agent(model, [astreamer]) - run = await agent.astream_events({"messages": [HumanMessage("hi")]}, version="v3") + run = await agent.astream_v2({"messages": [HumanMessage("hi")]}) collected: list[ToolCallStream] = [] async for tc in run.tool_calls: