JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
test(hooks): cover stop hook session id propagation
guozirui19e21ad41f64b
diff --git a/tests/unit_tests/server/hooks/test_user_hook_rail.py b/tests/unit_tests/server/hooks/test_user_hook_rail.pyindex 869b38bd31..3e0fafc024 100644--- a/tests/unit_tests/server/hooks/test_user_hook_rail.py+++ b/tests/unit_tests/server/hooks/test_user_hook_rail.py@@ -70,9 +70,10 @@ class TestBeforeToolCall:assert "_skip_tool" not in ctx.extra@pytest.mark.asyncio- async def test_passes_session_id_from_context_session(self):+ async def test_passes_session_id_from_context_session_to_tool_and_stop_hooks(self):config = self._make_config(- PreToolUse=[("*", [{"command": "echo ok", "timeout": 5}])]+ PreToolUse=[("*", [{"command": "echo ok", "timeout": 5}])],+ Stop=[("*", [{"command": "echo ok", "timeout": 5}])],)rail = _rail_with_mocked_executor(config, [])ctx = MockCallbackContext(@@ -89,6 +90,12 @@ class TestBeforeToolCall:hook_input = rail._executor.run_all.await_args.kwargs["hook_input"]assert hook_input["session_id"] == "session-5081"+ rail._executor.run_all.reset_mock()+ await rail.after_invoke(ctx)++ hook_input = rail._executor.run_all.await_args.kwargs["hook_input"]+ assert hook_input["session_id"] == "session-5081"+@pytest.mark.asyncioasync def test_blocking_hook_sets_skip_tool(self):config = self._make_config(