From ff8e20d93f6d787fc3a13f0c7b921da0fc2131bb Mon Sep 17 00:00:00 2001 From: Tom McKenzie Date: Mon, 6 Jan 2025 10:27:10 -0800 Subject: [PATCH] Don't pass sanitize_inputs_outputs=True to managed agents (#85) --- src/smolagents/agents.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/smolagents/agents.py b/src/smolagents/agents.py index de6b3f2..a8ee83e 100644 --- a/src/smolagents/agents.py +++ b/src/smolagents/agents.py @@ -388,16 +388,22 @@ class MultiStepAgent: try: if isinstance(arguments, str): - observation = available_tools[tool_name].__call__( - arguments, sanitize_inputs_outputs=True - ) + if tool_name in self.managed_agents: + observation = available_tools[tool_name].__call__(arguments) + else: + observation = available_tools[tool_name].__call__( + arguments, sanitize_inputs_outputs=True + ) elif isinstance(arguments, dict): for key, value in arguments.items(): if isinstance(value, str) and value in self.state: arguments[key] = self.state[value] - observation = available_tools[tool_name].__call__( - **arguments, sanitize_inputs_outputs=True - ) + if tool_name in self.managed_agents: + observation = available_tools[tool_name].__call__(**arguments) + else: + observation = available_tools[tool_name].__call__( + **arguments, sanitize_inputs_outputs=True + ) else: error_msg = f"Arguments passed to tool should be a dict or string: got a {type(arguments)}." raise AgentExecutionError(error_msg)