From d508d4f402eb4c8a4e520bb2c12ccb9f59f4a88a Mon Sep 17 00:00:00 2001 From: alitariksahin Date: Fri, 31 Jul 2026 00:18:35 +0300 Subject: [PATCH 1/2] feat: add langchain guide --- box/guides/langchain-deep-agents.mdx | 109 +++++++++++++++++++++++++++ docs.json | 2 +- 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 box/guides/langchain-deep-agents.mdx diff --git a/box/guides/langchain-deep-agents.mdx b/box/guides/langchain-deep-agents.mdx new file mode 100644 index 00000000..5a42e69a --- /dev/null +++ b/box/guides/langchain-deep-agents.mdx @@ -0,0 +1,109 @@ +--- +title: "LangChain Deep Agents" +--- + +In this guide we'll give a [LangChain Deep Agent](https://docs.langchain.com/oss/python/deepagents/overview) a real computer to work in. The [`langchain-upstash-box`](https://pypi.org/project/langchain-upstash-box/) package wraps an Upstash Box (a secure, isolated cloud container with a full Linux shell, filesystem, git, and a runtime) as a Deep Agents [sandbox backend](https://docs.langchain.com/oss/python/deepagents/backends). The agent's shell and file tools then run inside the box instead of on your machine. + +--- + +## 1. Installation + + + +```bash pip +pip install langchain-upstash-box +``` + +```bash uv +uv add langchain-upstash-box +``` + + + +Get a Box API key from the [Upstash Console](https://console.upstash.com/box) and export it: + +```bash +export UPSTASH_BOX_API_KEY="box_xxxxxxxxxxxxxxxxxxxxxxxx" +``` + +--- + +## 2. Create a sandbox backend + +`UpstashBoxSandbox.create()` provisions a new box, waits until it is ready, and returns a backend that implements the Deep Agents `SandboxBackendProtocol`: + + +The API key and base URL can also be passed directly as `api_key=` and `base_url=` arguments instead of the `UPSTASH_BOX_API_KEY` and `UPSTASH_BOX_BASE_URL` environment variables. The base URL defaults to `https://us-east-1.box.upstash.com`. + + +```python +from langchain_upstash_box import UpstashBoxSandbox + +# Creates a box and waits until it is ready. +sandbox = UpstashBoxSandbox.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) come for free. +sandbox.write("/workspace/home/hello.py", "print('hi from box')") +print(sandbox.execute("python3 /workspace/home/hello.py").output) + +sandbox.delete() +``` + +If you already have a box, wrap it by id instead of creating a new one: + +```python +sandbox = UpstashBoxSandbox(box_id="current-wasp-05510") +``` + +--- + +## 3. Use with a Deep Agent + +Pass the sandbox as the agent's `backend`. Every shell command and file operation the agent performs now runs inside the box: + +```python +from deepagents import create_deep_agent +from langchain_upstash_box import UpstashBoxSandbox + +sandbox = UpstashBoxSandbox.create(runtime="python") + +agent = create_deep_agent( + model="anthropic:claude-sonnet-4-6", + system_prompt="You are a coding assistant with sandbox access.", + backend=sandbox, +) + +result = agent.invoke( + { + "messages": [ + {"role": "user", "content": "Create a hello world Python script and run it"} + ] + } +) +print(result["messages"][-1].content) + +sandbox.delete() +``` + + +The `model="anthropic:..."` shorthand requires `langchain-anthropic` (install with `pip install "langchain[anthropic]"`) and an `ANTHROPIC_API_KEY` environment variable. Any LangChain chat model works here. + + +--- + +## 4. Cleanup + +You own the box lifecycle, so call `sandbox.delete()` when you are done. An idle box pauses automatically: its compute is released but the filesystem is kept, and it wakes up on the next command. The box itself stays around until you delete it. + +Commands have a default execution timeout of 30 minutes. You can override it for the whole backend or per call: + +```python +sandbox = UpstashBoxSandbox.create(runtime="python", timeout=600) +result = sandbox.execute("sleep 5 && echo done", timeout=30) +``` + +To see everything else a box can do, like snapshots, git, previews, and schedules, check the [Box quickstart](/box/overall/quickstart). diff --git a/docs.json b/docs.json index b58552f0..fb416911 100644 --- a/docs.json +++ b/docs.json @@ -1678,7 +1678,7 @@ }, { "group": "Guides", - "pages": ["box/guides/remote-development", "box/guides/nextjs-setup", "box/guides/code-review-agent", "box/guides/web-scraping-playwright", "box/guides/ai-sdk-code-interpreter", "box/guides/tanstack-ai-file-editor", "box/guides/openclaw-setup", "box/guides/hermes-setup", "box/guides/crabbox-setup"] + "pages": ["box/guides/remote-development", "box/guides/nextjs-setup", "box/guides/code-review-agent", "box/guides/langchain-deep-agents", "box/guides/web-scraping-playwright", "box/guides/ai-sdk-code-interpreter", "box/guides/tanstack-ai-file-editor", "box/guides/openclaw-setup", "box/guides/hermes-setup", "box/guides/crabbox-setup"] } ] }, From a066e02e48d6e9209b3de3277fe9e7a956c10c75 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 30 Jul 2026 21:19:22 +0000 Subject: [PATCH 2/2] chore(llms): regenerate llms.txt and llms-full.txt --- llms-full.txt | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++ llms.txt | 1 + 2 files changed, 110 insertions(+) diff --git a/llms-full.txt b/llms-full.txt index ad646146..1f348147 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -1176,6 +1176,115 @@ hermes gateway start > gateway.log 2>&1 & This command runs automatically whenever the box starts, so your gateway is always available without manual intervention. +# LangChain Deep Agents +Source: https://upstash.com/docs/box/guides/langchain-deep-agents + +In this guide we'll give a [LangChain Deep Agent](https://docs.langchain.com/oss/python/deepagents/overview) a real computer to work in. The [`langchain-upstash-box`](https://pypi.org/project/langchain-upstash-box/) package wraps an Upstash Box (a secure, isolated cloud container with a full Linux shell, filesystem, git, and a runtime) as a Deep Agents [sandbox backend](https://docs.langchain.com/oss/python/deepagents/backends). The agent's shell and file tools then run inside the box instead of on your machine. + +*** + +## 1. Installation + + + +```bash pip +pip install langchain-upstash-box +``` + +```bash uv +uv add langchain-upstash-box +``` + + + +Get a Box API key from the [Upstash Console](https://console.upstash.com/box) and export it: + +```bash +export UPSTASH_BOX_API_KEY="box_xxxxxxxxxxxxxxxxxxxxxxxx" +``` + +*** + +## 2. Create a sandbox backend + +`UpstashBoxSandbox.create()` provisions a new box, waits until it is ready, and returns a backend that implements the Deep Agents `SandboxBackendProtocol`: + + +The API key and base URL can also be passed directly as `api_key=` and `base_url=` arguments instead of the `UPSTASH_BOX_API_KEY` and `UPSTASH_BOX_BASE_URL` environment variables. The base URL defaults to `https://us-east-1.box.upstash.com`. + + +```python +from langchain_upstash_box import UpstashBoxSandbox + +# Creates a box and waits until it is ready. +sandbox = UpstashBoxSandbox.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) come for free. +sandbox.write("/workspace/home/hello.py", "print('hi from box')") +print(sandbox.execute("python3 /workspace/home/hello.py").output) + +sandbox.delete() +``` + +If you already have a box, wrap it by id instead of creating a new one: + +```python +sandbox = UpstashBoxSandbox(box_id="current-wasp-05510") +``` + +*** + +## 3. Use with a Deep Agent + +Pass the sandbox as the agent's `backend`. Every shell command and file operation the agent performs now runs inside the box: + +```python +from deepagents import create_deep_agent +from langchain_upstash_box import UpstashBoxSandbox + +sandbox = UpstashBoxSandbox.create(runtime="python") + +agent = create_deep_agent( + model="anthropic:claude-sonnet-4-6", + system_prompt="You are a coding assistant with sandbox access.", + backend=sandbox, +) + +result = agent.invoke( + { + "messages": [ + {"role": "user", "content": "Create a hello world Python script and run it"} + ] + } +) +print(result["messages"][-1].content) + +sandbox.delete() +``` + + +The `model="anthropic:..."` shorthand requires `langchain-anthropic` (install with `pip install "langchain[anthropic]"`) and an `ANTHROPIC_API_KEY` environment variable. Any LangChain chat model works here. + + +*** + +## 4. Cleanup + +You own the box lifecycle, so call `sandbox.delete()` when you are done. An idle box pauses automatically: its compute is released but the filesystem is kept, and it wakes up on the next command. The box itself stays around until you delete it. + +Commands have a default execution timeout of 30 minutes. You can override it for the whole backend or per call: + +```python +sandbox = UpstashBoxSandbox.create(runtime="python", timeout=600) +result = sandbox.execute("sleep 5 && echo done", timeout=30) +``` + +To see everything else a box can do, like snapshots, git, previews, and schedules, check the [Box quickstart](/docs/box/overall/quickstart). + # Next.js Setup Source: https://upstash.com/docs/box/guides/nextjs-setup diff --git a/llms.txt b/llms.txt index 9d996ff1..6356d140 100644 --- a/llms.txt +++ b/llms.txt @@ -36,6 +36,7 @@ - [Build a Code Review Agent](https://upstash.com/docs/box/guides/code-review-agent.md) - [Running Tests with Crabbox](https://upstash.com/docs/box/guides/crabbox-setup.md) - [Hermes Setup](https://upstash.com/docs/box/guides/hermes-setup.md) +- [LangChain Deep Agents](https://upstash.com/docs/box/guides/langchain-deep-agents.md) - [Next.js Setup](https://upstash.com/docs/box/guides/nextjs-setup.md) - [OpenClaw Setup](https://upstash.com/docs/box/guides/openclaw-setup.md) - [Remote Development](https://upstash.com/docs/box/guides/remote-development.md)