From ea08cd0c18b80dc9631a8f3ce977f70503a3d967 Mon Sep 17 00:00:00 2001 From: Nick Hollon Date: Tue, 12 May 2026 16:01:55 -0700 Subject: [PATCH] test(langchain): assert `ToolRuntime.context`/`store`/`stream_writer` propagation --- .../middleware/implementations/test_human_in_the_loop.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_human_in_the_loop.py b/libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_human_in_the_loop.py index f93a66e380c..43fb4aa726e 100644 --- a/libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_human_in_the_loop.py +++ b/libs/langchain_v1/tests/unit_tests/agents/middleware/implementations/test_human_in_the_loop.py @@ -1066,11 +1066,18 @@ def test_interrupt_when_tool_runtime_fields() -> None: ) state = AgentState[Any](messages=[HumanMessage(content="Hi"), ai_message]) - middleware.after_model(state, Runtime()) + sentinel_context = object() + sentinel_store = object() + runtime = Runtime(context=sentinel_context, store=sentinel_store) # type: ignore[arg-type] + + middleware.after_model(state, runtime) rt = captured["runtime"] assert rt.tool_call_id == "abc" assert rt.state is state + assert rt.context is sentinel_context + assert rt.store is sentinel_store + assert rt.stream_writer is runtime.stream_writer assert rt.tools == [] assert rt.config == {} assert rt.execution_info is None