Documentation Index
Fetch the complete documentation index at: https://docs.crewai.com/llms.txt
Use this file to discover all available pages before exploring further.
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; also supportsmove,find(content grep),search(filename glob),chmod(permissions),replace(bulk find-and-replace), andexists.
Installation
DAYTONA_API_URL and DAYTONA_TARGET are also respected if set.
Sandbox Lifecycle
All three tools inherit lifecycle controls fromDaytonaBaseTool:
| Mode | How to enable | Sandbox created | Sandbox deleted |
|---|---|---|---|
| Ephemeral (default) | persistent=False (default) | On every _run call | At the end of that same call |
| Persistent | persistent=True | Lazily on first use | At process exit (via atexit), or manually via tool.close() |
| Attach | sandbox_id="<id>" | Never — attaches to an existing sandbox | Never — the tool will not delete a sandbox it did not create |
DaytonaFileTool with DaytonaExecTool.
Examples
One-shot Python execution (ephemeral)
Code
Multi-step shell session (persistent)
Code
By default, each tool with
persistent=True lazily creates its own sandbox on first use. The pattern above shares a single sandbox across multiple tools by reading the first tool’s active_sandbox_id after a .run() call and passing it to the others via sandbox_id=.... With persistent=False (the default), every .run() call gets a fresh sandbox that’s deleted at the end of that call.Attach to an existing sandbox
Code
Custom sandbox parameters
Pass Daytona’sCreateSandboxFromSnapshotParams kwargs via create_params:
Code
Searching, moving, and modifying files
Code
Agent integration
Code
Parameters
Shared (DaytonaBaseTool)
All three tools accept these parameters at initialization:
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | None | $DAYTONA_API_KEY | Daytona API key. Falls back to the DAYTONA_API_KEY env var. |
api_url | str | None | $DAYTONA_API_URL | Daytona API URL override. |
target | str | None | $DAYTONA_TARGET | Daytona target region. |
persistent | bool | False | Reuse one sandbox across all calls and delete it at process exit. |
sandbox_id | str | None | None | Attach to an existing sandbox by id or name. |
create_params | dict | None | None | Extra kwargs forwarded to CreateSandboxFromSnapshotParams (e.g. language, env_vars, labels). |
sandbox_timeout | float | 60.0 | Timeout in seconds for sandbox create/delete operations. |
DaytonaExecTool
| Parameter | Type | Required | Description |
|---|---|---|---|
command | str | ✓ | Shell command to execute. |
cwd | str | None | Working directory inside the sandbox. | |
env | dict[str, str] | None | Extra environment variables for this command. | |
timeout | int | None | Maximum seconds to wait for the command. |
DaytonaPythonTool
| Parameter | Type | Required | Description |
|---|---|---|---|
code | str | ✓ | Python source code to execute. |
argv | list[str] | None | Argument vector forwarded via CodeRunParams. | |
env | dict[str, str] | None | Environment variables forwarded via CodeRunParams. | |
timeout | int | None | Maximum seconds to wait for execution. |
DaytonaFileTool
| Parameter | Type | Required | Description |
|---|---|---|---|
action | str | ✓ | One of: read, write, append, list, delete, mkdir, info, exists, move, find, search, chmod, replace. |
path | str | None | ✓ for all actions except replace | Absolute path inside the sandbox. |
content | str | None | ✓ for append | Content to write or append. |
binary | bool | If True, content is base64 on write; returns base64 on read. | |
recursive | bool | For delete: remove directories recursively. | |
mode | str | None | For mkdir: octal permissions for the new directory (defaults to "0755"). For chmod: octal permissions to apply to the target. | |
destination | str | None | ✓ for move | Destination path for move. |
pattern | str | None | ✓ for find, search, replace | For find: substring matched against file CONTENTS. For search: glob matched against file NAMES (e.g. *.py). For replace: text to replace inside files. |
replacement | str | None | ✓ for replace | Replacement text for pattern. |
paths | list[str] | None | ✓ for replace | List of file paths in which to replace text. |
owner | str | None | For chmod: new file owner. | |
group | str | None | For chmod: new file group. |
For
chmod, pass at least one of mode, owner, or group — any field left as None is left unchanged on the target.