Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Fix sandboxID in Python SDK list method
Tomas Valentab40637226a15
diff --git a/packages/python-sdk/e2b/__init__.py b/packages/python-sdk/e2b/__init__.pyindex e758b0bb7..897347e50 100644--- a/packages/python-sdk/e2b/__init__.py+++ b/packages/python-sdk/e2b/__init__.py@@ -22,7 +22,6 @@ sandbox.close()```"""-from .api import (E2BApiClient,client,@@ -55,6 +54,7 @@ from .sandbox import (ProcessOutput,TerminalOutput,run_code,+ RunningSandbox,)from .templates import (DataAnalysis,diff --git a/packages/python-sdk/e2b/sandbox/__init__.py b/packages/python-sdk/e2b/sandbox/__init__.pyindex ddccbddc2..5acbefbd5 100644--- a/packages/python-sdk/e2b/sandbox/__init__.py+++ b/packages/python-sdk/e2b/sandbox/__init__.py@@ -27,3 +27,4 @@ from .terminal import (TerminalManager,TerminalOutput,)+from .sandbox_connection import RunningSandboxdiff --git a/packages/python-sdk/e2b/sandbox/sandbox_connection.py b/packages/python-sdk/e2b/sandbox/sandbox_connection.pyindex b85149bbf..cf64086a4 100644--- a/packages/python-sdk/e2b/sandbox/sandbox_connection.py+++ b/packages/python-sdk/e2b/sandbox/sandbox_connection.py@@ -3,13 +3,15 @@ import loggingimport threadingimport tracebackimport warnings+from concurrent.futures import ThreadPoolExecutor, CancelledErrorfrom time import sleepfrom typing import Any, Callable, List, Literal, Optional, Union, Dict-+from datetime import datetimefrom pydantic import BaseModelfrom urllib3.exceptions import ReadTimeoutError, MaxRetryError, ConnectTimeoutError+from e2b.api import E2BApiClient, exceptions, models, clientfrom e2b.constants import (SANDBOX_DOMAIN,@@ -52,7 +54,8 @@ class RunningSandbox(BaseModel):sandbox_id: strtemplate_id: stralias: Optional[str]- metadata: Dict[str, str]+ metadata: Dict[str, str] | None+ started_at: datetimeclass SandboxConnection:@@ -458,7 +461,7 @@ class SandboxConnection:self._close()@staticmethod- def list(api_key: Optional[str] = None) -> List[models.RunningSandboxes]:+ def list(api_key: Optional[str] = None) -> List[RunningSandbox]:"""List all running sandboxes.@@ -466,5 +469,15 @@ class SandboxConnection:If not provided, the `E2B_API_KEY` environment variable will be used."""api_key = get_api_key(api_key)+with E2BApiClient(api_key=api_key) as api_client:- return client.SandboxesApi(api_client).sandboxes_get()+ return [+ RunningSandbox(+ metadata=sandbox.metadata,+ sandbox_id=f"{sandbox.sandbox_id}-{sandbox.client_id}",+ template_id=sandbox.template_id,+ alias=sandbox.alias,+ started_at=sandbox.started_at,+ )+ for sandbox in client.SandboxesApi(api_client).sandboxes_get()+ ]