Skip to content

leap0-dev/langchain-leap0-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

langchain-leap0-python

Leap0 integration for LangChain Deep Agents: a BaseSandbox backend that runs shell commands and file transfers inside a Leap0 sandbox.

Leap0 is enterprise-grade cloud sandboxes for AI agents. Launch isolated sandboxes in ~200ms. Give every agent its own compute, filesystem, and network boundary while your agents run safely.

Quick install

pip install langchain-leap0

Set your API key (see Leap0 for account and key management):

export LEAP0_API_KEY="your-key"

Minimal usage with the [leap0](https://pypi.org/project/leap0/) SDK and Leap0Sandbox:

from leap0 import Leap0Client

from langchain_leap0 import Leap0Sandbox

client = Leap0Client()
sandbox = client.sandboxes.create()
backend = Leap0Sandbox(client=client, sandbox=sandbox)

try:
    result = backend.execute("echo 'Hello LangChain from Leap0.dev'")
    print(result.output)
finally:
    client.sandboxes.delete(sandbox)
    client.close()

Examples

Runnable scripts for Deep Agents sandboxes. Environment variables and run commands are documented in each example’s module docstring. LangChain sandbox integration tests: make integration_test.

Script Summary
examples/basic_sandbox.py Minimal: create a sandbox, Leap0Sandbox.execute(), teardown. Requires LEAP0_API_KEY.
examples/deep_agent_sandbox.py create_deep_agent(..., backend=Leap0Sandbox(...)) — agent task to create and run a Python script; prints the agent invocation result. Requires LEAP0_API_KEY, OPENAI_API_KEY; optional OPENAI_MODEL (default openai:gpt-4o).

From the repo root:

uv run python examples/basic_sandbox.py
uv run python examples/deep_agent_sandbox.py

Developing from source

From this directory (alongside leap0-python in the Leap0 workspace). Uses pyproject.toml dependencies; run:

cd langchain-leap0
uv sync --all-groups

Running tests

From the package root:

# Unit tests
make test

# LangChain standard sandbox integration tests
make integration_test

Integration tests require:

export LEAP0_API_KEY="your-key"

Documentation

Full documentation is available at leap0.dev/docs.

License

Apache License 2.0. See LICENSE for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors