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.

Updated `docs/content/docs/agent-sdk/agent-loops.mdx:16-46` with the complete working example that includes: - `asyncio` import and `asyncio.run()` - `async with Computer()` context manager - Full `Computer()` initialization with all required parameters - Proper message format as a list of dictionaries - Complete `async for` loop with item iteration

Your Name7253d39fe76d
diff --git a/docs/content/docs/agent-sdk/agent-loops.mdx b/docs/content/docs/agent-sdk/agent-loops.mdx
index 33bf66e2d9..6cd8daefb6 100644
--- a/docs/content/docs/agent-sdk/agent-loops.mdx
+++ b/docs/content/docs/agent-sdk/agent-loops.mdx
@@ -15,20 +15,34 @@ To run an agent loop simply do:
```python
from agent import ComputerAgent
+import asyncio
from computer import Computer
-computer = Computer() # Connect to a cua container
-agent = ComputerAgent(
- model="anthropic/claude-3-5-sonnet-20241022",
- tools=[computer]
-)
+async def take_screenshot():
+ async with Computer(
+ os_type="linux",
+ provider_type="cloud",
+ name="m-linux-h3sj2qbz2a",
+ api_key=""
+ ) as computer:
+
+ agent = ComputerAgent(
+ model="anthropic/claude-3-5-sonnet-20241022",
+ tools=[computer],
+ max_trajectory_budget=5.0
+ )
-prompt = "Take a screenshot and tell me what you see"
+ messages = [{"role": "user", "content": "Take a screenshot and tell me what you see"}]
-async for result in agent.run(prompt):
- if result["output"][-1]["type"] == "message":
- print("Agent:", result["output"][-1]["content"][0]["text"])
+ async for result in agent.run(messages):
+ for item in result["output"]:
+ if item["type"] == "message":
+ print(item["content"][0]["text"])
+
+
+if __name__ == "__main__":
+ asyncio.run(take_screenshot())
```
For a list of supported models and configurations, see the [Supported Agents](./supported-agents/computer-use-agents) page.
@@ -170,4 +184,4 @@ except BudgetExceededException:
print("Budget limit exceeded")
except Exception as e:
print(f"Agent error: {e}")
-```
\ No newline at end of file
+```