Skip to main content
Serverless Sandbox を使用すると、スクリーンショット、マウスクリック、キーボード入力で操作できる Linux デスクトップをエージェントに提供できます。このチュートリアルでは、使い捨てのサーバーレスサンドボックスで Chromium を実行します。手元のマシン上の Python コントローラーがデスクトップのスクリーンショットを OpenAI の computer tool に送信し、返されたアクションをサンドボックス内で実行して、その結果を取得します。 Have the agent complete a sample browser form. The form’s server independently verifies the submission, so success doesn’t depend only on the model’s completion report.

Prerequisites

Before you begin, make sure you have the following:
  • Python 3.11、3.12、または 3.13 と uv。
  • サンドボックスへのアクセス権を持つ W&B APIキー。Get started を参照してください。
  • gpt-5.6-sol と computer tool へのアクセス権を持つ OpenAI APIキー。
  • コントローラーからサンドボックスサービスおよび OpenAI API へのアウトバウンドアクセス。サンドボックスは Debian リポジトリからパッケージをインストールします。
The example requests 2 CPUs and 4 gibibytes (GiB) of memory, with a 30-minute maximum sandbox lifetime. It explicitly selects serverless placement, so you don’t need to deploy a runner.

Configure credentials

Create a working directory and start Bash for the hidden-input prompts:
そのシェルで、W&B と OpenAI の認証情報を入力します。
Both keys stay in the local controller environment. The script doesn’t pass them to the sandbox. The controller sends desktop screenshots and the task prompt to the model API.

Create the desktop controller

In your working directory, save the following complete example as the computer_use.py file. It combines three components: Chromium runs as the desktop user with its browser sandbox enabled. The form server listens on loopback inside the sandbox. This example doesn’t create a public endpoint or open a browser on your machine. The adapter validates coordinates and key combinations and passes typed text as a literal argument. The loop stops on unsupported actions or a requested safety review. It permits up to 20 model turns and checks a 10-minute deadline between turns.
computer_use.py

Run and verify the task

From the same shell, run the controller with its dependencies:
The controller creates a sandbox, installs the desktop packages, and waits for Chromium to load the form. The model then reads the page, enters the displayed phrase, and selects Verify. Package installation can take several minutes. The number of model turns can vary. Each run saves its results in a new directory under computer-use-results/: After a successful run, the result.json file contains "status": "passed", "verified": true, and "cleanup": "stopped". To see PASS on the form, open the agent/final.png file. The controller checks the form server’s verification file before declaring success. The controller attempts to stop the sandbox in a finally block, including when the task fails. If cleanup reports "failed" or you terminate the controller before cleanup finishes, use the ID from the sandbox-id.txt file to stop it. Replace [SANDBOX-ID] with that ID. In the same shell, stop the sandbox:
If the task fails, inspect the saved transcript and the latest agent/turn-*.png file if available. API, desktop installation, and browser startup failures can occur before one or both files exist. For sandbox connection and execution errors, see Sandboxes support articles.

Next steps

To adapt the example, replace the sample form and task with an application you control. Keep the screenshot/action loop and add an application-specific success check. For repeated runs, build the desktop packages into a container image to avoid installing them at startup. See Sandbox configuration. Before you use the agent with other applications, define allowed destinations and actions, and require human approval for sensitive operations. The sample prompt and input validation don’t enforce where Chromium can navigate. When you extend the controller, review OpenAI’s computer-use guidance. For more ways to connect an agent to a sandbox, see Agents. For lifecycle management, see Cleanup patterns.
最終更新日 2026年10月5日