CoreWeave Serverless sandboxes are in public preview.
Prerequisites
Before you begin, you need the following:- A W&B API key or CoreWeave API access token with sandbox access. See Choose a credential.
- A Cursor user API key and access to a model supported by Cursor CLI.
- A public repository URL. Private repositories require Git credentials inside the sandbox.
- Outbound connectivity to Cursor, its download host, and your Git host.
- W&B API key
- CoreWeave API access token
CWSANDBOX_API_KEY makes cws-agent select W&B authentication.CURSOR_API_KEY inside the sandbox. Cursor can send
prompts, file contents, and tool output to its service. Use a repository and
credentials appropriate for the task.
Run Cursor CLI with cws-agent
Usecws-agent to create a sandbox, install Cursor, and attach your terminal.
Interactive attachment requires an interactive terminal (TTY) on macOS, Linux,
or Windows Subsystem for Linux (WSL). Native Windows terminals aren’t supported.
Export your Cursor key locally. cws-agent forwards it into the sandbox’s
environment:
-
Follow the
cws-agentinstallation instructions. -
Replace
[SANDBOX-NAME]with a session name containing 1 to 40 lowercase letters, digits, or hyphens, starting with a letter or digit. Replace[REPOSITORY-URL]with your repository URL:Cursor opens in/workspace/project. If a workspace trust prompt appears, accept it.--permission-mode nativeretains Cursor’s approval settings.cws-agentotherwise uses--force.--no-config-syncskips importing your local skills and Model Context Protocol (MCP) configuration. -
Ask Cursor to create a file you can retrieve:
Approve any prompts for the task. Exit Cursor with
/exit. In your local terminal, read the file:The output should beHello from CoreWeave. Exiting Cursor leaves the sandbox running. -
After exiting all Cursor sessions in the sandbox, remove Cursor’s leftover
worker.socksocket files, save the workspace, and stop compute:The cleanup removes socket files that can block snapshot creation.downtakes a snapshot before stopping the sandbox. If snapshot creation fails, the sandbox stays running. Resolve the error and retrydownbefore restoring. -
To return to the saved workspace, keep
CURSOR_API_KEYexported locally and run:Ask Cursor to read thesandbox-proof.txtfile to verify that it was restored. When finished, exit Cursor and repeat the cleanup anddowncommands.
Run an unattended prompt
Choose a new session name. In your local terminal, launch with--detach to skip
terminal attachment, then send a prompt:
cws-agent run passes Cursor’s --force flag by default so the headless task can
write files without interactive approval. Cursor retains explicit deny rules.
To attach your terminal to the running session, run:
cws-agent exec,
then clean up the sockets and save with cws-agent down as shown in
Run Cursor CLI with cws-agent.
Run a task with the Sandbox SDK
Use the Sandbox SDK to manage a task directly. This path creates a separate sandbox, runs Cursor in print mode, retrieves the file, and stops the sandbox in a cleanup block. It doesn’t configure snapshots or requirecws-agent.
Choose how to supply the Cursor key
Both scripts take an authentication mode as their first argument:
W&B secret injection requires W&B authentication and serverless placement.
It isn’t available with a CoreWeave API access token. These examples use
serverless placement for both modes.
- W&B secret
- CoreWeave environment injection
Ask a W&B administrator to add your Cursor key as a team secret.
In your local terminal, replace Your W&B API key must have access to that team. The scripts map the named
secret to
[WANDB-TEAM] with your team name and
[CURSOR-SECRET-NAME] with the secret name:CURSOR_API_KEY inside the sandbox. See
Use W&B secrets.Install a client
Choose a language and install the client locally:- Python
- TypeScript
Use Python 3.11 or later and
uv. In a new project directory, run:Create, run, and clean up
Save the script for your language using the filename shown. Each script installs Cursor, clones the repository passed on the command line, and asks Cursor to write thesandbox-proof.txt file.
The --print, --force, and --trust flags enable non-interactive output,
permit file changes, and trust the workspace. Use this
example only with a repository you trust. See
Cursor headless mode.
- Python
- TypeScript
run_cursor_sandbox.py
[AUTH-MODE]
with wandb or coreweave, and [REPOSITORY-URL] with your repository URL:
- Python
- TypeScript
Hello from CoreWeave. The cleanup block calls stop() even if setup or execution
raises an error.
Retrieve any additional files before the cleanup block runs. For larger results,
use file operations.
The 2-hour lifetime is a maximum wall-clock limit, including startup. Each
command also has its own timeout. Changing the command timeout doesn’t extend
the sandbox lifetime.
Troubleshoot
Use these checks to resolve common issues:- If sandbox creation fails, verify the credential for your selected authentication mode.
- If a W&B secret can’t be resolved, check
WANDB_ENTITY,CURSOR_SECRET_NAME, and your API key’s team access. - If Cursor reports an authentication error, verify the key in your W&B secret
or local
CURSOR_API_KEY, and check your account’s model access. - If an SDK prompt only proposes changes, confirm that the Cursor command
includes
--force. - If installation, cloning, or model requests fail, check outbound connectivity and provider credentials. For CoreWeave Kubernetes Service (CKS) placement, your runner policy must allow the required destinations.
Next steps
For more information, see these guides:- Run agents on CoreWeave sandboxes covers placement, longer sessions, and workspace lifecycle.
- Cursor with cws-agent covers saved conversations and configuration imports.
- Cursor CLI documentation covers agent configuration and supported modes.