From b351a8c9ce95182d09a8c3938a8f95d5315d0c69 Mon Sep 17 00:00:00 2001 From: kingdomad <34766852+kingdomad@users.noreply.github.com> Date: Thu, 23 Jan 2025 16:43:49 +0800 Subject: [PATCH] Improve static tools initialization safety (#324) * improve static tools initialization safety * Allow modification of custom_tools during code execution --- src/smolagents/local_python_executor.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/smolagents/local_python_executor.py b/src/smolagents/local_python_executor.py index 27179a5..b719ac8 100644 --- a/src/smolagents/local_python_executor.py +++ b/src/smolagents/local_python_executor.py @@ -1266,10 +1266,8 @@ def evaluate_python_code( if state is None: state = {} - if static_tools is None: - static_tools = {} - if custom_tools is None: - custom_tools = {} + static_tools = static_tools.copy() if static_tools is not None else {} + custom_tools = custom_tools if custom_tools is not None else {} result = None global PRINT_OUTPUTS PRINT_OUTPUTS = ""