diff --git a/src/smolagents/agents.py b/src/smolagents/agents.py index 2ba1787..e53bc95 100644 --- a/src/smolagents/agents.py +++ b/src/smolagents/agents.py @@ -876,6 +876,10 @@ You have been provided with these additional arguments, that you can access usin } if hasattr(self, "authorized_imports"): agent_dict["authorized_imports"] = self.authorized_imports + if hasattr(self, "use_e2b_executor"): + agent_dict["use_e2b_executor"] = self.use_e2b_executor + if hasattr(self, "max_print_outputs_length"): + agent_dict["max_print_outputs_length"] = self.max_print_outputs_length return agent_dict @classmethod @@ -971,6 +975,8 @@ You have been provided with these additional arguments, that you can access usin ) if cls.__name__ == "CodeAgent": args["additional_authorized_imports"] = agent_dict["authorized_imports"] + args["use_e2b_executor"] = agent_dict["use_e2b_executor"] + args["max_print_outputs_length"] = agent_dict["max_print_outputs_length"] args.update(kwargs) return cls(**args) diff --git a/tests/test_agents.py b/tests/test_agents.py index adcdb6a..e5f4906 100644 --- a/tests/test_agents.py +++ b/tests/test_agents.py @@ -784,6 +784,7 @@ class MultiAgentsTests(unittest.TestCase): tools=[], additional_authorized_imports=["pandas", "datetime"], managed_agents=[web_agent, code_agent], + max_print_outputs_length=1000, ) agent.save("agent_export") @@ -820,6 +821,8 @@ class MultiAgentsTests(unittest.TestCase): agent2 = CodeAgent.from_folder("agent_export", planning_interval=5) assert agent2.planning_interval == 5 # Check that kwargs are used assert set(agent2.authorized_imports) == set(["pandas", "datetime"] + BASE_BUILTIN_MODULES) + assert agent2.max_print_outputs_length == 1000 + assert agent2.use_e2b_executor is False assert ( agent2.managed_agents["web_agent"].tools["web_search"].max_results == 10 ) # For now tool init parameters are forgotten