The examples on this page omit
auth. To authenticate with your W&B API key, install cwsandbox[wandb] and pass auth=AuthStrategy.WANDB to Sandbox.run(), Sandbox(), or Sandbox.session(). See Get started..stop() explicitly:
atexit and signals (Ctrl+C, SIGTERM). These handlers stop sandboxes that belong to a Session, so session-managed sandboxes stop even on unexpected exits. A sandbox created directly with Sandbox.run() isn’t part of a session, so it keeps running after the process exits until you stop it or its lifetime expires. See Set up Claude Code with the Sandbox SDK for a workflow that relies on this.
For batch cleanup, tagging strategies, and orphan recovery, see the Cleanup patterns guide.