langchain-lightning
Lightning AI sandbox integration for Deep Agents.
Quick Install
pip install langchain-lightning
Deep Agents SDK
from lightning_sdk.sandbox import Sandbox
from langchain_lightning import LightningSandbox, ensure_workdir
# python313 ships python3, which Deep Agents file tools require.
sandbox = Sandbox.create(
instance_type="cpu-1",
runtime="python313",
persistent=True, # optional: stop/resume by id across runs
)
ensure_workdir(sandbox, "/root")
backend = LightningSandbox(sandbox=sandbox)
try:
result = backend.execute("python3 --version && echo hello")
print(result.output)
finally:
sandbox.delete()
Reconnect to a durable sandbox (auto-resumes when paused):
from lightning_sdk.sandbox import Sandbox
from langchain_lightning import LightningSandbox, ensure_workdir, resume_if_needed
sandbox = resume_if_needed(Sandbox().get("sbx_..."))
ensure_workdir(sandbox, "/root")
backend = LightningSandbox(sandbox=sandbox)
The backend also works with async Deep Agents via the inherited aexecute,
aupload_files, adownload_files, and related methods (the Lightning SDK is
synchronous, so these run on a worker thread).
Deep Agents Code
Install langchain-lightning into the dcode environment, then run with the
Lightning sandbox provider:
dcode --install langchain-lightning --package
export LIGHTNING_API_KEY=...
dcode --sandbox lightning
The provider defaults:
| Setting | Default |
|---|---|
| runtime | python313 (has python3) |
| instance type | cpu-1 |
| sandbox lifetime | 30 minutes |
| workdir | /root |
| persistent | false |
Optional env vars: LIGHTNING_SANDBOX_RUNTIME, LIGHTNING_SANDBOX_IMAGE,
LIGHTNING_SANDBOX_INSTANCE_TYPE, LIGHTNING_SANDBOX_TIMEOUT (seconds),
LIGHTNING_SANDBOX_PERSISTENT, LIGHTNING_SANDBOX_NETWORK_POLICY,
LIGHTNING_CLOUD_URL.
When reconnecting by sandbox id, the provider resumes paused/stopped persistent sandboxes and ensures the workdir exists.
What is this?
langchain-lightning adapts an existing Lightning AI sandbox to the Deep Agents
sandbox protocol. It implements the execute, upload_files, and
download_files primitives over the lightning_sdk.sandbox SDK; Deep Agents
derives the rest of the filesystem operations (ls, read, write, edit,
grep, glob) from those.
Commands run detached and are awaited so per-command timeouts are honored. File transfer is bridged through base64 so arbitrary binary content round-trips losslessly despite Lightning's text-based file API.
For SDK use, this package intentionally does not hide Lightning sandbox
lifecycle management. Use the Lightning SDK to create, connect to, configure,
and delete sandboxes, then pass the sandbox object to LightningSandbox.
For Deep Agents Code, the package also exposes a dcode sandbox provider entry
point. The provider creates, reconnects to, and deletes Lightning sandboxes for
dcode --sandbox lightning.
Contributing
Contributions are welcome. Keep the adapter focused on implementing the Deep Agents sandbox backend protocol over the official Lightning SDK.
Development
uv sync --group test
make test
make lint
Integration tests require LIGHTNING_API_KEY and hit the real Lightning API
(create / shell / files / pause-resume):
export LIGHTNING_API_KEY=...
make integration_tests
CI runs unit tests on every PR and live integration tests when the
LIGHTNING_API_KEY repository secret is available (same-repo PRs, pushes to
main, nightly schedule, and manual workflow_dispatch).
Metadata
Release files for langchain-lightning 1.0.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_lightning-1.0.1.tar.gz | 246.7 kB | With provenance | Details for langchain_lightning-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_lightning-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for langchain_lightning-1.0.1-py3-none-any.whl |
Total release size: 261.1 kB
Release files / langchain_lightning-1.0.1.tar.gz
| Download URL | langchain_lightning-1.0.1.tar.gz |
|---|---|
| Size | 246.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b637418139e31450a8f3a723df905a140de818a1d1685b377230ec66ffd07eb2
|
|
BLAKE2b-256 checksum How to use checksums |
5092a0511bdaec90d19b93db71d240d0b869029efa4ae4371bd983a35bd35582
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 10, 2026.
Transparency logRelease files / langchain_lightning-1.0.1-py3-none-any.whl
| Download URL | langchain_lightning-1.0.1-py3-none-any.whl |
|---|---|
| Size | 14.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
20c6493ca4e486a13bb609b5abf4a6f14c6535182e7742450a3b86b175c7e75d
|
|
BLAKE2b-256 checksum How to use checksums |
70b82cf7a99b188fe3e0bc68503125d0072c6c8d5768e84a3917622a62039283
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 Jul 10, 2026.
Transparency logSecurity for langchain-lightning 1.0.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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for langchain_lightning-1.0.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 Jul 10, 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.