Skip to content

SRTExecutionEnvironmentConfig

Base classes

Name Children Inherits
BaseExecutionEnvironmentConfig
exxec_config.configs
Base execution environment configuration.

⋔ Inheritance diagram

graph TD
  724606211["configs.SRTExecutionEnvironmentConfig"]
  2844377061["configs.BaseExecutionEnvironmentConfig"]
  330168112["schema.Schema"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  2844377061 --> 724606211
  330168112 --> 2844377061
  3879467795 --> 330168112
  2751680898 --> 3879467795

🛈 DocStrings

Bases: BaseExecutionEnvironmentConfig

Sandboxed execution environment using Anthropic's sandbox-runtime.

Executes code locally with OS-level sandboxing for network and filesystem restrictions. Requires srt CLI: npm install -g @anthropic-ai/sandbox-runtime

dependencies are installed with pip install outside the sandbox (they come from this configuration, not from the sandboxed code).

Source code in src/exxec_config/configs.py
class SRTExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
    """Sandboxed execution environment using Anthropic's sandbox-runtime.

    Executes code locally with OS-level sandboxing for network and filesystem restrictions.
    Requires `srt` CLI: `npm install -g @anthropic-ai/sandbox-runtime`

    `dependencies` are installed with `pip install` outside the sandbox (they come from
    this configuration, not from the sandboxed code).
    """

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "SRT Execution Environment"})

    type: Literal["srt"] = Field("srt", init=False)

    language: Language = Field(
        default="python",
        title="Programming Language",
        examples=["python", "javascript", "typescript"],
    )
    """Programming language to use."""

    executable: str | None = Field(
        default=None,
        title="Executable",
        examples=["/usr/bin/python3", "python3.13"],
    )
    """Executable to use (auto-detect if None)."""

    sandbox: SandboxConfig = Field(default_factory=SandboxConfig)
    """Sandbox restrictions configuration."""

    def get_provider(
        self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
    ) -> SRTExecutionEnvironment:
        """Create sandboxed execution environment instance."""
        from exxec.srt_provider import SRTExecutionEnvironment

        return SRTExecutionEnvironment(
            sandbox_config=self.sandbox,
            lifespan_handler=lifespan_handler,
            dependencies=self.dependencies,
            default_command_timeout=self.default_command_timeout,
            executable=self.executable,
            language=self.language,
            cwd=self.cwd,
            env_vars=self.env_vars,
            inherit_env=self.inherit_env,
        )

executable class-attribute instance-attribute

executable: str | None = Field(
    default=None, title="Executable", examples=["/usr/bin/python3", "python3.13"]
)

Executable to use (auto-detect if None).

language class-attribute instance-attribute

language: Language = Field(
    default="python", title="Programming Language", examples=["python", "javascript", "typescript"]
)

Programming language to use.

sandbox class-attribute instance-attribute

sandbox: SandboxConfig = Field(default_factory=SandboxConfig)

Sandbox restrictions configuration.

get_provider

get_provider(
    lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
) -> SRTExecutionEnvironment

Create sandboxed execution environment instance.

Source code in src/exxec_config/configs.py
def get_provider(
    self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
) -> SRTExecutionEnvironment:
    """Create sandboxed execution environment instance."""
    from exxec.srt_provider import SRTExecutionEnvironment

    return SRTExecutionEnvironment(
        sandbox_config=self.sandbox,
        lifespan_handler=lifespan_handler,
        dependencies=self.dependencies,
        default_command_timeout=self.default_command_timeout,
        executable=self.executable,
        language=self.language,
        cwd=self.cwd,
        env_vars=self.env_vars,
        inherit_env=self.inherit_env,
    )

:fa-brands-github: Show source on GitHub