langchain-withruntime
Runtime sandbox integration for Deep Agents.
Runtime runs each sandbox in a Firecracker microVM
with its own kernel. RuntimeSandbox is a Deep Agents sandbox backend. The
agent's execute, ls, read_file, write_file, edit_file, glob and
grep tools all run in one sandbox.
Quick install
pip install langchain-withruntime
This installs the Runtime SDK, withruntime,
and Deep Agents. Set RUNTIME_API_KEY to a key from
https://withruntime.com/account/keys. You can also run npx -y withruntime login
once on this machine. Signing up takes no card. Your first sandbox asks for one, and the trial starts then.
Use it
from deepagents import create_deep_agent
from withruntime import Sandbox
from langchain_withruntime import RuntimeSandbox
with Sandbox.create() as sbx:
agent = create_deep_agent(
model="anthropic:claude-sonnet-4-6",
backend=RuntimeSandbox(sbx),
)
result = agent.invoke(
{"messages": [{"role": "user", "content": "Write fib.py, run it, and show the first 10 numbers."}]}
)
print(result["messages"][-1].content)
Leaving the with block stops the sandbox. The backend also works on its own:
from withruntime import Sandbox
from langchain_withruntime import RuntimeSandbox
with Sandbox.create() as sbx:
backend = RuntimeSandbox(sbx, timeout_seconds=300)
print(backend.execute("python3 --version").output)
backend.write("/workspace/notes.txt", "hello\n")
print(backend.read("/workspace/notes.txt").file_data["content"])
timeout_seconds(default 1800) is the limit for a command that sets no timeout of its own. A command that runs past the limit is stopped, and its output says so.max_output_chars(default 100,000) keeps the end of a longer output. It marks the output as truncated.Sandbox.create()takes the sandbox settings:image,region,vcpu,memory_mib,timeout_seconds(the lease),networkand more. See the Python SDK guide.
Deep Agents Code
The package registers a runtime sandbox provider for Deep Agents Code:
dcode install langchain-withruntime --package
dcode --sandbox runtime
Each session gets a new sandbox. The sandbox stops when the session ends.
--sandbox-id <id> attaches to a sandbox that is already running. It leaves
that sandbox running. RuntimeProvider has the same lifecycle, in code:
from langchain_withruntime import RuntimeProvider
provider = RuntimeProvider()
backend = provider.get_or_create(timeout=900) # a new sandbox with a 15 minute lease
try:
print(backend.execute("uname -r").output)
finally:
provider.delete(sandbox_id=backend.id)
Where it comes from
RuntimeSandbox is maintained in the Runtime SDK as withruntime.deepagents.
pip install "withruntime[deepagents]" gives the same class. This package
installs it under the langchain-<provider> name that the other Deep Agents
sandbox packages use. It also adds the Deep Agents Code provider.
Tests
pip install -e . pytest pytest-asyncio langchain-tests
pytest tests/unit_tests # offline
RUNTIME_API_KEY=... pytest tests/integration_tests # real sandboxes
RUNTIME_API_KEY=... python scripts/e2e.py # a Deep Agent with a scripted model
The offline tests run LangChain's standard SandboxIntegrationTests against a
stand-in sandbox. The stand-in runs on the local machine (Linux).
Documentation
License
Apache-2.0
Metadata
Release files for langchain-withruntime 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langchain_withruntime-0.1.1.tar.gz | 15.4 kB | With provenance | Details for langchain_withruntime-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_withruntime-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for langchain_withruntime-0.1.1-py3-none-any.whl |
Total release size: 25.5 kB
Release files / langchain_withruntime-0.1.1.tar.gz
| Download URL | langchain_withruntime-0.1.1.tar.gz |
|---|---|
| Size | 15.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6f3ffa1dad9e794a4c59d05f65f930fabb60a0f44ddf19192cdb88d583aff981
|
|
BLAKE2b-256 checksum How to use checksums |
3a429be113a02eb2b50899b7ae5c2b485ec50063dd4c2d7aefdbe5e2a896c437
|
| 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 Nov 24, 2026.
Transparency logRelease files / langchain_withruntime-0.1.1-py3-none-any.whl
| Download URL | langchain_withruntime-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a2999939eae180a4893d974b2ed78efa5395bfc81b22da947f388f9e1d93dd2f
|
|
BLAKE2b-256 checksum How to use checksums |
bf2ee4243e3db2e5b9bb621c976d8b71779a0b93267941194601e1c2b4f9cf14
|
| 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 Nov 24, 2026.
Transparency logSecurity for langchain-withruntime 0.1.1
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
Both files in this release have been uploaded with provenance metadata.
Attestation for langchain_withruntime-0.1.1.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 Nov 24, 2026.
Transparency logA 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.