Sandbox Auto Pause
Auto-pause (beta)
Section titled “Auto-pause (beta)”Sandboxes can now automatically pause after they time out. When a sandbox is paused, it stops consuming compute but preserves its state. The default inactivity timeout is 5 minutes. You can change the timeout by passing the timeout parameter to the Sandbox.connect() method.
from agentbox import Sandbox
# Create a new Sandbox, Starts in Running state
sbx1 = Sandbox.beta_create(
api_key="ab_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
template="<YOUR_TEMPLATE_ID>",
timeout=300,
auto_pause=True # Auto-pause after the sandbox times out
)
print('Sandbox created:', sbx1.sandbox_id)
# time.sleep(300)
# Connect the sandbox
sbx2 = Sandbox.connect(
sandbox_id=sbx1.sandbox_id,
api_key="ab_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
timeout=300,
)
print('Sandbox Id:', sbx2.sandbox_id)
from agentbox import AsyncSandbox
async def main():
# Create a new sandbox, Starts in Running state
sbx1 = await AsyncSandbox.beta_create(
api_key="ab_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
template="<YOUR_TEMPLATE_ID>",
timeout=300,
auto_pause=True # Auto-pause after the sandbox times out
)
print('Sandbox created:', sbx1.sandbox_id)
# time.sleep(300)
# Connect the sandbox
sbx2 = await AsyncSandbox.connect(
sandbox_id=sbx1.sandbox_id,
api_key="ab_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
timeout=300,
)
print('Sandbox Id:', sbx2.sandbox_id)
Network
Section titled “Network”If you have a service (for example a server) running inside your sandbox and you pause the sandbox, the service won’t be accessible from the outside and all the clients will be disconnected. If you resume the sandbox, the service will be accessible again but you need to connect clients again.
Limitations while in beta
Section titled “Limitations while in beta”- Pausing a sandbox takes about 4 seconds per 1 GiB of RAM
- Resuming a sandbox takes about 1 second
- Sandbox can be used up to 30 days
- After 30 days from the initial sandbox create call, the data may be deleted and you will not be able to resume it. Attempting to resume a sandbox that was deleted or does not exist will result in the NotFoundException in the Python SDK