Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

docs: run the OpenAI and Omarchy recipes without Fleets (#4656)

Francesco Bonacci1198f64fa7b9
diff --git a/.github/workflows/docs-page-tests.yml b/.github/workflows/docs-page-tests.yml
index fa557bceee..b1a83d7ce7 100644
--- a/.github/workflows/docs-page-tests.yml
+++ b/.github/workflows/docs-page-tests.yml
@@ -12,7 +12,7 @@ on:
- "docs/scripts/tests/test_fleet_driver_guide.py"
- "docs/scripts/tests/test_sandbox_secret_example.py"
- "docs/scripts/tests/test_fleet_docs_version_facts.py"
- - "docs/scripts/tests/test_openai_agents_fleet_example.py"
+ - "docs/scripts/tests/test_openai_agents_example.py"
- "libs/python/cua-sandbox/**"
- "libs/cua/VERSION"
- "libs/cua/python/pyproject.toml"
@@ -50,4 +50,4 @@ jobs:
docs/scripts/tests/test_fleet_driver_guide.py
docs/scripts/tests/test_sandbox_secret_example.py
docs/scripts/tests/test_fleet_docs_version_facts.py
- docs/scripts/tests/test_openai_agents_fleet_example.py
+ docs/scripts/tests/test_openai_agents_example.py
diff --git a/docs/content/docs/cua-sdk/guides/agent-frameworks.mdx b/docs/content/docs/cua-sdk/guides/agent-frameworks.mdx
index ae1416def7..0e375f838f 100644
--- a/docs/content/docs/cua-sdk/guides/agent-frameworks.mdx
+++ b/docs/content/docs/cua-sdk/guides/agent-frameworks.mdx
@@ -5,26 +5,31 @@ description: Run OpenAI Agents, Codex, Cursor, OpenClaw, an Omarchy desktop and
import { Callout } from 'fumadocs-ui/components/callout';
-Each recipe gives a third-party agent its own desktop instead of yours. The
-cloud recipes need [cloud credentials](/cua-sdk/guides/cloud#credentials), and
-Python `>=3.11,<3.14` with [`uv`](https://docs.astral.sh/uv/) for the scripts,
-which pin `cua-sandbox==0.9.0`. Your controller owns the sandbox and must
-release it.
+Each recipe gives a third-party agent its own desktop instead of yours.
+Sandboxes run on this machine by default; to run them in your own AWS, Google
+Cloud or Modal account, see [Use your own cloud](/cua-sdk/guides/your-cloud).
+The Python script needs Python `>=3.11,<3.14` with
+[`uv`](https://docs.astral.sh/uv/) and pins `cua-sandbox==0.9.0`. Your
+controller owns the sandbox and must delete it.
## OpenAI Agents API
-A controller claims `Image.linux()`, starts `codex exec-server` in it as an
-OpenAI `self_hosted` environment, and gives the agent Cua Driver as a stdio
+A controller creates an `Image.linux()` sandbox, starts `codex exec-server` in
+it as an OpenAI `self_hosted` environment, and gives the agent Cua Driver as a stdio
MCP server. It needs an OpenAI application key (`OPENAI_API_KEY`) and a
separate environment key with only `api.agents.environments.connect`
(`CODEX_API_KEY`), which is written to a mode-`600` file and deleted after the
executor reads it.
```bash skip="third-party-cli"
-curl -fsSLO https://cua.ai/docs-assets/scripts/openai-agents-fleet/run_openai_agents_fleet.py
-uv run run_openai_agents_fleet.py
+curl -fsSLO https://cua.ai/docs-assets/scripts/openai-agents/run_openai_agents.py
+uv run run_openai_agents.py
```
+The sandbox runs on this machine. To run it in your own cloud, connect the
+account with `cua cloud connect` and set `CUA_ON=aws` (or `gcp`, `modal`)
+before `uv run`.
+
The run drives an XFCE terminal through Cua Driver, reconnects the same
environment ID, downloads an artifact, and deletes the session and the
sandbox. Deleting an OpenAI session alone does not release the sandbox.
@@ -99,85 +104,21 @@ OpenClaw needs X11 (not Wayland) and a vision-capable model.
## Omarchy desktop
-An amd64 Omarchy (Hyprland) containerDisk that ships cua-spacesd runs as a
-KubeVirt VM on a pool you apply. `OMARCHY_IMAGE` names the image (pin a
-digest) and `CUA_POOL_NAME` a globally unique pool name:
-
-```python title="run_omarchy_fleet.py" test="fleet" id="omarchy-fleet"
-# /// script
-# requires-python = ">=3.11,<3.14"
-# dependencies = [
-# "cua-sandbox[driver]==0.9.0",
-# ]
-# [[tool.uv.index]]
-# name = "cua-wheels"
-# url = "https://wheels.cua.ai/simple"
-# ///
-
-import asyncio
-import os
-from pathlib import Path
-
-from cua_driver import GetScreenSizeInput
-from cua_sandbox import Image, Pool
-
-IMAGE = os.environ["OMARCHY_IMAGE"]
-POOL_NAME = os.environ["CUA_POOL_NAME"]
-
-
-async def main() -> None:
- pool = await Pool.apply(
- Image.from_registry(IMAGE, os_type="linux", kind="vm"),
- name=POOL_NAME,
- replicas=1,
- cpu=4,
- memory_mb=6144,
- runtime="kubevirt",
- ttl_seconds_after_created=21600,
- )
-
- try:
- async with pool.claim(time_to_start=1800) as sandbox:
- width, height = await sandbox.get_dimensions()
- print(f"Sandbox: {sandbox.name}, screen {width}x{height}")
-
- result = await sandbox.shell.run("pgrep -a Hyprland")
- if not result.success:
- raise RuntimeError(result.stderr)
- print(result.stdout.strip())
-
- screenshot = Path("omarchy-fleet.png")
- screenshot.write_bytes(await sandbox.screenshot())
- print(f"Screenshot: {screenshot.resolve()}")
-
- await sandbox.clipboard.set("hello from Omarchy Fleet")
- if await sandbox.clipboard.get() != "hello from Omarchy Fleet":
- raise RuntimeError("clipboard round trip failed")
-
- await sandbox.mouse.click(width // 2, height // 2)
- await sandbox.keyboard.keypress(["super", "2"])
-
- # Typed Cua Driver over the spacesd's /mcp endpoint.
- async with sandbox.driver.connect() as driver:
- size = await driver.get_screen_size(GetScreenSizeInput(session=None))
- print(f"Driver screen size: {size.text}")
-
- print("Shell, screenshot, clipboard, click, hotkey and Driver passed")
- finally:
- await pool.delete()
-
-
-asyncio.run(main())
-```
-
-`PoolAccessDeniedError` means the pool name is taken or the image is not
-admitted; a black screenshot means Hyprland did not start. To keep the pool
-warm between runs, drop the `finally` and delete it later:
+`ghcr.io/trycua/omarchy:edge` is an amd64 Omarchy (Hyprland) VM image that
+ships Cua Driver and cua-spacesd. Run it as a local VM and drive it with the
+cua CLI:
-```python test="docs" id="delete-pool" prelude="fakefleet,pool-applied"
-await pool.delete()
+```bash skip="local-vm"
+cua sb create ghcr.io/trycua/omarchy:edge --kind vm --name omarchy --cpu 4 --memory 4GB
+cua sb view omarchy
+cua do switch omarchy
+cua do screenshot --save omarchy.png
+cua sb rm omarchy -f
```
+It boots under QEMU: KVM on Linux, TCG (slow) on Apple silicon. A black
+screenshot means Hyprland did not start. The full walkthrough, including
+Omarchy's own Cua Driver, is in [Omarchy with Cua Driver](/cua-sdk/guides/omarchy).
For Omarchy on Apple silicon, see [Lume](/lume).
## Minecraft
diff --git a/docs/content/docs/cua-sdk/guides/omarchy.mdx b/docs/content/docs/cua-sdk/guides/omarchy.mdx
index 2bc061c84d..eab9eff684 100644
--- a/docs/content/docs/cua-sdk/guides/omarchy.mdx
+++ b/docs/content/docs/cua-sdk/guides/omarchy.mdx
@@ -13,8 +13,7 @@ cua-spacesd, so the cua CLI, SDK and Spaces work with it.
- amd64 only (Omarchy is x86_64). VM only: Hyprland needs a GPU or KMS
device, which containers do not have.
-- Locally it boots under QEMU: KVM on Linux, TCG (slow) on Apple silicon.
- In the cloud it runs on KubeVirt.
+- It boots under QEMU: KVM on Linux, TCG (slow) on Apple silicon.
## Create, view and run commands
diff --git a/docs/content/docs/spaces/index.mdx b/docs/content/docs/spaces/index.mdx
index 9aac82e401..349fefac43 100644
--- a/docs/content/docs/spaces/index.mdx
+++ b/docs/content/docs/spaces/index.mdx
@@ -7,8 +7,8 @@ landing:
---
A Space is a desktop your agents can use and you can watch: a container or VM
-on your own Mac, or one of your team's machines (your own cloud is coming
-soon). Each runs cua-spacesd, which streams the screen, takes input through
+on your own Mac, one of your team's machines, or
+[your own cloud](/cua-sdk/guides/your-cloud) (AWS, Google Cloud or Modal). Each runs cua-spacesd, which streams the screen, takes input through
Cua Driver, and receives teleported apps and files. Cua Spaces is
source-available under the FSL-1.1-MIT. For teams, join the
[waitlist](https://cua.ai/teams).
diff --git a/docs/public/scripts/openai-agents-fleet/run_openai_agents_fleet.py b/docs/public/scripts/openai-agents/run_openai_agents.py
similarity index 73%
rename from docs/public/scripts/openai-agents-fleet/run_openai_agents_fleet.py
rename to docs/public/scripts/openai-agents/run_openai_agents.py
index 84108bd88f..43971f610d 100644
--- a/docs/public/scripts/openai-agents-fleet/run_openai_agents_fleet.py
+++ b/docs/public/scripts/openai-agents/run_openai_agents.py
@@ -9,10 +9,14 @@
# name = "cua-wheels"
# url = "https://wheels.cua.ai/simple"
# ///
-"""Run an OpenAI Agents API self-hosted session on Cua Cloud Fleet.
+"""Run an OpenAI Agents API self-hosted session in a Cua sandbox.
+
+The sandbox runs on this machine by default. Set CUA_ON to "aws", "gcp" or
+"modal" to run it in your own cloud account instead (connect it first with
+`cua cloud connect`; see https://cua.ai/docs/cua-sdk/guides/your-cloud).
The application API key remains on the controller. Only the restricted
-environment key is copied into the claimed VM, and its temporary file is
+environment key is copied into the sandbox, and its temporary file is
removed as soon as the detached executor starts. The guest is the canonical
Image.linux() (ghcr.io/trycua/linux:24.04): Ubuntu 24.04 with XFCE on X11 and
cua-spacesd on port 3211, which carries the SDK's shell and file calls. Commands run as the
@@ -31,17 +35,19 @@ import shlex
from typing import Any, AsyncIterator, Callable
import httpx
-from cua_sandbox import Image, Pool
+from cua_sandbox import Image, Sandbox
AGENTS_BASE_URL = "https://api.openai.com/v1/agents/"
AGENTS_BETA_HEADER = "agents=v1"
-# Unset: Image.linux() (ghcr.io/trycua/linux:24.04), run as a gVisor pod.
-IMAGE = os.environ.get("CUA_FLEET_IMAGE")
+# Unset: Image.linux() (ghcr.io/trycua/linux:24.04).
+IMAGE = os.environ.get("CUA_IMAGE")
+# "local" (this machine), or "aws", "gcp" or "modal" (your own cloud).
+LOCATION = os.environ.get("CUA_ON", "local")
CODEX_VERSION = "0.155.0-alpha.3"
CUA_DRIVER_VERSION = "0.27.0"
-ARTIFACT_PATH = "/workspace/outputs/openai-cua-fleet-e2e.txt"
-ARTIFACT_CONTENT = "OPENAI AGENTS API ON CUA CLOUD FLEET PASSED\n"
+ARTIFACT_PATH = "/workspace/outputs/openai-cua-e2e.txt"
+ARTIFACT_CONTENT = "OPENAI AGENTS API ON CUA PASSED\n"
RUNTIME_DIR = "/run/cua-agents"
EXECUTOR_ENV_PATH = f"{RUNTIME_DIR}/executor.env"
EXECUTOR_LAUNCHER_PATH = f"{RUNTIME_DIR}/launch-executor"
@@ -65,10 +71,9 @@ def required_env(name: str) -> str:
return value
-def pool_name() -> str:
- # This example deletes its pool. Never reconcile a caller's existing pool.
- # Fleet appends an instance suffix and service name; leave room under 63 bytes.
- return f"cua-openai-agents-{secrets.token_hex(12)}"
+def sandbox_name() -> str:
+ # This example deletes its sandbox. Never reuse a caller's existing one.
+ return f"openai-agents-{secrets.token_hex(6)}"
def root_turn(event: dict[str, Any]) -> bool:
@@ -91,7 +96,7 @@ async def checked_read(
timeout: int = 300,
attempts: int = 3,
) -> str:
- """Retry a read-only shell probe after transient Fleet transport failures."""
+ """Retry a read-only shell probe after transient transport failures."""
for attempt in range(1, attempts + 1):
try:
return await checked(sandbox, command, timeout=timeout)
@@ -356,12 +361,12 @@ def e2e_terminal_launcher() -> str:
return f'''#!/bin/bash
set -euo pipefail
rm -f {shlex.quote(E2E_TARGET_PATH)}
-xfce4-terminal --disable-server --title='OPENAI CUA FLEET E2E' --hold \\
- --command="bash -lc 'printf \\\"OPENAI CUA FLEET E2E\\\\n\\\"; sleep 3600'" &
+xfce4-terminal --disable-server --title='OPENAI CUA E2E' --hold \\
+ --command="bash -lc 'printf \\\"OPENAI CUA E2E\\\\n\\\"; sleep 3600'" &
terminal_pid=$!
window_id=''
for _attempt in $(seq 1 50); do
- window_id=$(xwininfo -root -tree 2>/dev/null | awk '/"OPENAI CUA FLEET E2E"/ && /xfce4-terminal/ {{print $1; exit}}')
+ window_id=$(xwininfo -root -tree 2>/dev/null | awk '/"OPENAI CUA E2E"/ && /xfce4-terminal/ {{print $1; exit}}')
test -n "$window_id" && break
sleep 0.1
done
@@ -547,7 +552,7 @@ async def cleanup_resources(
agents: AgentsClient,
*,
session: dict[str, Any] | None,
- pool: Pool | None,
+ sandbox: Sandbox | None,
) -> list[Exception]:
errors: list[Exception] = []
if session is not None:
@@ -559,9 +564,9 @@ async def cleanup_resources(
await agents.close()
except Exception as error:
errors.append(error)
- if pool is not None:
+ if sandbox is not None:
try:
- await pool.delete()
+ await sandbox.destroy()
except Exception as error:
errors.append(error)
return errors
@@ -570,52 +575,112 @@ async def cleanup_resources(
async def main() -> None:
application_key = required_env("OPENAI_API_KEY")
environment_key = required_env("CODEX_API_KEY")
- selected_pool_name = pool_name()
output_path = Path(
- os.environ.get("CUA_ARTIFACT_DESTINATION", "openai-cua-fleet-e2e.txt")
+ os.environ.get("CUA_ARTIFACT_DESTINATION", "openai-cua-e2e.txt")
).resolve()
agents = AgentsClient(application_key)
- pool: Pool | None = None
session: dict[str, Any] | None = None
- sandbox: Any = None
+ sandbox: Sandbox | None = None
executor_running = False
run_error: Exception | None = None
try:
# Default services: cua-spacesd published as `env` on port 3211.
- pool = await Pool.apply(
+ sandbox = await Sandbox.create(
Image.from_registry(IMAGE, os_type="linux", kind="container")
if IMAGE
else Image.linux(),
- name=selected_pool_name,
- replicas=1,
+ name=sandbox_name(),
+ on=LOCATION,
cpu=4,
memory_mb=8192,
- ttl_seconds_after_created=7200,
- )
- async with pool.claim(
- name=f"session-{secrets.token_hex(4)}",
time_to_start=1800,
- ttl_seconds_after_created=3600,
- ) as sandbox:
- print(f"Cua pool: {sandbox.pool_name}")
- print(f"Cua claim: {sandbox.claim_name}")
- codex_path, driver_path = await install_runtime(sandbox)
- display = (await checked(sandbox, "printf %s \"${DISPLAY:-:1}\"")).strip() or ":1"
-
- session = await agents.create_session(driver_path)
- session_id = session["id"]
- environment = session["environment"]
- launcher = executor_launcher(
- codex_path=codex_path,
- remote_url=environment["remote_url"],
- environment_id=environment["id"],
- display=display,
- )
+ )
+ print(f"Cua sandbox: {sandbox.id}")
+ codex_path, driver_path = await install_runtime(sandbox)
+ display = (await checked(sandbox, "printf %s \"${DISPLAY:-:1}\"")).strip() or ":1"
+
+ session = await agents.create_session(driver_path)
+ session_id = session["id"]
+ environment = session["environment"]
+ launcher = executor_launcher(
+ codex_path=codex_path,
+ remote_url=environment["remote_url"],
+ environment_id=environment["id"],
+ display=display,
+ )
+
+ async with agents.event_lines(session_id) as lines:
+ monitor = EventMonitor(lines)
+ try:
+ await start_executor(
+ sandbox,
+ environment_key=environment_key,
+ launcher=launcher,
+ )
+ executor_running = True
+ await monitor.wait_for_type("agent.session.environment.connected")
+ print("Executor connection: PASS")
+
+ await agents.send_message(
+ session_id,
+ f"Write exactly {ARTIFACT_CONTENT.strip()!r} followed by a newline "
+ f"to {ARTIFACT_PATH}. Read the file back and report the exact "
+ "contents. Then perform this desktop check with the cua_driver MCP "
+ f"tools. (1) Call `launch_app` with name `/bin/bash` and "
+ f"additional_arguments [`{E2E_TERMINAL_PATH}`]. (2) Use the shell to "
+ f"wait up to 10 seconds for `{E2E_TARGET_PATH}` to become non-empty, "
+ "then read its two integers; they are the terminal's owner PID and "
+ "window ID. This read is discovery only, not UI automation. (3) Call "
+ "`get_window_state` for that exact PID and window ID. (4) Call `click` "
+ "on the `File` menu using the element token from that snapshot, not "
+ "coordinates. (5) Call `get_window_state` again, then call `click` on "
+ "`Close Terminal` or `Close Window` using the fresh element token from "
+ "the second snapshot. (6) Use the shell only to verify that the "
+ "published terminal PID is no longer running. Do not report success "
+ "unless every step completed.",
+ )
+ first_turn = await monitor.wait_for_root_turn()
+ if first_turn["type"] != "agent.session.turn.completed":
+ raise RuntimeError(
+ "First turn did not complete: "
+ + json.dumps(first_turn, sort_keys=True)
+ )
+ initial_artifact = await sandbox.files.read_bytes(ARTIFACT_PATH)
+ if initial_artifact != ARTIFACT_CONTENT.encode():
+ raise RuntimeError(
+ "Agent-created artifact content did not match"
+ )
+ await verify_desktop_evidence(sandbox)
+ print("Cua Driver MCP evidence: PASS")
- async with agents.event_lines(session_id) as lines:
- monitor = EventMonitor(lines)
+ await stop_executor(sandbox)
+ executor_running = False
+ await monitor.wait_for_type("agent.session.environment.disconnected")
+ print("Executor disconnect observation: PASS")
+
+ second_submission = asyncio.create_task(
+ agents.send_message(
+ session_id,
+ f"Read {ARTIFACT_PATH} and report its exact contents, including "
+ "whether it ends with a newline.",
+ )
+ )
try:
+ await monitor.wait_for_type(
+ "agent.session.requires_action", timeout=60
+ )
+ pending_session = await agents.retrieve_session(session_id)
+ required_actions = pending_session.get("required_actions", [])
+ if not any(
+ action.get("type") == "environment_connection"
+ and action.get("environment_id") == environment["id"]
+ for action in required_actions
+ if isinstance(action, dict)
+ ):
+ raise RuntimeError(
+ "Session did not request the original environment connection"
+ )
await start_executor(
sandbox,
environment_key=environment_key,
@@ -623,104 +688,36 @@ async def main() -> None:
)
executor_running = True
await monitor.wait_for_type("agent.session.environment.connected")
- print("Executor connection: PASS")
-
- await agents.send_message(
- session_id,
- f"Write exactly {ARTIFACT_CONTENT.strip()!r} followed by a newline "
- f"to {ARTIFACT_PATH}. Read the file back and report the exact "
- "contents. Then perform this desktop check with the cua_driver MCP "
- f"tools. (1) Call `launch_app` with name `/bin/bash` and "
- f"additional_arguments [`{E2E_TERMINAL_PATH}`]. (2) Use the shell to "
- f"wait up to 10 seconds for `{E2E_TARGET_PATH}` to become non-empty, "
- "then read its two integers; they are the terminal's owner PID and "
- "window ID. This read is discovery only, not UI automation. (3) Call "
- "`get_window_state` for that exact PID and window ID. (4) Call `click` "
- "on the `File` menu using the element token from that snapshot, not "
- "coordinates. (5) Call `get_window_state` again, then call `click` on "
- "`Close Terminal` or `Close Window` using the fresh element token from "
- "the second snapshot. (6) Use the shell only to verify that the "
- "published terminal PID is no longer running. Do not report success "
- "unless every step completed.",
+ print("Same-environment reconnect: PASS")
+ await second_submission
+ finally:
+ if not second_submission.done():
+ second_submission.cancel()
+ with contextlib.suppress(asyncio.CancelledError):
+ await second_submission
+
+ second_turn = await monitor.wait_for_root_turn()
+ if second_turn["type"] != "agent.session.turn.completed":
+ raise RuntimeError(
+ "Second turn did not complete: "
+ + json.dumps(second_turn, sort_keys=True)
)
- first_turn = await monitor.wait_for_root_turn()
- if first_turn["type"] != "agent.session.turn.completed":
- raise RuntimeError(
- "First turn did not complete: "
- + json.dumps(first_turn, sort_keys=True)
- )
- initial_artifact = await sandbox.files.read_bytes(ARTIFACT_PATH)
- if initial_artifact != ARTIFACT_CONTENT.encode():
- raise RuntimeError(
- "Agent-created Fleet artifact content did not match"
- )
- await verify_desktop_evidence(sandbox)
- print("Cua Driver MCP evidence: PASS")
+ await agents.list_items(session_id)
+ artifact = await sandbox.files.read_bytes(ARTIFACT_PATH)
+ if artifact != ARTIFACT_CONTENT.encode():
+ raise RuntimeError("Retrieved artifact content did not match")
+ output_path.write_bytes(artifact)
+ print(f"Artifact retrieval: PASS ({output_path})")
+ finally:
+ await monitor.close()
+ if executor_running:
await stop_executor(sandbox)
executor_running = False
- await monitor.wait_for_type("agent.session.environment.disconnected")
- print("Executor disconnect observation: PASS")
-
- second_submission = asyncio.create_task(
- agents.send_message(
- session_id,
- f"Read {ARTIFACT_PATH} and report its exact contents, including "
- "whether it ends with a newline.",
- )
- )
- try:
- await monitor.wait_for_type(
- "agent.session.requires_action", timeout=60
- )
- pending_session = await agents.retrieve_session(session_id)
- required_actions = pending_session.get("required_actions", [])
- if not any(
- action.get("type") == "environment_connection"
- and action.get("environment_id") == environment["id"]
- for action in required_actions
- if isinstance(action, dict)
- ):
- raise RuntimeError(
- "Session did not request the original environment connection"
- )
- await start_executor(
- sandbox,
- environment_key=environment_key,
- launcher=launcher,
- )
- executor_running = True
- await monitor.wait_for_type("agent.session.environment.connected")
- print("Same-environment reconnect: PASS")
- await second_submission
- finally:
- if not second_submission.done():
- second_submission.cancel()
- with contextlib.suppress(asyncio.CancelledError):
- await second_submission
-
- second_turn = await monitor.wait_for_root_turn()
- if second_turn["type"] != "agent.session.turn.completed":
- raise RuntimeError(
- "Second turn did not complete: "
- + json.dumps(second_turn, sort_keys=True)
- )
-
- await agents.list_items(session_id)
- artifact = await sandbox.files.read_bytes(ARTIFACT_PATH)
- if artifact != ARTIFACT_CONTENT.encode():
- raise RuntimeError("Retrieved Fleet artifact content did not match")
- output_path.write_bytes(artifact)
- print(f"Artifact retrieval: PASS ({output_path})")
- finally:
- await monitor.close()
- if executor_running:
- await stop_executor(sandbox)
- executor_running = False
except Exception as error:
run_error = error
finally:
- cleanup_errors = await cleanup_resources(agents, session=session, pool=pool)
+ cleanup_errors = await cleanup_resources(agents, session=session, sandbox=sandbox)
if run_error is not None:
if cleanup_errors:
@@ -732,7 +729,7 @@ async def main() -> None:
if cleanup_errors:
raise ExceptionGroup("Resource cleanup failed", cleanup_errors)
- print("OpenAI session, Fleet claim, and Fleet pool cleanup: PASS")
+ print("OpenAI session and sandbox cleanup: PASS")
if __name__ == "__main__":
diff --git a/docs/scripts/tests/test_openai_agents_fleet_example.py b/docs/scripts/tests/test_openai_agents_example.py
similarity index 79%
rename from docs/scripts/tests/test_openai_agents_fleet_example.py
rename to docs/scripts/tests/test_openai_agents_example.py
index 1081f922ed..38442e0ad9 100644
--- a/docs/scripts/tests/test_openai_agents_fleet_example.py
+++ b/docs/scripts/tests/test_openai_agents_example.py
@@ -10,7 +10,7 @@ from unittest.mock import patch
DOCS_ROOT = Path(__file__).resolve().parents[2]
SCRIPT = (
DOCS_ROOT
- / "public/scripts/openai-agents-fleet/run_openai_agents_fleet.py"
+ / "public/scripts/openai-agents/run_openai_agents.py"
)
GUIDE = (
DOCS_ROOT
@@ -19,19 +19,27 @@ GUIDE = (
META = DOCS_ROOT / "content/docs/cua-sdk/guides/meta.json"
-def test_disposable_pool_name_ignores_existing_pool_override() -> None:
+def test_disposable_sandbox_name_ignores_existing_sandbox() -> None:
tree = ast.parse(SCRIPT.read_text())
function = next(node for node in tree.body if isinstance(node, ast.FunctionDef)
- and node.name == "pool_name")
+ and node.name == "sandbox_name")
namespace = {"os": os, "secrets": secrets}
exec(compile(ast.Module(body=[function], type_ignores=[]), str(SCRIPT), "exec"), namespace)
- with patch.dict(os.environ, {"CUA_POOL_NAME": "existing-production-pool"}):
- first = namespace["pool_name"]()
- second = namespace["pool_name"]()
+ with patch.dict(os.environ, {"CUA_SANDBOX_NAME": "existing-sandbox"}):
+ first = namespace["sandbox_name"]()
+ second = namespace["sandbox_name"]()
assert first != second
- assert first.startswith("cua-openai-agents-")
- assert len(first.removeprefix("cua-openai-agents-")) == 24
- assert len(f"{first}-a84951d4-server".encode()) <= 63
+ assert first.startswith("openai-agents-")
+ assert len(first.removeprefix("openai-agents-")) == 12
+
+
+def test_controller_does_not_use_fleets() -> None:
+ source = SCRIPT.read_text()
+ assert "Pool" not in source
+ assert "claim(" not in source
+ assert "await Sandbox.create(" in source
+ assert 'LOCATION = os.environ.get("CUA_ON", "local")' in source
+ assert "on=LOCATION" in source
def test_controller_uses_the_spacesd_image_and_default_services() -> None:
@@ -65,11 +73,11 @@ def test_controller_covers_reconnect_artifact_and_cleanup() -> None:
assert 'wait_for_type("agent.session.environment.disconnected")' in source
assert source.count("await start_executor(") >= 2
assert "await sandbox.files.read_bytes(ARTIFACT_PATH)" in source
- assert "Agent-created Fleet artifact content did not match" in source
+ assert "Agent-created artifact content did not match" in source
assert 'page.get("has_more")' in source
assert 'page.get("last_id")' in source
assert "await agents.delete_session" in source
- assert "await pool.delete()" in source
+ assert "await sandbox.destroy()" in source
assert 'response.status_code == 409' in source
assert "contextlib.suppress(Exception)" not in source
assert 'raise ExceptionGroup("Resource cleanup failed", cleanup_errors)' in source
@@ -105,7 +113,7 @@ def test_controller_registers_cua_driver_as_required_stdio_mcp() -> None:
def test_guide_links_the_download_and_navigation_entry() -> None:
guide = GUIDE.read_text()
meta = META.read_text()
- assert "https://cua.ai/docs-assets/scripts/openai-agents-fleet/run_openai_agents_fleet.py" in guide
- assert "https://cua.ai/scripts/openai-agents-fleet/" not in guide
+ assert "https://cua.ai/docs-assets/scripts/openai-agents/run_openai_agents.py" in guide
+ assert "openai-agents-fleet" not in guide
assert '"agent-frameworks"' in meta
assert "## OpenAI Agents API" in guide
diff --git a/scripts/images/image-refs-allowlist.json b/scripts/images/image-refs-allowlist.json
index 77ca214cef..6b97825562 100644
--- a/scripts/images/image-refs-allowlist.json
+++ b/scripts/images/image-refs-allowlist.json
@@ -641,7 +641,7 @@
"paths": [
".github/workflows/cd-image-linux.yml",
"docs/public/img/SOURCES.md",
- "docs/scripts/tests/test_openai_agents_fleet_example.py",
+ "docs/scripts/tests/test_openai_agents_example.py",
"libs/cua/bench/streaming/results/baseline-macos-arm64.json",
"libs/cua/bench/streaming/results/baseline-macos-arm64.md",
"libs/cua/crates/cua-cli/src/image_build.rs",