Skip to main content

boxd: composable computers for Google ADK agents

boxd-adk

Google ADK integration for boxd: give your agent a full Linux machine with a persistent disk, checkpoints, snapshots and live forks.

A boxd machine is a KVM microVM running Ubuntu 24.04, with sudo, Python, Node.js, Docker and a public HTTPS URL. It boots in about a second and keeps everything (files, packages, databases, running services) until you delete it. Idle machines go to sleep on their own and wake on the next command, so your agent can pick up yesterday's environment today. Before a risky change the agent can checkpoint the whole machine, memory included, and roll back in under a second if it goes wrong. From your own code you can also fork a running machine to try several approaches in parallel.

Installation

pip install boxd-adk

You'll need a boxd API key (sign up, then create a key in the console or with boxd auth keys create <name>):

export BOXD_API_KEY=...

Inside a boxd machine you can skip the key: the SDK signs in as the machine's owner.

Quickstart

import asyncio

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

from boxd_adk import BoxdPlugin

plugin = BoxdPlugin()  # or BoxdPlugin(machine_name="my-project") for a persistent machine

root_agent = Agent(
    model="gemini-flash-latest",
    name="boxd_agent",
    instruction="Run code and commands in the boxd machine, not locally.",
    tools=plugin.get_tools(),
)

# Registering the plugin on the App gives it lifecycle callbacks and error
# handling, and lets the runner delete the machine when it shuts down.
app = App(name="boxd_app", root_agent=root_agent, plugins=[plugin])


async def main():
    async with InMemoryRunner(app=app) as runner:
        await runner.run_debug("Use Python to compute 2**100, and tell me which OS you are on.")


asyncio.run(main())

Any ADK model works. For Claude, use model="anthropic/claude-sonnet-4-5" with pip install litellm and ANTHROPIC_API_KEY set.

Two modes

BoxdPlugin() BoxdPlugin(machine_name="my-project")
Machine name auto-generated adk-… yours
Reused across sessions no yes, full state persists
Deleted on plugin.close() yes no

The machine is created lazily on first tool use; constructing the agent needs no network. An existing machine that is asleep is woken by the first command, and a stopped one is started.

plugin.close() runs when the runner shuts down. If your process can die before that, pass delete_after=3600 (seconds) and boxd deletes the machine on its own after that time, whatever happens to your process.

Tools

Tool Description
execute_command_in_boxd Run a shell command (cwd, timeout supported)
execute_code_in_boxd Run a Python / JavaScript / bash snippet
write_file_to_boxd Write a text file (parents auto-created)
read_file_from_boxd Read a text file
create_boxd_checkpoint Checkpoint the entire machine: disk, memory and processes
list_boxd_checkpoints List checkpoints, newest first
restore_boxd_checkpoint Roll back to a checkpoint (destructive, requires confirm=true)

Commands run as the boxd user (with passwordless sudo) in /home/boxd, and relative paths start there. Every tool returns a dict with success; see Errors for what a failure looks like.

A note on restore

restore_boxd_checkpoint rewinds the whole machine, including memory and running processes, and permanently discards anything newer than the checkpoint. The tool refuses to run unless confirm=true is passed, and its description tells the model to get explicit user confirmation first. create_boxd_checkpoint waits until the checkpoint is ready, so a restore right after it works.

Forks and snapshots

These are Python methods on the plugin rather than agent tools, because each one gives you a new machine, and a set of tools is bound to one machine.

base = BoxdPlugin()
# ...set up the project once...

fork = base.fork()  # live copy: disk, memory and running processes
other_agent = Agent(model="gemini-flash-latest", name="other", tools=fork.get_tools())

base.save_snapshot("project-base")  # reusable starting point
fresh = BoxdPlugin(from_snapshot="project-base")  # new machines start from it

An unnamed fork is deleted when its plugin is closed. See examples/fork_experiments.py for two agents working on two forks in parallel.

Configuration

BoxdPlugin(
    api_key=None,              # default: $BOXD_API_KEY (not needed inside a boxd machine)
    machine_name=None,         # default: auto-generated "adk-…"
    plugin_name="boxd_plugin",
    region=None,               # default: $BOXD_REGION, then the API's own region
    base_url=None,             # default: $BOXD_BASE_URL, then the public boxd API
    from_snapshot=None,        # new machines: start from this snapshot
    image=None,                # new machines: boot this image instead
    vcpu=None,                 # new machines: 1, 2, 4 or 8 vCPUs (4 GB RAM each)
    labels=None,               # new machines: extra labels
    delete_after=None,         # new machines: seconds until boxd deletes it anyway
    destroy_on_close=None,     # default: True if unnamed, False if named
    client_timeout=60.0,       # timeout for boxd API calls
    client=None,               # an existing boxd.Boxd client to share
)

