Sandbox Lifecycle
Creating a Sandbox
Section titled “Creating a Sandbox”from synapse import Cell
# Basic — ephemeral sandboxcell = Cell()
# With optionscell = 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")import { Cell } from '@runsynapse/sdk';
const cell = await Cell.create({ template: 'python3', persistent: true, timeoutMs: 3_600_000, metadata: { project: 'my-agent' }, envs: { API_KEY: 'sk_...' },});Connecting to an Existing Sandbox
Section titled “Connecting to an Existing Sandbox”cell = Cell.connect("cell_id_here")const cell = await Cell.connect("cell_id_here");Listing Sandboxes
Section titled “Listing Sandboxes”cells = Cell.list()for info in cells: print(f"{info.sandbox_id}: {info.state}")const paginator = Cell.list({ limit: 50 });while (paginator.hasNext) { const items = await paginator.nextItems(); items.forEach(info => console.log(`${info.sandboxId}: ${info.state}`));}Pause and Resume
Section titled “Pause and Resume”Sandbox state is preserved across pause/resume cycles:
# Pause — creates a filesystem snapshotsnapshot = cell.pause()print(snapshot.snapshot_id)
# Resume — restores the snapshotcell.resume()Timeout Management
Section titled “Timeout Management”# Set timeout (seconds)cell.set_timeout(7200) # 2 hours
# Reset inactivity timercell.keep_alive(3600)cell.kill() # Destroys the sandbox and frees resources