Skip to main content

Google ADK plugin for Sprites: persistent, stateful Linux sandboxes with checkpoint/restore for AI agents.

Project description

sprites-adk

Google ADK integration for Sprites — persistent, stateful Linux sandboxes for AI agents, with checkpoint/restore, from Fly.io.

Most agent sandboxes are ephemeral: the environment vanishes when the session ends. A Sprite is a stateful Linux microVM that suspends when idle and keeps everything — files, packages, databases, running services — so your agent can resume yesterday's environment today. And because Sprites support checkpoints, your agent can snapshot the whole environment before a risky change and roll back if it goes wrong.

Installation

pip install sprites-adk

You'll need a Sprites API token (get started):

export SPRITES_TOKEN=...

Quickstart

from google.adk.agents import Agent
from sprites_adk import SpritesPlugin

plugin = SpritesPlugin()  # or SpritesPlugin(sprite_name="my-project") for a persistent env

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

Pass the plugin to your runner to get lifecycle callbacks and error handling:

runner = InMemoryRunner(agent=root_agent, plugins=[plugin])

Two modes

SpritesPlugin() SpritesPlugin(sprite_name="my-project")
Sprite name auto-generated adk-… yours
Reused across sessions no yes — full state persists
Destroyed on plugin.close() yes no

The Sprite is created lazily on first tool use; constructing the agent needs no network. Sprites suspend automatically when idle — a parked environment costs (almost) nothing.

Tools

Tool Description
execute_command_in_sprite Run a shell command (cwd, timeout supported)
execute_code_in_sprite Run a Python / JavaScript / bash snippet
write_file_to_sprite Write a text file (parents auto-created)
read_file_from_sprite Read a text file
create_sprite_checkpoint Snapshot the entire environment
list_sprite_checkpoints List checkpoints, newest first
restore_sprite_checkpoint Roll back to a checkpoint (destructive, requires confirm=true)

All tools return structured dicts (success, stdout/stderr/exit_code, …); failures come back as {"success": false, "error": ...} so the agent can adapt instead of crashing the run.

File reads and writes run as commands inside the Sprite (via base64, so quotes/newlines/unicode survive) rather than through a separate filesystem API. That keeps them consistent with everything else the agent does — in particular, files written this way are correctly reverted by restore_sprite_checkpoint. write_file_to_sprite is capped at 256 KB; generate larger files with a command inside the Sprite. /tmp is tmpfs and is not captured by checkpoints.

A note on restore

restore_sprite_checkpoint rewinds the whole environment and permanently discards anything newer than the checkpoint. The tool refuses to run unless confirm=true is passed, and its description instructs the model to get explicit user confirmation first.

Configuration

SpritesPlugin(
    token=None,                # default: $SPRITES_TOKEN
    sprite_name=None,          # default: auto-generated "adk-…"
    plugin_name="sprites_plugin",
    base_url="https://api.sprites.dev",
    destroy_on_close=None,     # default: True if unnamed, False if named
    client_timeout=600.0,      # HTTP timeout for Sprites API calls
)

Examples

Development

python -m venv .venv && .venv/bin/pip install -e '.[dev]'
.venv/bin/pytest

Releasing

Publishing to PyPI is automated via .github/workflows/publish.yml. Push a vX.Y.Z tag and the workflow stamps that version into pyproject.toml and sprites_adk/__init__.py, runs the tests, builds, and publishes via PyPI trusted publishing (OIDC — no API tokens):

git tag v0.1.0
git push origin v0.1.0

This requires a one-time PyPI trusted publisher configured for the sprites-adk project pointing at superfly/sprites-adk and workflow publish.yml.

Resources

License

MIT

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

sprites_adk-0.1.0.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

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

sprites_adk-0.1.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sprites_adk-0.1.0.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sprites_adk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b5aa107f534cf04d16ef3fc77ca08c6605de536661e353a63c99b0bbc69306fa
MD5 c3eaa100fe413df9c62af2a5a9a32cf4
BLAKE2b-256 2a00bd64f9654c67056fa600027e269189def10e125936f28fa57c7bc11e6cb5

See more details on using hashes here.

Provenance

The following attestation bundles were made for sprites_adk-0.1.0.tar.gz:

Publisher: publish.yml on superfly/sprites-adk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: sprites_adk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sprites_adk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6beaaed036e53c864469cc6e91694616365243f7fe529eed87c56b537fa3748c
MD5 2c6ef4263767a5649205476cf22a8fca
BLAKE2b-256 e00cb59c4dd2102656abd87da5d468b49583c23200dabbc5d8ccd9e5fd6bf965

See more details on using hashes here.

Provenance

The following attestation bundles were made for sprites_adk-0.1.0-py3-none-any.whl:

Publisher: publish.yml on superfly/sprites-adk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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