fix: global sandbox environment variables not injected on tool execution (#8310)

* base

* test
This commit is contained in:
jnjpng
2026-01-05 17:57:39 -08:00
committed by Caren Thomas
parent e57adc0a6e
commit e56c5c5b49
5 changed files with 152 additions and 60 deletions

View File

@@ -12,7 +12,9 @@ from letta.schemas.environment_variables import (
SandboxEnvironmentVariableUpdate,
)
from letta.schemas.sandbox_config import (
E2BSandboxConfig,
LocalSandboxConfig,
ModalSandboxConfig,
SandboxConfig as PydanticSandboxConfig,
SandboxConfigCreate,
SandboxConfigUpdate,
@@ -35,13 +37,16 @@ class SandboxConfigManager:
if not sandbox_config:
logger.debug(f"Creating new sandbox config of type {sandbox_type}, none found for organization {actor.organization_id}.")
# TODO: Add more sandbox types later
# Create the appropriate config type based on sandbox_type
# Using the actual model classes ensures Pydantic's Union type resolution works correctly
if sandbox_type == SandboxType.E2B:
default_config = {} # Empty
default_config = E2BSandboxConfig()
elif sandbox_type == SandboxType.MODAL:
default_config = ModalSandboxConfig()
else:
# TODO: May want to move this to environment variables v.s. persisting in database
# LOCAL sandbox type
default_local_sandbox_path = LETTA_TOOL_EXECUTION_DIR
default_config = LocalSandboxConfig(sandbox_dir=default_local_sandbox_path).model_dump(exclude_none=True)
default_config = LocalSandboxConfig(sandbox_dir=default_local_sandbox_path)
sandbox_config = self.create_or_update_sandbox_config(SandboxConfigCreate(config=default_config), actor=actor)
return sandbox_config
@@ -53,13 +58,16 @@ class SandboxConfigManager:
if not sandbox_config:
logger.debug(f"Creating new sandbox config of type {sandbox_type}, none found for organization {actor.organization_id}.")
# TODO: Add more sandbox types later
# Create the appropriate config type based on sandbox_type
# Using the actual model classes ensures Pydantic's Union type resolution works correctly
if sandbox_type == SandboxType.E2B:
default_config = {} # Empty
default_config = E2BSandboxConfig()
elif sandbox_type == SandboxType.MODAL:
default_config = ModalSandboxConfig()
else:
# TODO: May want to move this to environment variables v.s. persisting in database
# LOCAL sandbox type
default_local_sandbox_path = LETTA_TOOL_EXECUTION_DIR
default_config = LocalSandboxConfig(sandbox_dir=default_local_sandbox_path).model_dump(exclude_none=True)
default_config = LocalSandboxConfig(sandbox_dir=default_local_sandbox_path)
sandbox_config = await self.create_or_update_sandbox_config_async(SandboxConfigCreate(config=default_config), actor=actor)
return sandbox_config