From acbb0874ea31b01e00c74f8d83791d73e65c1c0f Mon Sep 17 00:00:00 2001 From: Erick Friis Date: Thu, 19 Dec 2024 13:09:17 -0500 Subject: [PATCH] x --- libs/core/tests/unit_tests/test_tools.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libs/core/tests/unit_tests/test_tools.py b/libs/core/tests/unit_tests/test_tools.py index b331abea7da7a..d60defceadcdd 100644 --- a/libs/core/tests/unit_tests/test_tools.py +++ b/libs/core/tests/unit_tests/test_tools.py @@ -2255,3 +2255,20 @@ def foo(x: int) -> Bar: assert foo.invoke( {"type": "tool_call", "args": {"x": 0}, "name": "foo", "id": "bar"} ) == Bar(x=0) + + +def test_tool_mutate_input() -> None: + class MyTool(BaseTool): + name: str = "MyTool" + description: str = "a tool" + + def _run( + self, + x: str, + run_manager: Optional[CallbackManagerForToolRun] = None, + ) -> str: + return "hi" + + my_input = {"x": "hi"} + MyTool().invoke(my_input) + assert my_input == {"x": "hi"}