> ## Documentation Index
> Fetch the complete documentation index at: https://uom-demo.vercel.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# sandboxes

> [<span className="flex items-center gap-1"><Icon icon="external-link"/>View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/tree/main/services/orchestrator/src/react_agent/utils/sandboxes.py)

Handles creation and management of Daytona sandboxes for code execution.

## react\_agent.utils.sandboxes.ValidationSandbox Objects

```python theme={null}
class ValidationSandbox()
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/sandboxes.py#L23)

Manager class for Daytona validation sandboxes.

This class tracks active container instances and handles the lifecycle of building and
restoring runtime environment snapshots (e.g., pulling Docker images and installing dependencies).
It ensures that validation steps execute in a clean, consistent sandbox environment, while
minimizing startup latency via snapshot caching.

#### ValidationSandbox.get\_sandbox

```python theme={null}
@staticmethod
async def get_sandbox(daytona: AsyncDaytona,
                      sandbox_type: SandboxType,
                      stream_writer: Callable[[Any], None],
                      env_vars: dict[str, Any] | None = None) -> AsyncSandbox
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/sandboxes.py#L49)

Retrieve or create an active validation sandbox, ensuring that the base environment snapshot is loaded.

**Arguments**:

* `daytona` - The AsyncDaytona API client instance.
* `sandbox_type` - The type of sandbox runtime container needed (.NET or Java).
* `stream_writer` - Callback to stream snapshot compilation and startup progress events back to client.
* `env_vars` - Optional dictionary of environment variables to inject into the sandbox.

**Returns**:

* `AsyncSandbox` - The active, fully initialized AsyncSandbox container.

#### ValidationSandbox.create\_snapshot

```python theme={null}
@staticmethod
async def create_snapshot(daytona: AsyncDaytona, sandbox_type: SandboxType,
                          stream_writer: Callable[[Any], None]) -> None
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/sandboxes.py#L66)

Create and cache a Daytona snapshot for the specified sandbox architecture.

A snapshot acts as a baseline environment (e.g., pre-installing Maven or downloading the
.NET SDK). This function checks if a snapshot named `validation-snapshot-<type>` already
exists. If not, it instructs the Daytona daemon to build one based on the configuration in
`DAYTONA_SANDBOX_IMAGES`, streaming the build logs back to the LangGraph UI.

**Arguments**:

* `daytona` *AsyncDaytona* - The asynchronous Daytona API client.
* `sandbox_type` *SandboxType* - The target architecture.
* `stream_writer` *Callable\[\[Any], None]* - Callback to stream logs to the UI.

**Raises**:

* `Exception` - If snapshot creation fails after multiple exponential backoff retries.

#### ValidationSandbox.create\_validation\_sandbox

```python theme={null}
@staticmethod
async def create_validation_sandbox(
        daytona: AsyncDaytona,
        sandbox_type: SandboxType,
        env_vars: dict[str, Any] | None = None) -> AsyncSandbox
```

[<span className="flex items-center gap-1"><Icon icon="external-link" />View Source</span>](https://github.com/corovcam/Universal-Object-Mapping/blob/main/services/orchestrator/src/react_agent/utils/sandboxes.py#L141)

Provision and start a Daytona sandbox container based on the cached snapshot.

This complex lifecycle manager ensures that a sandbox container named
`validation-sandbox-<type>` is actively running. It robustly handles Daytona state machine
transitions (e.g., cleaning up stuck ERROR/DESTROYING states, waiting for PENDING\_BUILD,
or waking up a STOPPED container).

**Arguments**:

* `daytona` *AsyncDaytona* - The asynchronous Daytona API client.
* `sandbox_type` *SandboxType* - The target architecture.
* `env_vars` *dict\[str, Any] | None, optional* - Optional environment variables to inject.

**Returns**:

* `AsyncSandbox` - The verified running sandbox instance.

**Raises**:

* `RuntimeError` - If the sandbox cannot be transitioned to a STARTED state after max retries.
