Pydantic AI Backend
File storage, sandbox backends, and console toolset
Multiple backend options (in-memory, local filesystem, Docker sandbox) with a console toolset (ls, read, write, edit, grep, execute) and fine-grained permission system.
Installation
pip install pydantic-ai-backendChoose from three backend options depending on your needs: StateBackend (in-memory, ephemeral — perfect for tests), LocalBackend (real filesystem with a sandboxed root directory), or DockerSandbox (full Docker container isolation with pre-configured runtimes for Python, Node.js, and data science). The console toolset provides 7 tools (ls, read_file, write_file, edit_file, glob, grep, execute) with a permission system offering 4 presets: DEFAULT, PERMISSIVE, READONLY, and STRICT.
Features
Quick Start
from dataclasses import dataclassfrom pydantic_ai import Agentfrom pydantic_ai_backends import LocalBackend, create_console_toolset
@dataclassclass Deps: backend: LocalBackend
agent = Agent( "openai:gpt-4o", deps_type=Deps, toolsets=[create_console_toolset()],)
backend = LocalBackend(root_dir="./workspace")result = agent.run_sync( "Create a Python script that calculates fibonacci and run it", deps=Deps(backend=backend),)Use Cases
AI Coding Assistants
Give agents full file read/write/execute capabilities with sandboxed access to your project workspace.
Sandboxed Code Execution
Run untrusted agent-generated code safely inside Docker containers with pre-configured Python and Node.js runtimes.
File Management Agents
Build agents that organize, search, and transform files using grep, glob, and edit tools with permission guardrails.
Testing & CI Pipelines
Use ephemeral in-memory backends for fast, isolated test runs that leave no artifacts behind.
Ready to build your first production AI agent?
Open-source tools, battle-tested patterns, zero boilerplate. Configure your stack and ship in minutes — not months.