Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: make sandboxrunresult rv not optional (#2244)
cthomascecd5394988b
diff --git a/letta/server/server.py b/letta/server/server.pyindex 39536c669..9c66832ee 100644--- a/letta/server/server.py+++ b/letta/server/server.py@@ -1954,8 +1954,6 @@ class SyncServer(Server):# Next, attempt to run the tool with the sandboxtry:sandbox_run_result = ToolExecutionSandbox(tool.name, tool_args_dict, user_id, tool_object=tool).run(agent_state=agent_state)- if sandbox_run_result is None:- raise ValueError(f"Tool with id {tool.id} returned execution with None")function_response = str(sandbox_run_result.func_return)stdout = [s for s in sandbox_run_result.stdout if s.strip()]stderr = [s for s in sandbox_run_result.stderr if s.strip()]diff --git a/letta/services/tool_execution_sandbox.py b/letta/services/tool_execution_sandbox.pyindex 9adcff0b4..3aac64b57 100644--- a/letta/services/tool_execution_sandbox.py+++ b/letta/services/tool_execution_sandbox.py@@ -62,7 +62,7 @@ class ToolExecutionSandbox:self.sandbox_config_manager = SandboxConfigManager(tool_settings)self.force_recreate = force_recreate- def run(self, agent_state: Optional[AgentState] = None) -> Optional[SandboxRunResult]:+ def run(self, agent_state: Optional[AgentState] = None) -> SandboxRunResult:"""Run the tool in a sandbox environment.@@ -101,7 +101,7 @@ class ToolExecutionSandbox:os.environ.clear()os.environ.update(original_env) # Restore original environment variables- def run_local_dir_sandbox(self, agent_state: AgentState) -> Optional[SandboxRunResult]:+ def run_local_dir_sandbox(self, agent_state: AgentState) -> SandboxRunResult:sbx_config = self.sandbox_config_manager.get_or_create_default_sandbox_config(sandbox_type=SandboxType.LOCAL, actor=self.user)local_configs = sbx_config.get_local_config()@@ -266,7 +266,7 @@ class ToolExecutionSandbox:# e2b sandbox specific functions- def run_e2b_sandbox(self, agent_state: AgentState) -> Optional[SandboxRunResult]:+ def run_e2b_sandbox(self, agent_state: AgentState) -> SandboxRunResult:sbx_config = self.sandbox_config_manager.get_or_create_default_sandbox_config(sandbox_type=SandboxType.E2B, actor=self.user)sbx = self.get_running_e2b_sandbox_with_same_state(sbx_config)if not sbx or self.force_recreate:@@ -286,7 +286,7 @@ class ToolExecutionSandbox:execution.logs.stderr.append(execution.error.traceback)execution.logs.stderr.append(f"{execution.error.name}: {execution.error.value}")elif len(execution.results) == 0:- return None+ raise ValueError(f"Tool {self.tool_name} returned execution with None")else:func_return, agent_state = self.parse_best_effort(execution.results[0].text)return SandboxRunResult(