Skip to content

Sandbox Persistence

You can pause a running Sandbox by calling the pause method on the Sandbox instance. This will save the state of the Sandbox, including the file system and any running processes. Later, you can resume the Sandbox by calling the resume method:

from agentbox import Sandbox

# Create a new sandbox
sbx = Sandbox(
    api_key="ab_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    template="dr68insivc2tac3ox3ts",
    timeout=60
)
print('Sandbox created:', sbx.sandbox_id)

# Pause the sandbox
sbx.pause()
print("Sandbox paused:", sbx.sandbox_id)

# Resume the sandbox
resumed_sbx = Sandbox.resume(sbx.sandbox_id)
print("Sandbox resumed:", resumed_sbx.sandbox_id)