diff --git a/letta/services/tool_execution_sandbox.py b/letta/services/tool_execution_sandbox.py index b05b6ce2..1060af43 100644 --- a/letta/services/tool_execution_sandbox.py +++ b/letta/services/tool_execution_sandbox.py @@ -277,6 +277,10 @@ class ToolExecutionSandbox: 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: + if not sbx: + logger.info(f"No running e2b sandbox found with the same state: {sbx_config}") + else: + logger.info(f"Force recreated e2b sandbox with state: {sbx_config}") sbx = self.create_e2b_sandbox_with_metadata_hash(sandbox_config=sbx_config) # Since this sandbox was used, we extend its lifecycle by the timeout @@ -292,6 +296,8 @@ class ToolExecutionSandbox: func_return, agent_state = self.parse_best_effort(execution.results[0].text) elif execution.error: logger.error(f"Executing tool {self.tool_name} failed with {execution.error}") + logger.error(f"E2B Sandbox configurations: {sbx_config}") + logger.error(f"E2B Sandbox ID: {sbx.sandbox_id}") func_return = get_friendly_error_msg( function_name=self.tool_name, exception_name=execution.error.name, exception_message=execution.error.value ) diff --git a/tests/integration_test_tool_execution_sandbox.py b/tests/integration_test_tool_execution_sandbox.py index ad3d2ebb..3f64b287 100644 --- a/tests/integration_test_tool_execution_sandbox.py +++ b/tests/integration_test_tool_execution_sandbox.py @@ -464,7 +464,7 @@ def test_e2b_sandbox_inject_env_var_existing_sandbox(check_e2b_key_is_set, get_e config = manager.create_or_update_sandbox_config(config_create, test_user) # Run the custom sandbox once, assert nothing returns because missing env variable - sandbox = ToolExecutionSandbox(get_env_tool.name, {}, user=test_user, force_recreate=True) + sandbox = ToolExecutionSandbox(get_env_tool.name, {}, user=test_user) result = sandbox.run() # response should be None assert result.func_return is None diff --git a/tests/test_client.py b/tests/test_client.py index c3e507ae..532d8058 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -42,8 +42,8 @@ def run_server(): @pytest.fixture( - # params=[{"server": False}, {"server": True}], # whether to use REST API server - params=[{"server": False}], # whether to use REST API server + params=[{"server": False}, {"server": True}], # whether to use REST API server + # params=[{"server": False}], # whether to use REST API server scope="module", ) def client(request): @@ -385,7 +385,7 @@ def test_function_return_limit(mock_e2b_api_key_none, client: Union[LocalClient, client.delete_agent(agent_id=agent.id) -def test_function_always_error(mock_e2b_api_key_none, client: Union[LocalClient, RESTClient]): +def test_function_always_error(client: Union[LocalClient, RESTClient]): """Test to see if function that errors works correctly""" def always_error(): @@ -409,7 +409,6 @@ def test_function_always_error(mock_e2b_api_key_none, client: Union[LocalClient, assert response_message, "ToolReturnMessage message not found in response" assert response_message.status == "error" - import ipdb;ipdb.set_trace() if isinstance(client, RESTClient): assert response_message.tool_return == "Error executing function always_error: ZeroDivisionError: division by zero" else: