Skip to main content

pydantic-ai-withruntime

Runtime sandboxes as a Pydantic AI toolset. Each agent run gets its own Runtime sandbox, a Firecracker microVM with its own Linux kernel. The sandbox is created when the run starts and stopped when it ends.

pip install pydantic-ai pydantic-ai-withruntime   # pydantic-ai brings the model providers
npx withruntime login   # or set RUNTIME_API_KEY
from pydantic_ai import Agent
from pydantic_ai_withruntime import RuntimeToolset

agent = Agent("anthropic:claude-sonnet-4-6", toolsets=[RuntimeToolset()])
print(agent.run_sync("Fit a line to (1,2), (2,4.1), (3,6.2) with numpy and give the slope.").output)

The model sees four tools:

Tool What it does
runtime_exec Runs a command under bash -c and returns its output
runtime_read_file Reads a text file
runtime_write_file Creates or replaces a text file
runtime_list_files Lists a directory with each entry's type and size

Relative paths are under /workspace. Output past 20,000 characters is cut from the front, keeping the end, where errors are.

Options

  • RuntimeToolset(create={...}) sets each run's sandbox: vcpu, memory_mib, image, network, labels and the rest of sandboxes.create. Unless you set a timeout_seconds, each sandbox gets a 30-minute lease that ends in a stop, so a crashed process leaves nothing running.
  • RuntimeToolset(sandbox) uses an AsyncSandbox you created. Every run shares it, and it is never stopped for you. Use this to keep files between runs, for example with AsyncRuntime().sandboxes.get_or_create("user-42").
  • timeout_seconds, max_output_chars and root tune the tools. instructions=None leaves the agent's instructions unchanged.

Tests

tests/ runs the toolset under Pydantic AI's own agent loop, with a scripted FunctionModel and a fake client; uv run --resolution lowest-direct --group test pytest runs them at the lowest versions pyproject.toml allows. scripts/e2e.py runs the agent loop against the real API with RUNTIME_API_KEY set. It passed on 25 September 2026 with Pydantic AI 2.50.0: two runs, each in its own sandbox, both stopped.

Metadata

Release files for pydantic-ai-withruntime 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydantic-ai-withruntime 0.1.0
File Size Uploaded Provenance
pydantic_ai_withruntime-0.1.0.tar.gz 10.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pydantic-ai-withruntime 0.1.0
File Interpreter ABI Platform
pydantic_ai_withruntime-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.2 kB

Release files / pydantic_ai_withruntime-0.1.0.tar.gz

Download URL pydantic_ai_withruntime-0.1.0.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0ad5a334e9840e1c979de98ca498af528fe4e7a71e968da9b52cacce8c37d018
BLAKE2b-256 checksum
How to use checksums
182f352d7cc83336b3414680de35887d1721743bfae622b6730a14d0d135f725
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / pydantic_ai_withruntime-0.1.0-py3-none-any.whl

Download URL pydantic_ai_withruntime-0.1.0-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c90790a4ae6c66c14b8d281b85ee60e61d7a3974e5fa2d0d1e24f45a55662e38
BLAKE2b-256 checksum
How to use checksums
d99cb6256ccaccc7fea9c5548c368adccbda85333d8be72cd03c7e9bd018527e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

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 Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for pydantic-ai-withruntime 0.1.0

Provenance

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pydantic_ai_withruntime-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

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

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page