Prerequisites
Before you begin, you need the following:- サンドボックスへのアクセス権を持つ W&B APIキー
- 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.
CWSANDBOX_API_KEY の設定を解除すると、cws-agent は W&B 認証を使用します。
Cursor reads 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 のシークレット注入を使用するには、W&B 認証とサーバーレス配置が必要です。
W&B 管理者に依頼して、Cursor キーをチームシークレットとして追加してもらいます。
ローカルターミナルで、
[WANDB-TEAM] をチーム名に、
[CURSOR-SECRET-NAME] をシークレット名に置き換えます。
CURSOR_API_KEY にマッピングします。詳しくは
W&B シークレットを使用する を参照してください。
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] を
wandb に、[REPOSITORY-URL] をリポジトリの 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.
- W&B シークレットを解決できない場合は、
WANDB_ENTITY、CURSOR_SECRET_NAME、 および API キーのチームへのアクセス権を確認してください。 - Cursor で認証エラーが発生した場合は、W&B シークレットに登録されているキーを検証し、 アカウントにモデルへのアクセス権があるかを確認してください。
- If an SDK prompt only proposes changes, confirm that the Cursor command
includes
--force.
- インストール、クローン、またはモデルへのリクエストが失敗する場合は、アウトバウンドの接続性 とプロバイダーの認証情報を確認してください。
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.