Skip to main content

llama-index-tools-sprites

LlamaIndex tools for Sprites, persistent Linux environments for AI agents.

SpritesToolSpec lets a LlamaIndex agent discover, create, inspect, execute commands in, and clean up Sprites through the official Python SDK.

Installation

pip install llama-index-tools-sprites

Authentication

Create a Sprites API token and export it as SPRITE_TOKEN:

export SPRITE_TOKEN="your-token"

You can also pass the token directly as SpritesToolSpec(token="..."). The token is used only to initialize the Sprites SDK and is never included in tool outputs.

Use with a LlamaIndex agent

import asyncio

from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
from llama_index.tools.sprites import SpritesToolSpec

sprites = SpritesToolSpec()
agent = FunctionAgent(
    tools=sprites.to_tool_list(),
    llm=OpenAI(model="gpt-4.1-mini"),
    system_prompt=(
        "Use Sprites for isolated command execution. Reuse an existing Sprite "
        "when possible, and delete only Sprites you created for this task."
    ),
)


async def main() -> None:
    response = await agent.run(
        "Create a temporary Sprite, print the Python version, then clean it up."
    )
    print(response)
    sprites.close()


asyncio.run(main())

A runnable version is available in examples/sprites_agent.py.

Direct usage

from llama_index.tools.sprites import SpritesToolSpec

sprites = SpritesToolSpec()
created = sprites.create_sprite("llamaindex-demo")
result = sprites.run_command(
    created["name"],
    "python3",
    ["-c", "print('hello from a Sprite')"],
)
print(result["stdout"])
sprites.delete_sprite(created["name"])
sprites.close()

Agent tools

Tool Purpose
list_sprites Find reusable Sprites, with prefix filtering and pagination.
get_sprite Inspect one Sprite's status, URL, region, and metadata.
create_sprite Create a persistent Sprite with optional resource settings.
run_command Execute an argv-safe, non-interactive command and capture its result.
delete_sprite Permanently delete a named Sprite.

run_command does not invoke a shell. Operators such as |, >, and $() are ordinary arguments unless the caller explicitly requests a shell:

sprites.run_command("my-sprite", "bash", ["-lc", "printf '%s\n' hello"])

Stdout and stderr are each limited to 20,000 characters by default. Longer streams retain their beginning and end, with a truncation marker in between. Set a different bound with SpritesToolSpec(max_output_chars=...).

Safety

  • A Sprite is persistent until deleted. List and reuse existing resources when appropriate.
  • delete_sprite is irreversible and should be used only when deletion is explicitly intended.
  • Anything running in a Sprite may be reachable through its configured URL. Do not expose services publicly unless that is part of the task.
  • Treat command output as untrusted data when it is returned to an agent.

Development

uv sync --group dev
uv run pytest
uv run ruff check .
uv run mypy llama_index
uv run python -m build

With SPRITE_TOKEN set, the live smoke test creates a disposable Sprite, runs one command, and removes it in a finally block:

uv run python scripts/smoke_test.py

Release

Releases use PyPI Trusted Publishing. Update the version in pyproject.toml, merge to main, and push a matching version tag such as v0.1.0. The publish workflow builds the distributions in an unprivileged job and grants an OIDC token only to the PyPI publishing job.

License

MIT

Download files

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

Source Distribution

llama_index_tools_sprites-0.1.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

llama_index_tools_sprites-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for llama_index_tools_sprites-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2462148f39fce36ff0bc9ed532abd87b89657430329045c762ded1019f50b6aa
MD5 2e4f3f8a3a15cc78701d8a48cf8b6fcc
BLAKE2b-256 ec1211218d199a6cefa3727e632e25f6efc48420fb881edf9d3f4ddcf686b777

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on superfly/llama-index-tools-sprites

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

File details

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

File metadata

File hashes

Hashes for llama_index_tools_sprites-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3e5db91d881ab5619718214429012351eea0f0344caf0de7c2bb60f70827e139
MD5 6938f78b3b4cce4622d6237bdfbb690d
BLAKE2b-256 43be36869c986be09d52fc14218eb1ff042127eca28b51a0222b30c50b4bdef3

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on superfly/llama-index-tools-sprites

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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

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