add sandbox extra env config

This commit is contained in:
Азамат Нураев 2026-05-08 15:24:15 +03:00
parent 32793de992
commit 9ed24b1ae9
7 changed files with 28 additions and 1 deletions

View file

@ -324,9 +324,24 @@ def _load_sandbox_config(
env, env,
'APP_SANDBOX_VOLUME_MOUNT_PATH', 'APP_SANDBOX_VOLUME_MOUNT_PATH',
), ),
extra_env=_load_sandbox_extra_env(section),
) )
def _load_sandbox_extra_env(section: Mapping[str, object]) -> dict[str, str]:
raw = section.get('env')
if raw is None:
return {}
if not isinstance(raw, dict):
raise ConfigError('invalid sandbox.env')
result: dict[str, str] = {}
for key, value in raw.items():
if not isinstance(key, str):
raise ConfigError('invalid sandbox.env key')
result[key] = str(value)
return result
def _load_otel_config( def _load_otel_config(
data: Mapping[str, object], data: Mapping[str, object],
env: Mapping[str, str], env: Mapping[str, str],

View file

@ -59,6 +59,7 @@ class SandboxConfig:
dependencies_mount_path: str dependencies_mount_path: str
lambda_tools_mount_path: str lambda_tools_mount_path: str
volume_mount_path: str volume_mount_path: str
extra_env: dict[str, str]
@dataclass(frozen=True, slots=True) @dataclass(frozen=True, slots=True)

View file

@ -69,7 +69,7 @@ class DockerSandboxRuntime(SandboxRuntime):
container = self._client.containers.run( container = self._client.containers.run(
self._config.image, self._config.image,
detach=True, detach=True,
environment={'AGENT_ID': agent_id}, environment={**self._config.extra_env, 'AGENT_ID': agent_id},
labels=self._labels( labels=self._labels(
session_id, session_id,
chat_id, chat_id,

View file

@ -40,6 +40,7 @@ sandbox:
dependencies_mount_path: /opt/dependencies dependencies_mount_path: /opt/dependencies
lambda_tools_mount_path: /opt/lambda-tools lambda_tools_mount_path: /opt/lambda-tools
volume_mount_path: /workspace/volume volume_mount_path: /workspace/volume
env: {}
security: security:
token_header: X-API-Token token_header: X-API-Token

View file

@ -40,6 +40,14 @@ sandbox:
dependencies_mount_path: /opt/dependencies dependencies_mount_path: /opt/dependencies
lambda_tools_mount_path: /opt/lambda-tools lambda_tools_mount_path: /opt/lambda-tools
volume_mount_path: /workspace/volume volume_mount_path: /workspace/volume
env:
LANGFUSE_PUBLIC_KEY: pk-lf-
LANGFUSE_SECRET_KEY: sk-lf-
LANGFUSE_HOST: http://localhost:5000
PROVIDER_URL: http://host.docker.internal:8000/v1
PROVIDER_API_KEY: "1234"
PROVIDER_MODEL: supergemma4-26b-uncensored-mlx-4bit-v2
COMPOSIO_API_KEY: ck_r-3c8ClArmcHuSzK5TYu
security: security:
token_header: X-API-Token token_header: X-API-Token

View file

@ -347,6 +347,7 @@ def build_config() -> AppConfig:
dependencies_mount_path='/workspace/dependencies', dependencies_mount_path='/workspace/dependencies',
lambda_tools_mount_path='/workspace/lambda-tools', lambda_tools_mount_path='/workspace/lambda-tools',
volume_mount_path='/workspace/volume', volume_mount_path='/workspace/volume',
extra_env={},
), ),
security=SecurityConfig( security=SecurityConfig(
token_header='Authorization', token_header='Authorization',

View file

@ -315,6 +315,7 @@ def build_config(tmp_path: Path) -> SandboxConfig:
dependencies_mount_path='/workspace/dependencies', dependencies_mount_path='/workspace/dependencies',
lambda_tools_mount_path='/workspace/lambda-tools', lambda_tools_mount_path='/workspace/lambda-tools',
volume_mount_path='/workspace/volume', volume_mount_path='/workspace/volume',
extra_env={},
) )