Skip to main content

Upstash Box sandbox integration for Deep Agents

Project description

langchain-upstash-box

Upstash Box sandbox integration for Deep Agents.

An Upstash Box is a secure, isolated cloud container with a full Linux shell, filesystem, git, and a runtime. This package wraps a box as a Deep Agents SandboxBackendProtocol, so agents can run shell commands and read/write files inside it.

Quick install

uv add langchain-upstash-box
# or: pip install langchain-upstash-box

Usage

Set your Box API key (create one in the Upstash Console):

export UPSTASH_BOX_API_KEY="box_xxxxxxxxxxxx"

Provision a box and use it as a sandbox backend:

from langchain_upstash_box import BoxSandbox

# Creates a box and waits until it is ready.
sandbox = BoxSandbox.create(runtime="python")

result = sandbox.execute("echo hello")
print(result.output)      # "hello"
print(result.exit_code)   # 0

# Filesystem helpers (ls / read / write / edit / glob / grep) are provided by
# BaseSandbox on top of execute() + upload/download.
sandbox.write("/workspace/home/hello.py", "print('hi from box')")
print(sandbox.read("/workspace/home/hello.py").content)

sandbox.delete()

Wrap an existing box instead of creating one:

from langchain_upstash_box import BoxSandbox

sandbox = BoxSandbox(box_id="current-wasp-05510")

Use with a Deep Agent

from deepagents import create_deep_agent
from langchain_upstash_box import BoxSandbox

sandbox = BoxSandbox.create(runtime="python")

agent = create_deep_agent(
    model="anthropic:claude-opus-4-6",
    backend=sandbox,
)

agent.invoke({"messages": [{"role": "user", "content": "Create app.py and run it."}]})

🤔 What is this?

BoxSandbox subclasses BaseSandbox and implements execute(), upload_files(), download_files(), and id. All other filesystem tool operations are derived from those by BaseSandbox, which relies on python3 being available inside the box (it is, on the default Debian-based runtimes).

Configuration

Setting Source
API key api_key= argument or UPSTASH_BOX_API_KEY env var
Base URL base_url= argument or UPSTASH_BOX_BASE_URL env var (defaults to https://us-east-1.box.upstash.com)

Development

make test              # unit tests (no credentials needed)
make integration_test  # integration tests (requires UPSTASH_BOX_API_KEY)
make lint
make format

💁 Contributing

Issues and pull requests are welcome at https://github.com/upstash/box.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_upstash_box-0.0.1.tar.gz (144.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_upstash_box-0.0.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file langchain_upstash_box-0.0.1.tar.gz.

File metadata

  • Download URL: langchain_upstash_box-0.0.1.tar.gz
  • Upload date:
  • Size: 144.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for langchain_upstash_box-0.0.1.tar.gz
Algorithm Hash digest
SHA256 fbedfbcb20aa27291be44e993f2f1ebe5f4ec804d7607df78db3ccc25092dad0
MD5 8c971a85741c753a47836b897fdda50e
BLAKE2b-256 dfbc3c13afcc390077cf8a1dc5e9e196dc1aa759f4886d482d821bc4e6367ca9

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_upstash_box-0.0.1.tar.gz:

Publisher: release.yml on upstash/langchain-upstash-box

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langchain_upstash_box-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_upstash_box-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bb28c049ef2c1405a0f7339a5fb0986667e3d48455a6b69123dadd98399ebc82
MD5 1c7502b69fdddc7838e412c21ea2bbaa
BLAKE2b-256 b8cb036e104c951d7d74bafb5853c9af5802e576858b12cc31dea25cd2314c0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_upstash_box-0.0.1-py3-none-any.whl:

Publisher: release.yml on upstash/langchain-upstash-box

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page