Skip to main content

Daytona plugin for Google ADK

Project description

daytona-adk

Google ADK plugin for secure code execution in Daytona sandboxed environments. This plugin enables ADK agents to execute Python, JavaScript, and TypeScript code, run shell commands, upload scripts and datasets, and read outputs from files in isolated sandboxes.

Installation

pip install daytona-adk

Configuration

You must configure credentials for both Daytona (sandbox infrastructure) and Google Gemini (the LLM model used by ADK agents).

Daytona API Key

Get your API key from Daytona Dashboard.

You can configure it in one of three ways:

  1. Set the DAYTONA_API_KEY environment variable:

    export DAYTONA_API_KEY="your-daytona-api-key"
    
  2. Add it to a .env file in your project root:

    DAYTONA_API_KEY=your-daytona-api-key
    
  3. Pass the API key directly when instantiating DaytonaPlugin:

    from daytona_adk import DaytonaPlugin
    
    plugin = DaytonaPlugin(api_key="your-daytona-api-key")
    

Google API Key (for Gemini LLM)

Get your API key from Google AI Studio.

This key is required to access Google's Gemini models (e.g., gemini-2.0-flash, gemini-1.5-pro).

You need to set it as an environment variable:

export GOOGLE_API_KEY="your-google-api-key"

Or add it to your .env file:

GOOGLE_API_KEY=your-google-api-key

Quick Start

import asyncio
from google.adk.agents import Agent
from google.adk.runners import InMemoryRunner
from daytona_adk import DaytonaPlugin


async def main():
    # Create the Daytona plugin
    plugin = DaytonaPlugin()

    # Create an agent with Daytona tools
    agent = Agent(
        model="gemini-2.0-flash",
        name="agent_with_sandbox",
        tools=plugin.get_tools(),
    )

    # Run with InMemoryRunner
    async with InMemoryRunner(
        app_name="my_app",
        agent=agent,
        plugins=[plugin],
    ) as runner:
        response = await runner.run_debug(
            "Execute this Python code: print('Hello from Daytona!')"
        )
        print(response)


if __name__ == "__main__":
    asyncio.run(main())

Usage Patterns

Using with App (Recommended)

from google.adk.agents import Agent
from google.adk.apps import App
from google.adk.runners import InMemoryRunner
from daytona_adk import DaytonaPlugin

plugin = DaytonaPlugin()

agent = Agent(
    model="gemini-2.0-flash",
    name="agent_with_sandbox",
    tools=plugin.get_tools(),
)

app = App(
    name="my_app",
    root_agent=agent,
    plugins=[plugin],
)

async with InMemoryRunner(app=app) as runner:
    response = await runner.run_debug("Execute Python: print('Hello!')")

Using with Runner Directly

from google.adk.agents import Agent
from google.adk.runners import InMemoryRunner
from daytona_adk import DaytonaPlugin

plugin = DaytonaPlugin()

agent = Agent(
    model="gemini-2.0-flash",
    name="agent_with_sandbox",
    tools=plugin.get_tools(),
)

async with InMemoryRunner(
    app_name="my_app",
    agent=agent,
    plugins=[plugin],
) as runner:
    response = await runner.run_debug("Run command: echo 'Hello!'")

Available Tools

The plugin provides the following tools to ADK agents:

Tool Description
execute_code_in_daytona Execute Python, JavaScript, or TypeScript code
execute_command_in_daytona Run shell commands
upload_file_to_daytona Upload scripts or data files to the sandbox
read_file_from_daytona Read script outputs or generated files
start_long_running_command_daytona Start background processes (servers, watchers)

Tool Parameters

execute_code_in_daytona

  • code (required): The code snippet to execute
  • language (required): Programming language - python (default), javascript, or typescript
  • env: Environment variables as key-value pairs
  • argv: Command line arguments
  • timeout: Timeout in seconds

execute_command_in_daytona

  • command (required): The shell command to execute
  • cwd: Working directory
  • env: Environment variables
  • timeout: Timeout in seconds

upload_file_to_daytona

  • file_path (required): Destination path for the file
  • content (required): File content to upload

read_file_from_daytona

  • file_path (required): Path of the file to read

start_long_running_command_daytona

  • command (required): The command to start
  • timeout: Timeout in seconds

Plugin Configuration

DaytonaPlugin(
    api_key="your-api-key",           # Daytona API key (or use DAYTONA_API_KEY env var)
    plugin_name="daytona_plugin",     # Plugin identifier
    sandbox_name="my-sandbox",        # Optional sandbox name
    env_vars={"KEY": "value"},        # Environment variables for the sandbox
    labels={"env": "dev"},            # Custom labels
    auto_stop_interval=15,            # Auto-stop after N minutes (0 to disable)
    auto_delete_interval=60,          # Auto-delete stopped sandbox after N minutes
)

Examples

See the examples/ directory for complete working examples:

Usage Patterns:

Specific Use Cases:

Architecture

daytona-adk-plugin/
├── daytona_adk/
│   ├── __init__.py           # Package exports
│   ├── plugin.py             # DaytonaPlugin (extends BasePlugin)
│   └── tools.py              # ADK tool implementations
├── examples/
│   ├── patterns/
│   │   ├── with_app.py       # App pattern example
│   │   └── with_runner.py    # Runner pattern example
│   ├── multi_language_execution.py  # Multi-language code execution
│   ├── file_operations.py           # Script upload and file reading
│   └── long_running_process.py      # Background process management
├── tests/
│   └── test_tools.py         # Tool unit tests
└── pyproject.toml

Key Components

  1. DaytonaPlugin: Extends BasePlugin

    • Creates and manages sandbox lifecycle
    • Provides tools via get_tools()
    • Implements lifecycle callbacks
  2. Tools: ADK tool implementations using BaseTool

    • Each tool wraps Daytona SDK operations
    • Shared sandbox instance for state persistence

License

Apache 2.0 - See LICENSE file for details.

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

daytona_adk-0.1.0.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

daytona_adk-0.1.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file daytona_adk-0.1.0.tar.gz.

File metadata

  • Download URL: daytona_adk-0.1.0.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for daytona_adk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bb61a03296c88424aff9a2974fc20caf5a43803d4582e8f8211581823ca9f1d4
MD5 f65ed6cb7a626d37da960d700290ec4c
BLAKE2b-256 7fb30d0ed2d27e91c627264aaf3506e196984f878dc52e2c4c06028600708f76

See more details on using hashes here.

File details

Details for the file daytona_adk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: daytona_adk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for daytona_adk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 28a2575e61d5ff8cc0cd8e44ab391ea1be36d2db4edb4c6adbe978092666da4b
MD5 9498ea2aad589d6f6b970efe34c366b0
BLAKE2b-256 7b52ae95852591f9034a960005dedaa72c9beea4f455221e0ade11b1a843a7e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page