Skip to main content

Overview

DaytonaTools extends ToolKit and uses Daytona cloud sandboxes for running code, shell commands, managing files, and git operations in an isolated environment. Supports Python, TypeScript, and JavaScript.
ToolKit: DaytonaTools inherits from ToolKit. You get all base behavior (e.g. include_tools, exclude_tools, timeout, use_async). See Creating ToolKit for the full API.
Required: Set DAYTONA_API_KEY (env or .env). Install: pip install daytona.
Tools (11): daytona_run_code, daytona_run_command, daytona_install_packages, daytona_create_file, daytona_read_file, daytona_list_files, daytona_delete_file, daytona_search_files, daytona_git_clone, daytona_get_sandbox_info, daytona_shutdown_sandbox. Use ToolKit’s exclude_tools / include_tools to limit which tools the agent sees.
All tools are prefixed with daytona_ (e.g. daytona_run_code, daytona_create_file) to avoid name collisions with local filesystem tools or other sandbox toolkits when used alongside AutonomousAgent.

Examples

Basic: Agent with Daytona

from upsonic import Agent, Task
from upsonic.tools.custom_tools.daytona import DaytonaTools

agent = Agent(model="openai/gpt-4o", tools=[DaytonaTools()])
task = Task(description="Write a Python function to check if a number is prime, then test it with 17 and 20.")
result = agent.print_do(task)
print(result)

AutonomousAgent: Local Filesystem + Remote Sandbox

The most powerful pattern: the agent edits files locally in the workspace, but all code execution happens in a secure remote sandbox.
from upsonic import AutonomousAgent, Task
from upsonic.tools.custom_tools.daytona import DaytonaTools

agent = AutonomousAgent(
    model="openai/gpt-4o",
    workspace="/path/to/project",
    enable_filesystem=True,   # local: write_file, edit_file, read_file, etc.
    enable_shell=False,       # disable local shell execution
    tools=[DaytonaTools()],   # remote: daytona_run_code, daytona_run_command, daytona_install_packages, daytona_git_clone
)

task = Task(description="Read main.py, then run it in the sandbox and fix any errors.")
result = agent.print_do(task)
CapabilityWhere it runsTools
File write/edit/deleteLocal workspace (sandboxed)write_file, edit_file, delete_file, move_file, copy_file
File read/searchLocal workspace (sandboxed)read_file, list_files, search_files, grep_files
Code executionRemote Daytona sandboxdaytona_run_code (Python/TypeScript/JavaScript)
Shell commandsRemote Daytona sandboxdaytona_run_command
Package installRemote Daytona sandboxdaytona_install_packages
Sandbox file opsRemote Daytona sandboxdaytona_create_file, daytona_read_file, daytona_list_files, daytona_delete_file
Content searchRemote Daytona sandboxdaytona_search_files
Git operationsRemote Daytona sandboxdaytona_git_clone

Advanced: Custom Configuration

from upsonic import Agent, Task
from upsonic.tools.custom_tools.daytona import DaytonaTools

tools = DaytonaTools(
    auto_stop_interval=120,                # 2-hour auto-stop
    sandbox_language="python",             # default language for code execution
    env_vars={"MY_API_KEY": "sk-..."},     # env vars available in sandbox
    labels={"project": "demo"},            # metadata labels
    exclude_tools=["daytona_shutdown_sandbox"],  # prevent agent from killing sandbox
)

agent = Agent(model="anthropic/claude-sonnet-4-6", tools=[tools])
task = Task(description="Install pandas and matplotlib, then create a bar chart of sales data.")
result = agent.print_do(task)

Connect to an Existing Sandbox

from upsonic import Agent, Task
from upsonic.tools.custom_tools.daytona import DaytonaTools

# Connect to a previously created sandbox instead of creating a new one
tools = DaytonaTools(sandbox_id="my-existing-sandbox-id")

agent = Agent(model="openai/gpt-4o", tools=[tools])
task = Task(description="Check what files exist in the sandbox and run any Python scripts.")
result = agent.print_do(task)

Git Clone + Run

from upsonic import Agent, Task
from upsonic.tools.custom_tools.daytona import DaytonaTools

agent = Agent(model="openai/gpt-4o", tools=[DaytonaTools()])

task = Task(
    description=(
        "Clone the repo https://github.com/example/project into /home/daytona/project, "
        "install its dependencies, then run the test suite."
    )
)
result = agent.print_do(task)

Parameters

ParameterTypeDefaultDescription
api_keystr | Nonefrom env DAYTONA_API_KEYDaytona API key.
api_urlstr | Nonefrom env DAYTONA_API_URLDaytona API URL. Defaults to https://app.daytona.io/api.
targetstr | Nonefrom env DAYTONA_TARGETTarget region for sandbox deployment.
organization_idstr | NoneNoneOrganization ID for multi-org setups.
sandbox_idstr | NoneNoneConnect to an existing sandbox instead of creating a new one.
sandbox_languagestr | None"python"Default code language: python, typescript, or javascript.
os_userstr | NoneNoneOS user for sandbox commands.
env_varsdict | NoneNoneEnvironment variables to set in the sandbox.
labelsdict | None{}Labels to attach to the sandbox for organization.
auto_stop_intervalint | None60Minutes of inactivity before auto-stop. Set 0 to disable.
timeoutint300Sandbox creation/start timeout in seconds.

Tools Reference

Code Execution

ToolDescription
daytona_run_codeExecute code in the sandbox. Supports python, typescript, javascript. Returns output and exit code.
daytona_run_commandRun a shell command in the sandbox. Returns output and exit code.
daytona_install_packagesInstall packages via pip (Python) or npm (JavaScript/TypeScript).

File Operations

ToolDescription
daytona_create_fileCreate or overwrite a file in the sandbox. Auto-creates parent directories.
daytona_read_fileRead a text file from the sandbox.
daytona_list_filesList files and directories with metadata (name, type, size, permissions).
daytona_delete_fileDelete a file or directory (recursive for directories).
daytona_search_filesSearch for content within files using grep-like pattern matching.

Git Operations

ToolDescription
daytona_git_cloneClone a Git repository into the sandbox. Supports branch selection.

Sandbox Management

ToolDescription
daytona_get_sandbox_infoGet sandbox status: sandbox_id, state, CPU, memory, disk, labels.
daytona_shutdown_sandboxStop and delete the sandbox, releasing all resources.