Skip to content
Merged
2 changes: 2 additions & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
"docs/agents/crabbox",
"docs/agents/devin",
"docs/agents/grok",
"docs/agents/deep-agents",
"docs/agents/open-swe",
"docs/agents/openai-agents-sdk",
{
"group": "OpenClaw",
Expand Down
113 changes: 113 additions & 0 deletions docs/agents/deep-agents.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
title: "LangChain Deep Agents"
description: "Use E2B sandboxes as the execution backend for LangChain Deep Agents."
icon: "/images/icons/deep-agents.svg"
---

[Deep Agents](https://docs.langchain.com/oss/python/deepagents/overview) is LangChain's agent harness for building LLM-powered agents, built on the [LangGraph](https://langchain-ai.github.io/langgraph/) runtime. In Deep Agents, a [sandbox backend](https://docs.langchain.com/oss/python/deepagents/sandboxes) defines the environment where the agent operates — E2B is a supported backend via the [`langchain-e2b`](https://pypi.org/project/langchain-e2b/) package.

With the E2B backend, the agent's built-in tools all execute inside an isolated sandbox instead of your machine:

- **Filesystem tools** — `ls`, `read_file`, `write_file`, `edit_file`, `glob`, and `grep` operate on the sandbox filesystem.
- **Shell tool** — `execute` runs arbitrary shell commands in the sandbox.

## Install the dependencies

Set API keys for E2B and your model provider:

```bash
export E2B_API_KEY="e2b_***" # get yours at https://e2b.dev/dashboard
export ANTHROPIC_API_KEY="sk-ant-***"
```

Then install the packages:

```bash
pip install deepagents langchain-e2b e2b
```

## Basic example

Create an E2B sandbox, wrap it in the `E2BSandbox` backend, and pass it to `create_deep_agent`. You manage the sandbox lifecycle yourself — create it before the agent runs and kill it when you're done.

```python
from deepagents import create_deep_agent
from e2b import Sandbox
from langchain_e2b import E2BSandbox

sandbox = Sandbox.create(timeout=600)

agent = create_deep_agent(
model="anthropic:claude-sonnet-5",
system_prompt="You are a coding agent working in an isolated Linux sandbox.",
backend=E2BSandbox(sandbox=sandbox),
)

result = agent.invoke({
"messages": [{
"role": "user",
"content": "Create hello.py that prints 'Hello from E2B', run it, and show the output.",
}]
})

print(result["messages"][-1].content)
sandbox.kill()
```

The agent's file operations and shell commands all run inside the sandbox — nothing touches your machine. Because the backend wraps the native E2B SDK sandbox, you can configure everything the SDK supports: [custom templates](/docs/template/quickstart), timeouts, [persistence](/docs/sandbox/persistence), or reconnecting to an existing sandbox by ID.

## Deep Agents Code (dcode)

Check warning on line 59 in docs/agents/deep-agents.mdx

View check run for this annotation

Mintlify / Mintlify Validation (e2b) - vale-spellcheck

docs/agents/deep-agents.mdx#L59

Did you really mean 'dcode'?

[Deep Agents Code](https://docs.langchain.com/oss/python/deepagents/sandboxes#deep-agents-code) is LangChain's terminal coding agent built on Deep Agents. `langchain-e2b` ships a sandbox provider for it, so every `dcode` session can run in an E2B sandbox:

```bash
dcode --install langchain-e2b --package
export E2B_API_KEY="e2b_***"
dcode --sandbox e2b
```

Requires `dcode` >= 0.1.19 and `langchain-e2b` >= 0.0.4. Unlike the library path, `dcode` manages the sandbox lifecycle for you — it creates the sandbox on start and deletes it on exit. Configure it with:

- `E2B_TEMPLATE` — custom sandbox template to start from
- `E2B_SANDBOX_TIMEOUT` — sandbox timeout in seconds

## Custom templates

By default, sandboxes start from the E2B base template. To pre-install languages, frameworks, or tools your agent needs — and cut setup time per run — build a [custom template](/docs/template/quickstart) and pass it when creating the sandbox:

```python
sandbox = Sandbox.create(template="your-template-id-or-name", timeout=600)
```

## Deep Agents vs. Open SWE

[Open SWE](/docs/agents/open-swe) is LangChain's coding agent framework built on top of Deep Agents — both use the same `langchain-e2b` backend under the hood, but they sit at different layers:

| | **Deep Agents** (this page) | **[LangChain Open SWE](/docs/agents/open-swe)** |
|---|---|---|
| What it is | A Python library you embed in your own agent | A deployable internal coding agent you fork and run |
| How you use E2B | Create the sandbox yourself and pass `E2BSandbox` to `create_deep_agent` | Set `SANDBOX_TYPE="e2b"` — sandboxes are created and managed for you |
| Sandbox lifecycle | Yours to manage (`Sandbox.create()` / `sandbox.kill()`) | Per-thread persistent sandbox, reconnect by ID, auto-recreate |
| Use it when | Building any custom agent that needs isolated code execution | You want a GitHub/Slack/Linear-driven coding agent for your org |

Use this page's approach for custom agents; if you're deploying a coding agent for your team, start from [Open SWE](/docs/agents/open-swe) instead.

## Learn more

- [Deep Agents sandboxes](https://docs.langchain.com/oss/python/deepagents/sandboxes) — sandbox backends overview
- [E2B integration reference](https://docs.langchain.com/oss/python/integrations/sandboxes/e2b) — LangChain's E2B provider page
- [`langchain-e2b` on PyPI](https://pypi.org/project/langchain-e2b/)

## Related guides

<CardGroup cols={3}>
<Card title="Templates" icon="layer-group" href="/docs/template/quickstart">
Build custom sandbox templates with pre-installed dependencies
</Card>
<Card title="Sandbox persistence" icon="clock" href="/docs/sandbox/persistence">
Auto-pause, resume, and manage sandbox lifecycle
</Card>
<Card title="Open SWE" icon="/images/icons/open-swe.svg" href="/docs/agents/open-swe">
LangChain's coding agent framework with E2B built in
</Card>
</CardGroup>
90 changes: 90 additions & 0 deletions docs/agents/open-swe.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
title: "LangChain Open SWE"
description: "Use E2B sandboxes as the execution environment for Open SWE, LangChain's open-source coding agent framework."
icon: "/images/icons/open-swe.svg"
---

[Open SWE](https://github.com/langchain-ai/open-swe) is LangChain's open-source framework for building your org's internal coding agent, built on [LangGraph](https://langchain-ai.github.io/langgraph/) and [Deep Agents](https://github.com/langchain-ai/deepagents). Every task runs in an isolated cloud sandbox where the agent gets full shell access — and E2B is a supported sandbox provider out of the box.

Check warning on line 7 in docs/agents/open-swe.mdx

View check run for this annotation

Mintlify / Mintlify Validation (e2b) - vale-spellcheck

docs/agents/open-swe.mdx#L7

Did you really mean 'org's'?

## Get started

<Steps>
<Step title="Clone and install Open SWE">

```bash
git clone https://github.com/langchain-ai/open-swe.git
cd open-swe
uv venv
source .venv/bin/activate
uv sync --all-extras
```

</Step>
<Step title="Set the sandbox provider to E2B">

Get your API key from the [E2B dashboard](https://e2b.dev/dashboard?tab=keys) and create a `.env` file in the repo root — `langgraph dev` loads it automatically:

```bash .env
SANDBOX_TYPE="e2b"
E2B_API_KEY="e2b_***" # get yours at https://e2b.dev/dashboard
E2B_TEMPLATE="my-template" # optional: custom sandbox template

# === LLM ===
OPENAI_API_KEY="" # default model is openai:gpt-5.6-sol
ANTHROPIC_API_KEY="" # when using anthropic: models
```

You need an API key for at least one LLM provider — the default model is `openai:gpt-5.6-sol`, and you can switch with `LLM_MODEL_ID` (e.g. `LLM_MODEL_ID="anthropic:claude-sonnet-5"`). Google and Fireworks are also supported — see the [full environment variable reference](https://github.com/langchain-ai/open-swe/blob/main/docs/INSTALLATION.md#6-environment-variables) for LangSmith tracing, GitHub App, and trigger configuration.

No other sandbox changes are needed — Open SWE creates and manages the sandboxes for you.

</Step>
<Step title="Run the backend">

Open SWE's backend is a LangGraph app served together with its webhook API:

Check warning on line 44 in docs/agents/open-swe.mdx

View check run for this annotation

Mintlify / Mintlify Validation (e2b) - vale-spellcheck

docs/agents/open-swe.mdx#L44

Did you really mean 'SWE's'?

```bash
langgraph dev
```

The full deployment (GitHub App, webhooks, dashboard) is covered in the [installation guide](https://github.com/langchain-ai/open-swe/blob/main/docs/INSTALLATION.md).

</Step>
<Step title="Watch the sandboxes">

As Open SWE picks up tasks, you can watch it create and reuse sandboxes with the [E2B CLI](/docs/cli):

```bash
e2b sandbox list --state running
```

</Step>
</Steps>

## Custom templates

By default, sandboxes start from the E2B base template. To pre-install languages, frameworks, or internal tools your repositories depend on — and cut setup time per agent run — build a [custom template](/docs/template/quickstart) and point Open SWE at it:

```bash
E2B_TEMPLATE="your-template-id-or-name"
```

## Learn more

- [Open SWE installation guide](https://github.com/langchain-ai/open-swe/blob/main/docs/INSTALLATION.md)
- [Open SWE customization guide](https://github.com/langchain-ai/open-swe/blob/main/docs/CUSTOMIZATION.md#using-a-different-sandbox-provider) — switching sandbox providers
- [Announcement blog post](https://blog.langchain.com/open-swe-an-open-source-framework-for-internal-coding-agents/)

## Related guides

<CardGroup cols={3}>
<Card title="Templates" icon="layer-group" href="/docs/template/quickstart">
Build custom sandbox templates with pre-installed dependencies
</Card>
<Card title="Sandbox persistence" icon="clock" href="/docs/sandbox/persistence">
Auto-pause, resume, and manage sandbox lifecycle
</Card>
<Card title="Git integration" icon="code-branch" href="/docs/sandbox/git-integration">
Clone repos, manage branches, and push changes

Check warning on line 88 in docs/agents/open-swe.mdx

View check run for this annotation

Mintlify / Mintlify Validation (e2b) - vale-spellcheck

docs/agents/open-swe.mdx#L88

Did you really mean 'repos'?
</Card>
</CardGroup>
1 change: 1 addition & 0 deletions images/icons/deep-agents.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions images/icons/open-swe.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading