Skip to main content Switch to mobile version pydantic-ai-backend 0.2.42 File storage and sandbox backends for AI agents
pip install pydantic-ai-backend==0.2.42 Copy PIP instructions
From the team behind this repo: AgenticOS, the Sovereign Agentic AI Layer. AI agents your whole team can use and improve: open source (Apache-2.0), self-hosted, built on Pydantic AI.
Workspaces & console tools for Pydantic AI agents. Docker / sandboxd / Kubernetes / Daytona / State workspaces and a console toolset that works in any of them, plus a sandbox service so your app never needs Docker access.
Docs · PyPI · Install · Ecosystem · Deep Agents
Pydantic AI workspaces • Docker / sandboxd / Kubernetes / Daytona / State • Console toolset • Permission system • No docker-in-docker
Part of Pydantic Deep Agents — the open-source Claude Code alternative & Python agent framework. Use this library standalone, or get everything wired together in one create_deep_agent() call.
Pydantic AI Backend gives your Pydantic AI agent somewhere to work and the tools to work there. It supplies Pydantic AI workspaces — a Docker container, a sandboxd session, a Kubernetes pod, a Daytona sandbox, a JSON document — and a console toolset that reads, writes, searches and runs code in whichever workspace the run has, under a fine-grained permission system.
pip install pydantic-ai-backend Or with uv:
uv add pydantic-ai-backend Optional extras:
# Console tools (Pydantic AI 2.52+) pip install "pydantic-ai-backend[console]" # Workspaces (Pydantic AI 2.52+); add the provider's own extra pip install "pydantic-ai-backend[workspaces,docker]" # DockerWorkspace pip install "pydantic-ai-backend[workspaces,kubernetes]" # KubernetesWorkspace pip install "pydantic-ai-backend[workspaces,daytona]" # DaytonaWorkspace pip install "pydantic-ai-backend[workspaces]" # SandboxdWorkspace, StateWorkspace # The sandbox service itself (install in the service image, not your app) pip install "pydantic-ai-backend[server]" # Reading what sandboxd sessions left behind pip install "pydantic-ai-backend[remote]" Quick Start
A workspace capability supplies the environment; ConsoleCapability gives the model tools that work in it:
from pydantic_ai import Agent from pydantic_ai_backends import ConsoleCapability, DockerWorkspace agent = Agent( "anthropic:claude-opus-5-5", capabilities=[DockerWorkspace(runtime="python-datascience"), ConsoleCapability()], ) first = agent.run_sync("Create a script that calculates fibonacci and run it") # Same container: the workspace ref travels on the message history. second = agent.run_sync("Now add tests for it", message_history=first.all_messages()) That's it. Your agent can now:
List files and directories (ls)
Read and write files (read_file, write_file)
Edit files with string replacement (edit_file)
Search with glob patterns and regex (glob, grep)
Execute shell commands (execute)
The container is created on first use and kept after the run. Remove it when you are done with it: await workspace.destroy(ref).
from pydantic_ai_backends import ConsoleCapability from pydantic_ai_backends.permissions import READONLY_RULESET # Read-only agent — write/edit/execute tools are hidden from the model console = ConsoleCapability(permissions=READONLY_RULESET) On your own machine
Pydantic AI's own LocalWorkspace covers a directory on the host. It runs commands as you, so use it on your own code:
Pydantic AI ships LocalWorkspace, and its harness covers E2B, Modal and Sprites; ConsoleCapability works in all of them. Every workspace here is created on first use, attached again by its ref, and never deleted for you. DockerWorkspace and SandboxdWorkspace pass Pydantic AI's own conformance suite against a real Docker daemon, and StateWorkspace passes it in CI.
from pydantic_ai_backends import StateBackend, StateWorkspace store = {"conv-42": StateBackend(files=row.files, directories=row.directories)} workspace = StateWorkspace(store=store) A StateBackend is a filesystem kept as a JSON document — files, and the directories created — so a host can keep a workspace in a database row and hand it back on the next turn. Binary content is held base64, so the document stays JSON even after an agent writes an image into it.
sandboxd: no docker.sock in your app
If your application runs in a container, giving it a Docker sandbox the obvious way means mounting /var/run/docker.sock — which is an unauthenticated API for root on the host. Docker-in-Docker needs --privileged and lands in the same place. So instead, one small service owns the socket and your app speaks HTTP to it:
The service is published as an image, and the client chooses nothing about the container:
services: app: environment: { SANDBOXD_URL: http://sandboxd:8080 } networks: [backend] # no docker.sock here sandboxd: image: ghcr.io/vstorm-co/sandboxd:latest environment: SANDBOXD_TOKEN: ${SANDBOXD_TOKEN:?} SANDBOXD_HOST: 0.0.0.0 SANDBOXD_WORKSPACE_ROOT: /workspaces # files survive idle reaping SANDBOXD_MAX_SESSIONS_PER_TENANT: "5" # one tenant cannot take the pool volumes: ["/var/run/docker.sock:/var/run/docker.sock"] group_add: ["${DOCKER_GID}"] # it runs unprivileged; this reaches the socket networks: [backend] # and no `ports:` either Every field of SandboxdConfig is SANDBOXD_ plus its name in upper case — runtimes, ceilings, retention, the lot — so the whole policy is a compose file and there is no launcher to write. A value that will not parse, or a combination the service refuses, fails at startup naming the variable.
To embed it in something larger, create_app still takes the config directly:
from pydantic_ai_backends.remote.server import SandboxdConfig, create_app app = create_app( SandboxdConfig( token="a-long-random-secret", runtimes={"python": "python:3.12-slim"}, # allowlist; a request sends an alias mem_limit="1g", cpus=2.0, network_mode="none", # sandboxes get no network by default max_sessions=20, # beyond this: 429, not unbounded containers workspace_root="/workspaces", # files survive idle reaping ) ) Three settings decide what survives an idle timeout, and they cover different things: workspace_root keeps the work directory, persist_containers keeps the container's write layer so pip install survives too, and workspace_ttl reclaims workspaces nobody opens any more. await sandbox.destroy(ref) drops a session's files for good when its conversation is deleted.
Users can see what the agent wrote — including in a conversation from last week, long after its sandbox was reaped. WorkspaceArchive reads the stored workspace off the host volume, so no container starts:
from pydantic_ai_backends import WorkspaceArchive archive = WorkspaceArchive("http://sandboxd:8080", token="...") for entry in archive.ls(ref.id): print(entry["path"], entry["size"]) print(archive.read(ref.id, "report.md")) Proxy it from your backend rather than handing a token to the browser — the service token can start containers.
SandboxdConfig(ui_enabled=True) serves a dashboard at /ui — one self-contained HTML file, no build step and no CDN, so it works offline and behind a strict CSP. Three views:
Sessions — capacity at a glance, and every open session with its tenant, idle time and memory against its own ceiling.
Workspace — one session at full width: a terminal with command history, the stored workspace's files, the activity log and session info.
Runtimes & policy — the allowlist with each runtime's image, ceilings and whether it gets a network, the config that produces it, and every limit in force.
Off by default: the page asks a human for the service token, and that token can start containers on the host.
ConsoleCapability takes the toolset's options:
Available tools: ls, read_file, write_file, edit_file, glob, grep, execute
Fine-grained access control, enforced by the tools on every call:
Pre-configured environments for DockerWorkspace(runtime=...):
A runtime naming an image starts as fast as a pull. One naming a base_image plus packages builds an image on first use and hits the cache afterwards, which is worth it when installing them per session would dominate.
from pydantic_ai_backends import DockerWorkspace, RuntimeConfig runtime = RuntimeConfig( name="ml-env", base_image="python:3.12-slim", packages=["torch", "transformers"], ) workspace = DockerWorkspace(runtime=runtime) Why Choose This Library?
This library is one piece of a broader open-source toolkit for production AI agents — all built on Pydantic AI.
Want it all wired together? Pydantic Deep Agents ships every library above integrated — planning, filesystem, subagents, memory, context management, and guardrails — behind a single function call. Browse all our open-source projects at github.com/vstorm-co.
git clone https://github.com/vstorm-co/pydantic-ai-backend.git cd pydantic-ai-backend make install make test # 100% coverage required Star History
If this library saved you from wiring an agent harness by hand — give it a ⭐. It's the single biggest thing that helps the project grow.
Need help shipping AI agents in production?
We're Vstorm — an Applied Agentic AI Engineering Consultancywith 30+ production agent implementations. Pydantic Deep Agents is what we build them with.
Both files in this release have provenance metadata.
MIT View SPDX License List
console daytona dev docker images kubernetes remote server workspaces
Development Status 4 - Beta
Intended Audience Developers
License OSI Approved :: MIT License
Operating System OS Independent
Programming Language Python
Topic Software Development :: Libraries :: Python Modules
Release files for pydantic-ai-backend 0.2.42
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 3.1 MB
Release files / pydantic_ai_backend-0.2.42.tar.gz
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.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Security for pydantic-ai-backend 0.2.42
Both files in this release have been uploaded with provenance metadata.
With provenance pydantic_ai_backend-0.2.42.tar.gz Nov 27, 2026
Attestation for pydantic_ai_backend-0.2.42.tar.gz
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
Nov 27, 2026 2 release files Full provenance
Nov 26, 2026 2 release files Full provenance
Oct 30, 2026 2 release files Full provenance
Oct 27, 2026 2 release files Full provenance
Oct 19, 2026 2 release files Full provenance
Oct 5, 2026 2 release files Full provenance
Aug 22, 2026 2 release files Full provenance
Aug 20, 2026 2 release files Full provenance
Aug 16, 2026 2 release files Full provenance
Aug 4, 2026 2 release files Full provenance
Aug 2, 2026 2 release files Full provenance
Aug 1, 2026 2 release files Full provenance
Jul 31, 2026 2 release files Full provenance
Jul 17, 2026 2 release files Full provenance
Jun 27, 2026 2 release files Full provenance
Jun 22, 2026 2 release files Full provenance
Jun 17, 2026 2 release files Full provenance
Jun 12, 2026 2 release files Full provenance
Jun 7, 2026 2 release files Full provenance
Jun 1, 2026 2 release files Full provenance
May 24, 2026 2 release files Full provenance
May 14, 2026 2 release files Full provenance
May 5, 2026 2 release files Full provenance
Apr 20, 2026 2 release files Full provenance
Apr 11, 2026 2 release files Full provenance
Apr 6, 2026 2 release files Full provenance
Mar 31, 2026 2 release files Full provenance
Mar 28, 2026 2 release files Full provenance
Mar 12, 2026 2 release files Full provenance
Feb 26, 2026 2 release files Full provenance
Feb 25, 2026 2 release files Full provenance
Feb 24, 2026 2 release files Full provenance
Feb 20, 2026 2 release files Full provenance
Feb 19, 2026 2 release files Full provenance
Feb 15, 2026 2 release files Full provenance
Feb 7, 2026 2 release files Full provenance
Jan 28, 2026 2 release files Full provenance
Jan 22, 2026 2 release files Full provenance
Jan 21, 2026 2 release files Full provenance
Jan 20, 2026 2 release files Full provenance
Jan 16, 2026 2 release files Full provenance
Dec 28, 2025 2 release files Full provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation




