Skip to content

Sandbox Lifecycle

from synapse import Cell
# Basic — ephemeral sandbox
cell = Cell()
# With options
cell = Cell(
template="python3",
persistent=True,
timeout_ms=3_600_000, # 1 hour
metadata={"project": "my-agent"},
envs={"API_KEY": "sk_..."},
)
# Factory method (async context)
cell = Cell.create(template="python3")
cell = Cell.connect("cell_id_here")
cells = Cell.list()
for info in cells:
print(f"{info.sandbox_id}: {info.state}")

Sandbox state is preserved across pause/resume cycles:

# Pause — creates a filesystem snapshot
snapshot = cell.pause()
print(snapshot.snapshot_id)
# Resume — restores the snapshot
cell.resume()
# Set timeout (seconds)
cell.set_timeout(7200) # 2 hours
# Reset inactivity timer
cell.keep_alive(3600)
cell.kill() # Destroys the sandbox and frees resources