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

from snowflake.sandbox import Sandbox

with Sandbox.create() as sb:
    print(sb.exec(["python", "-c", "print(40 + 2)"]).stdout)   # 42

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().

Common use cases

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 the snow sandbox CLI, install pip install 'snowflake-sandbox-python[cli]' and then enable the plugin once with snow 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