Skip to content

Sandbox Modes

Abhishek Gahlot edited this page Mar 27, 2026 · 1 revision

Sandbox Modes

DeepGym runs code in three modes. Pick the one that fits your situation.

Local

dg = DeepGym(mode='local')

Runs the verifier and solution as a subprocess on your machine. Fast, no isolation, no setup. Fine for development and trusted code. Do not use with untrusted code.

Host Machine
  |-- python verifier.py solution.py
  |-- stdout -> JSON parse -> RunResult

Daytona

dg = DeepGym(mode='daytona')

Each run creates an ephemeral Daytona sandbox (container). Full OS/filesystem/network isolation. Slower due to container startup (~2-5s). Use this for production and untrusted agents.

Daytona Sandbox (ephemeral container)
  |-- /home/user/verifier.py    (uploaded)
  |-- /home/user/solution.py    (uploaded)
  |-- /home/user/test_cases.json (if present)
  |-- python verifier.py solution.py
  |-- sandbox destroyed after run

Requires:

Variable What
DAYTONA_API_KEY Your Daytona API key
DAYTONA_API_URL API endpoint (only for self-hosted)

Snapshots skip dependency installation:

env = Environment(task='...', verifier_code='...', snapshot='docker-dind')

Auto (default)

dg = DeepGym(mode='auto')

Tries Daytona if DAYTONA_API_KEY is set, otherwise falls back to local. This is the default. Code written with mode='auto' works everywhere.


Comparison

Local Daytona Auto
Setup None API key None
Isolation None Full container Depends
Speed ~50ms ~2-5s startup Depends
Network Host Isolated Depends
Untrusted code Unsafe Safe Safe if Daytona available

Concurrency

Local

Uses ThreadPoolExecutor for run_batch().

Daytona

Uses asyncio.Semaphore to cap concurrent sandbox creation.

Recommended max_parallel values

Mode Range
Local 4-8 (match your CPU cores)
Daytona (self-hosted) 10-20
Daytona (cloud) 20-100

Clone this wiki locally