Cortex Sandboxes overview¶
Cortex Sandboxes runs code in an isolated Linux container inside your own Snowflake account. You create a sandbox with a single call, run commands in it, and remove it when the work is finished.
Sandboxes are designed for code you cannot fully trust, such as code written by an AI agent. Because the container runs inside your account, the code runs next to your data rather than requiring your data to be copied to an external service.
Key benefits¶
Give your agents a computer next to your data. Agents can write and run code against live Snowflake data without an export pipeline or infrastructure to manage. Create a sandbox with one call, and Snowflake runs it for you. See Run a LangGraph agent over Snowflake data in a sandbox.
Let agents act on your data without handing them the keys. A sandbox works as you, under the access controls and governance policies you already have, and code can’t send data anywhere you haven’t allowed. See Cortex Sandboxes concepts and security.
Run one agent or many. Keep a long-lived sandbox for a coding agent’s session, or create many at once to evaluate or score agent runs in parallel, each with its own clean environment. See Work with sandboxes using the Python SDK.
Example¶
The with block creates the container, runs one command in it, and removes the sandbox on exit. No setup is required inside the container. A sandbox you create without with keeps running until you call terminate().
One command creates the container, streams the output, exits with the command’s own exit code, and removes the sandbox. There is no script to write and no setup inside the container.
Common use cases¶
- Running agent-generated code against your data. The agent writes Python, the sandbox runs it against live Snowflake tables, and the SDK fits any agent framework. See Run a LangGraph agent over Snowflake data in a sandbox.
- Running many isolated tasks in parallel. Evaluation and training need a clean environment per attempt. Create many at once, score each from what the run produced, then remove them. See Work with sandboxes using the Python SDK.
- Giving a developer or a coding agent a dedicated machine. One sandbox per person, with a terminal, filesystem, git, and package manager, kept as long as the work takes and reconnectable by name. See Your first Cortex Sandbox in Cortex Code and Reconnect to a running sandbox.
- Running batch jobs that a warehouse cannot host. Some work needs tools a user-defined function cannot carry, such as a text-recognition engine and its system libraries, and it keeps running after you disconnect. See Run Cortex batch inference over a Snowflake table.
Prerequisites¶
- Python 3.11 or later.
- A Snowflake account with Cortex Sandboxes enabled. See Availability.
- The SDK, installed with
pip install snowflake-sandbox-python. To use thesnow sandboxCLI, installpip install 'snowflake-sandbox-python[cli]'and then enable the plugin once withsnow plugin enable snow-sandbox, because Snowflake CLI plugins ship disabled. See Cortex Sandboxes quickstart. - A configured Snowflake connection. The SDK resolves your credentials for you. See Connect to Snowflake from the SDK.
Comparison with Snowpark Container Services¶
Cortex Sandboxes and Snowpark Container Services both run containers in your Snowflake account, but they suit different kinds of work. Use a sandbox for many short-lived, per-task containers that start quickly and are removed after the task, including one container per agent invocation. Use Snowpark Container Services to operate a long-running service, to expose a stable inbound endpoint, or to use GPUs.
If you have not used Snowpark Container Services, you do not need it in order to use Cortex Sandboxes.
Availability¶
Cortex Sandboxes is available in private preview. To request access for your account, contact your Snowflake account representative. See Cortex Sandboxes limitations and FAQ for current limitations.
Next steps¶
- Cortex Sandboxes quickstart: install, connect, and run your first sandbox.
- Working with the Cortex Sandboxes CLI: run, manage, and attach to sandboxes from the terminal.
- Cortex Sandboxes tutorials: worked examples of the use cases above.
- Cortex Sandboxes concepts and security: the isolation model and the sandbox lifecycle in detail.