Skip to main content

Docker sandbox tools for Axio

Project description

axio-tools-docker

PyPI Python License: MIT

Docker sandbox tools for axio.

Run agent-generated code and commands inside isolated Docker containers. The agent gets sandbox_exec, sandbox_write, and sandbox_read tools that operate entirely within the sandbox — the host filesystem stays untouched.

Features

  • Isolated execution — code runs inside a Docker container, not on the host
  • Configurable image — use any Docker image as the sandbox environment
  • Three sandboxed tools — execute commands, write files, read files — all inside the container
  • Persistent sandbox — container is reused across tool calls within a session for faster execution
  • TUI integration — configure image, memory limits, and CPU from the axio-tui settings screen

Requirements

Docker must be installed and running:

docker info   # should succeed

Installation

pip install axio-tools-docker

Usage

from axio.agent import Agent
from axio.context import MemoryContextStore
from axio_transport_openai import OpenAITransport
from axio_tools_docker.plugin import DockerPlugin

async def main() -> None:
    plugin = DockerPlugin()
    await plugin.init()   # uses default config (python:3.12-slim)

    agent = Agent(
        system=(
            "You are a coding assistant. Use sandbox_exec to run code safely. "
            "Never attempt to access the host filesystem directly."
        ),
        tools=plugin.all_tools,
        transport=OpenAITransport(api_key="sk-...", model="gpt-4o"),
    )

    ctx = MemoryContextStore()
    result = await agent.run(
        "Write a Python script that computes the first 20 Fibonacci numbers and run it.",
        ctx,
    )
    print(result)

Sandbox tools

Tool Description
sandbox_exec Run a shell command inside the container; returns stdout + stderr
sandbox_write Write a file into the container's filesystem
sandbox_read Read a file from the container's filesystem

Container lifecycle

The sandbox container is created lazily on the first tool call (sandbox_exec, sandbox_write, or sandbox_read) — plugin.init() itself does not start Docker. The same container is reused for all subsequent tool calls within the session.

When await plugin.close() is called the container is stopped and removed (docker rm -f). You should always call close() when the agent session ends to avoid leaving containers behind:

async def run_with_cleanup(agent, ctx, plugin):
    try:
        result = await agent.run("...", ctx)
    finally:
        await plugin.close()

If Docker is not installed or the docker CLI is not on PATH, the container creation step will raise a RuntimeError on the first tool call. You can detect this before starting a session with SandboxManager.docker_available() (returns True if the docker executable is found on PATH).

Configuration

Field Type Default Description
image str "python:latest" Docker image to use for the sandbox container
memory str "256m" Memory limit passed to docker run --memory (e.g., "512m", "1g")
cpus str "1.0" CPU limit passed to docker run --cpus
network bool False Whether to allow network access. When False, --network none is set on the container.
workdir str "/workspace" Working directory inside the container
from axio_tools_docker.config import SandboxConfig

config = SandboxConfig(
    image="python:3.12-slim",
    memory="512m",
    cpus="1.0",
    workdir="/workspace",
)

Plugin registration

[project.entry-points."axio.tools.settings"]
docker = "axio_tools_docker.plugin:DockerPlugin"

Part of the axio ecosystem

axio · axio-tools-local · axio-tools-mcp · axio-tui

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

axio_tools_docker-0.7.0.tar.gz (41.1 kB view details)

Uploaded Source

Built Distribution

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

axio_tools_docker-0.7.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file axio_tools_docker-0.7.0.tar.gz.

File metadata

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

File hashes

Hashes for axio_tools_docker-0.7.0.tar.gz
Algorithm Hash digest
SHA256 c4bf2ac471452e3a6cbec5dad2b9276218ca9630d5b6b8115d9f8e67a4743008
MD5 5853e05283e4067316898266cd1e301c
BLAKE2b-256 3d18bca9963aeb3d513f419919c79f1c0f81d7dbbf83cfb662eede8831e45622

See more details on using hashes here.

Provenance

The following attestation bundles were made for axio_tools_docker-0.7.0.tar.gz:

Publisher: publish.yml on mosquito/axio-agent

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

File details

Details for the file axio_tools_docker-0.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for axio_tools_docker-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4da6cb0fe2d8629b84c514101327c350b699bdbde6eed50c5f7833cdeacc50c3
MD5 b197b957aefd5f325792569497cb11dd
BLAKE2b-256 3c552cf430cc3b5c61f8adc436e8df3ac166e140ebc0f802e6f86b20c55145ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for axio_tools_docker-0.7.0-py3-none-any.whl:

Publisher: publish.yml on mosquito/axio-agent

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