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.

Clean notebooks for standardized agent loop

f-trycua3dd772324dee
diff --git a/notebooks/agent_nb.ipynb b/notebooks/agent_nb.ipynb
index 24b2e15fd8..41cf6be53c 100644
--- a/notebooks/agent_nb.ipynb
+++ b/notebooks/agent_nb.ipynb
@@ -18,19 +18,11 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "zsh:1: no matches found: cua-agent[all]\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
- "!pip uninstall cua-agent[all]"
+ "!pip uninstall -y cua-agent"
]
},
{
@@ -79,12 +71,12 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
- "from agent import AgentLoop, LLMProvider\n",
- "from computer import Computer"
+ "from computer import Computer\n",
+ "from agent import ComputerAgent, LLM, AgentLoop, LLMProvider"
]
},
{
@@ -96,7 +88,7 @@
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -118,10 +110,8 @@
"metadata": {},
"outputs": [],
"source": [
- "from datetime import datetime\n",
"import logging\n",
"from pathlib import Path\n",
- "from agent.core.computer_agent import ComputerAgent, LLM\n",
"\n",
"computer = Computer(verbosity=logging.INFO)\n",
"\n",
@@ -129,9 +119,7 @@
"agent = ComputerAgent(\n",
" computer=computer,\n",
" loop=AgentLoop.ANTHROPIC,\n",
- " # loop=AgentLoop.OMNI,\n",
" model=LLM(provider=LLMProvider.ANTHROPIC, name=\"claude-3-7-sonnet-20250219\"),\n",
- " # model=LLM(provider=LLMProvider.OPENAI, name=\"gpt-4.5-preview\"),\n",
" save_trajectory=True,\n",
" trajectory_dir=str(Path(\"trajectories\")),\n",
" only_n_most_recent_images=3,\n",
@@ -139,21 +127,21 @@
" )\n",
"\n",
"tasks = [\n",
- "\"\"\"\n",
- "Please help me with the following task:\n",
- "1. Open Safari browser\n",
- "2. Go to Wikipedia.org\n",
- "3. Search for \"Claude AI\" \n",
- "4. Summarize the main points you find about Claude AI\n",
- "\"\"\"\n",
+ " \"Look for a repository named trycua/cua on GitHub.\",\n",
+ " \"Check the open issues, open the most recent one and read it.\",\n",
+ " \"Clone the repository in users/lume/projects if it doesn't exist yet.\",\n",
+ " \"Open the repository with an app named Cursor (on the dock, black background and white cube icon).\",\n",
+ " \"From Cursor, open Composer if not already open.\",\n",
+ " \"Focus on the Composer text area, then write and submit a task to help resolve the GitHub issue.\",\n",
"]\n",
"\n",
- "async with agent:\n",
- " for i, task in enumerate(tasks, 1):\n",
- " print(f\"\\nExecuting task {i}/{len(tasks)}: {task}\")\n",
- " async for result in agent.run(task):\n",
- " print(result)\n",
- " print(f\"Task {i} completed\")\n"
+ "for i, task in enumerate(tasks):\n",
+ " print(f\"\\nExecuting task {i}/{len(tasks)}: {task}\")\n",
+ " async for result in agent.run(task):\n",
+ " # print(result)\n",
+ " pass\n",
+ "\n",
+ " print(f\"\\n✅ Task {i+1}/{len(tasks)} completed: {task}\")"
]
},
{
@@ -169,41 +157,40 @@
"metadata": {},
"outputs": [],
"source": [
- "from datetime import datetime\n",
"import logging\n",
"from pathlib import Path\n",
+ "from agent import ComputerAgent, LLM, AgentLoop\n",
"\n",
"computer = Computer(verbosity=logging.INFO)\n",
"\n",
"# Create agent with Anthropic loop and provider\n",
"agent = ComputerAgent(\n",
- " computer=computer,\n",
- " # loop=AgentLoop.ANTHROPIC,\n",
- " loop=AgentLoop.OMNI,\n",
- " model=LLM(provider=LLMProvider.OPENAI, name=\"gpt-4.5-preview\"),\n",
- " # model=LLM(provider=LLMProvider.ANTHROPIC, name=\"claude-3-7-sonnet-20250219\"),\n",
- " save_trajectory=True,\n",
- " trajectory_dir=str(Path(\"trajectories\")),\n",
- " only_n_most_recent_images=3,\n",
- " verbosity=logging.INFO,\n",
- ")\n",
+ " computer=computer,\n",
+ " loop=AgentLoop.OMNI,\n",
+ " model=LLM(provider=LLMProvider.ANTHROPIC, name=\"claude-3-7-sonnet-20250219\"),\n",
+ " # model=LLM(provider=LLMProvider.OPENAI, name=\"gpt-4.5-preview\"),\n",
+ " save_trajectory=True,\n",
+ " trajectory_dir=str(Path(\"trajectories\")),\n",
+ " only_n_most_recent_images=3,\n",
+ " verbosity=logging.INFO\n",
+ " )\n",
"\n",
"tasks = [\n",
- "\"\"\"\n",
- "Please help me with the following task:\n",
- "1. Open Safari browser\n",
- "2. Go to Wikipedia.org\n",
- "3. Search for \"Claude AI\" \n",
- "4. Summarize the main points you find about Claude AI\n",
- "\"\"\"\n",
+ " \"Look for a repository named trycua/cua on GitHub.\",\n",
+ " \"Check the open issues, open the most recent one and read it.\",\n",
+ " \"Clone the repository in users/lume/projects if it doesn't exist yet.\",\n",
+ " \"Open the repository with an app named Cursor (on the dock, black background and white cube icon).\",\n",
+ " \"From Cursor, open Composer if not already open.\",\n",
+ " \"Focus on the Composer text area, then write and submit a task to help resolve the GitHub issue.\",\n",
"]\n",
"\n",
- "async with agent:\n",
- " for i, task in enumerate(tasks, 1):\n",
- " print(f\"\\nExecuting task {i}/{len(tasks)}: {task}\")\n",
- " async for result in agent.run(task):\n",
- " print(result)\n",
- " print(f\"Task {i} completed\")\n"
+ "for i, task in enumerate(tasks):\n",
+ " print(f\"\\nExecuting task {i}/{len(tasks)}: {task}\")\n",
+ " async for result in agent.run(task):\n",
+ " # print(result)\n",
+ " pass\n",
+ "\n",
+ " print(f\"\\n✅ Task {i+1}/{len(tasks)} completed: {task}\")"
]
}
],
diff --git a/notebooks/computer_nb.ipynb b/notebooks/computer_nb.ipynb
index 98a994cf73..c776fbfead 100644
--- a/notebooks/computer_nb.ipynb
+++ b/notebooks/computer_nb.ipynb
@@ -18,18 +18,9 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "\u001b[33mWARNING: Skipping cua-computer as it is not installed.\u001b[0m\u001b[33m\n",
- "\u001b[0m"
- ]
- }
- ],
+ "outputs": [],
"source": [
"!pip uninstall -y cua-computer"
]
@@ -177,7 +168,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
@@ -202,15 +193,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "Computer API Server not ready yet. Will retry automatically.\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"async with Computer(\n",
" # name=\"my_vm\", # optional, in case you want to use any other VM created using lume\n",
@@ -243,8 +226,7 @@
" os=\"macos\"\n",
")\n",
"\n",
- "await computer.run()\n",
- "# ... do something with the computer interface"
+ "await computer.run()"
]
},
{