Skip to main content

Daytona Sandbox Tools

Description

The Daytona sandbox tools give CrewAI agents access to isolated, ephemeral compute environments powered by Daytona. Three tools are available so you can give an agent exactly the capabilities it needs:
  • DaytonaExecTool — run any shell command inside a sandbox.
  • DaytonaPythonTool — execute a block of Python source code inside a sandbox.
  • DaytonaFileTool — read, write, append, list, delete, and inspect files inside a sandbox.
All three tools share the same sandbox lifecycle controls, so you can mix and match them while keeping state in a single persistent sandbox.

Installation

Set your API key:
DAYTONA_API_URL and DAYTONA_TARGET are also respected if set.

Sandbox Lifecycle

All three tools inherit lifecycle controls from DaytonaBaseTool: Ephemeral mode is the safe default: nothing leaks if the agent forgets to clean up. Use persistent mode when you want filesystem state or installed packages to carry across multiple tool calls — this is typical when pairing DaytonaFileTool with DaytonaExecTool.

Examples

One-shot Python execution (ephemeral)

Code

Multi-step shell session (persistent)

Code
Each tool instance maintains its own persistent sandbox. To share one sandbox across two tools, create the first tool, grab its sandbox id via tool._persistent_sandbox.id, and pass it to the second tool via sandbox_id=....

Attach to an existing sandbox

Code

Custom sandbox parameters

Pass Daytona’s CreateSandboxFromSnapshotParams kwargs via create_params:
Code

Agent integration

Code

Parameters

Shared (DaytonaBaseTool)

All three tools accept these parameters at initialization:

DaytonaExecTool

DaytonaPythonTool

DaytonaFileTool

For files larger than a few KB, create the file first with action="write" and empty content, then send the body via multiple action="append" calls of ~4 KB each to stay within tool-call payload limits.