LogoCua Documentation

Custom Tools

The Agent SDK supports defining custom Python tools that run securely in sandboxed environments on remote Cua Computers. This enables safe execution of user-defined functions, isolation of dependencies, and robust automation workflows.

Custom Tools

Define a custom tool for an agent:

def calculate(a: int, b: int) -> int:
    """Calculate the sum of two integers"""
    return a + b

# Use with agent
agent = ComputerAgent(
    model="anthropic/claude-3-5-sonnet-20241022",
    tools=[computer, calculate]
)

Sandboxed Tools

Define a sandboxed tool:

from computer.helpers import sandboxed

@sandboxed()
def read_file(location: str) -> str:
    """Read contents of a file"""
    with open(location, 'r') as f:
        return f.read()

You can then register this as a tool for your agent:

from agent import ComputerAgent
from computer import Computer

computer = Computer(...)
agent = ComputerAgent(
    model="anthropic/claude-3-5-sonnet-20241022",
    tools=[computer, read_file],
)