plugin.client is the underlying boxd SDK client and plugin.machine_id the machine's id, for anything the tools don't cover (exposing a port, egress allowlists, pausing).

Errors

A tool never raises into the ADK run. A failure comes back to the model as a result it can read and act on:

What happened What the tool returns
The command exited non-zero {"success": false, "exit_code": 2, "stdout": ..., "stderr": ...}
The command ran past its timeout {"success": false, "timed_out": true, "error": "command did not finish within 300s and was stopped. ..."}
boxd rejected the API key {"success": false, "error": "boxd rejected the credentials (...). Check BOXD_API_KEY."}
A file is missing or can't be read {"success": false, "error": "..."}
A required argument is missing {"success": false, "error": "path is required"}
restore_boxd_checkpoint without confirm=true {"success": false, "error": "Restore not performed: ..."}
A checkpoint failed to save {"success": false, "error": "checkpoint 'adk-...' failed"}

The plugin also logs every failure, and its on_tool_error_callback turns an exception from one of its own tools into the same {"success": false, "error": ...} shape.

Two errors come from your own code rather than from a tool:

  • BoxdPlugin() raises ValueError when there is no API key at all (outside a boxd machine) and when you pass both from_snapshot and image.
  • fork() and save_snapshot() raise the boxd SDK's errors, and save_snapshot raises RuntimeError if the snapshot fails and TimeoutError if it isn't ready in time (600 seconds by default).

Limits

Limit
Command timeout 300 seconds by default; the model can pass a larger timeout per call
Output returned to the model 100,000 characters per stream (stdout, stderr, file content); the rest is cut and marked [truncated]
Files read_file_from_boxd and write_file_to_boxd handle text (UTF-8); there is no size limit on writes
Machines per plugin one; use fork() or a second BoxdPlugin for more
Machine size 1, 2, 4 or 8 vCPUs with 4 GB of memory each, up to your organization's quota
First tool call creates the machine and waits up to 180 seconds for it to accept commands (usually about a second)
New checkpoint the tool waits up to 120 seconds for it to become restorable, then returns it with "status": "pending"
Machine names unique per region; a name that exists in another region is an error, not a second machine

How it works

  • BoxdPlugin holds one boxd client and one machine. Nothing touches the network until the first tool call, which reuses the machine called machine_name if it exists (starting it if it was stopped) or creates it.
  • Commands go through the boxd SDK's machines.exec, and file tools through machines.fs, which writes as the machine's user, creates missing parent directories and replaces files atomically.
  • Tools run in a worker thread, so a long command doesn't block the event loop. A lock makes sure two parallel tool calls don't create two machines.
  • A machine that is asleep wakes on the next command. Checkpoints, forks and snapshots are boxd's own: they capture disk, memory and running processes.
  • When the runner shuts down, ADK calls the plugin's close(), which deletes an unnamed machine and closes the client. A named machine stays.

Examples

All examples read the model from ADK_MODEL (default gemini-flash-latest).

Attribution

Machines created by this plugin carry the label created-by=google-adk, so you can find them (boxd machine list --label created-by=google-adk) and boxd can see how much usage comes from ADK agents. Pass your own created-by label to override it.

Development

pip install -e '.[dev]'
pytest                                                # unit tests, no network
BOXD_ADK_LIVE=1 BOXD_API_KEY=... pytest tests/test_live.py -v   # against real boxd

The live tests create machines named t-adk-… with a 30 minute delete-after timer and delete them at the end. The agent test also needs ANTHROPIC_API_KEY and pip install litellm.

Resources

License

MIT

Metadata

Release files for boxd-adk 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for boxd-adk 0.1.0
File Size Uploaded Provenance Actions
boxd_adk-0.1.0.tar.gz 246.2 kB Without provenance Details for boxd_adk-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for boxd-adk 0.1.0
File Interpreter ABI Platform Actions
boxd_adk-0.1.0-py3-none-any.whl Python 3 none any Details for boxd_adk-0.1.0-py3-none-any.whl

Total release size: 261.8 kB

Release files / boxd_adk-0.1.0.tar.gz

Download URL boxd_adk-0.1.0.tar.gz
Size 246.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a7ebddc5bb7bddd754e851f8467a97e74620e4dd7be9b75b8a418f81d1628489
BLAKE2b-256 checksum
How to use checksums
678cbf02ef8df4bac771137ba7c8fe8aed26d465fd24cd4e2e72d91541d85e7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.9

Release files / boxd_adk-0.1.0-py3-none-any.whl

Download URL boxd_adk-0.1.0-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd9f6c06fe40653a840f86779b020f957ad3b714115b2040431240cf78deff64
BLAKE2b-256 checksum
How to use checksums
4a773bcb596384034263c5a1c29cfad76ca7cea4db677f8867163572434a8f90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.9

Security for boxd-adk 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page