Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
784692d
feat: add E2B cloud sandbox environment
JunYeopLee Mar 24, 2026
db34ac7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 24, 2026
f94ad52
feat: register active sandboxes for atexit cleanup
JunYeopLee Mar 24, 2026
0c7f362
fix: remove unsupported access_token option from E2B environment
JunYeopLee Mar 24, 2026
c4f8222
fix: respect skip_cache when E2B template already exists
JunYeopLee Mar 24, 2026
32d1f91
fix: run E2B sandbox commands as root user
JunYeopLee Mar 24, 2026
8bd3fee
fix: auto-rebuild E2B template on 404 stale cache error
JunYeopLee Apr 7, 2026
f8b9a05
fix: ensure sandbox cleanup in process_instance finally block
JunYeopLee Apr 7, 2026
bec508e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 7, 2026
a07b79e
Move imports top
klieret Jun 10, 2026
6718c1c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 10, 2026
efc3935
fix: remove temporary E2B sandbox metadata override
JunYeopLee Jun 16, 2026
8168400
fix: preserve output and exit code for failing E2B commands
JunYeopLee Jun 16, 2026
c785bb2
fix: inject platform.uname() into E2B template vars
JunYeopLee Jun 16, 2026
f5bc015
fix: keep E2B credentials out of template vars and serialization
JunYeopLee Jun 16, 2026
fcff143
fix: unify environment teardown in swebench finally block
JunYeopLee Jun 16, 2026
7f040d1
fix: match leading 404 status for E2B stale-template recovery
JunYeopLee Jun 16, 2026
96f9aed
fix: always release environment in process_instance teardown
JunYeopLee Jun 16, 2026
88385c8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 16, 2026
21d7e63
fix: add e2b to full extra so pylint can import it
JunYeopLee Jun 23, 2026
7befef8
test: remove unused _make_mock_e2b helper
JunYeopLee Jun 23, 2026
0eb096f
fix: tear down environment when startup command fails
JunYeopLee Jun 23, 2026
78900e0
Merge remote-tracking branch 'origin/main' into feat/e2b-environment
JunYeopLee Jul 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ We now ask: **What if our agent was 100x simpler, and still worked nearly as wel
- **Minimal**: Just some 100 lines of python for the [agent class](https://github.com/SWE-agent/mini-swe-agent/blob/main/src/minisweagent/agents/default.py) (and a bit more for the [environment](https://github.com/SWE-agent/mini-swe-agent/blob/main/src/minisweagent/environments/local.py),
[model](https://github.com/SWE-agent/mini-swe-agent/blob/main/src/minisweagent/models/litellm_model.py), and [run script](https://github.com/SWE-agent/mini-swe-agent/blob/main/src/minisweagent/run/hello_world.py)) — no fancy dependencies!
- **Performant:** Scores >74% on the [SWE-bench verified benchmark](https://www.swebench.com/); starts much faster than Claude Code
- **Deployable:** Supports **local environments**, **docker/podman**, **singularity/apptainer**, **bublewrap**, **contree**, and more
- **Deployable:** Supports **local environments**, **docker/podman**, **singularity/apptainer**, **bubblewrap**, **contree**, **[E2B](https://e2b.dev)** (no local Docker required), and more
- **Compatible:** Supports all models via **litellm**, **openrouter**, **portkey**, and more. Support for `/completion` and `/response` endpoints, interleaved thinking etc.
- Built by the Princeton & Stanford team behind [SWE-bench](https://swebench.com), [SWE-agent](https://swe-agent.com), and more
- **Tested:** [![Codecov](https://img.shields.io/codecov/c/github/swe-agent/mini-swe-agent?style=flat-square)](https://codecov.io/gh/SWE-agent/mini-swe-agent)
Expand Down
2 changes: 2 additions & 0 deletions docs/advanced/environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ On top, there are a few more specialized environment classes that you can use:

* **`contree`** ([`ContreeEnvironment`](../reference/environments/contree.md)) - Uses [ConTree](https://contree.dev/) for safe code execution sandboxing. Platform that built for agents and supports Git-like execution.

* **`e2b`** ([`E2BEnvironment`](../reference/environments/e2b.md)) - [E2B](https://e2b.dev) cloud sandbox execution. Converts Docker images into persistent E2B templates so **no local Docker daemon is required**. Suitable for large-scale, fully-remote SWE-bench evaluations.

78 changes: 78 additions & 0 deletions docs/reference/environments/e2b.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# E2B

!!! note "E2B Environment class"

- [Read on GitHub](https://github.com/swe-agent/mini-swe-agent/blob/main/src/minisweagent/environments/extra/e2b.py)
- Requires an [E2B](https://e2b.dev) account and API key

??? note "Full source code"

```python
--8<-- "src/minisweagent/environments/extra/e2b.py"
```

::: minisweagent.environments.extra.e2b

This environment executes commands in [E2B](https://e2b.dev) cloud sandboxes.
E2B converts Docker images into persistent sandbox templates, so **no local Docker daemon is required** — everything runs in the cloud.

This makes it well-suited for:

- Large-scale, fully-remote SWE-bench evaluations
- Environments where Docker is unavailable (CI, serverless)
- Parallel agent runs without managing local container infrastructure

## How it works

The first time a Docker image is used, `E2BEnvironment` builds a persistent E2B template from that image (via `Template.build`). Subsequent runs reuse the cached template, so the build cost is paid only once per unique image.

## Setup

1. Install the E2B extra:
```bash
pip install "mini-swe-agent[e2b]"
```

2. Set your E2B API key:
```bash
export E2B_API_KEY="your-e2b-api-key"
```

## Usage

Evaluate on SWE-bench using E2B as the sandbox backend:
```bash
mini-extra swebench \
--subset verified \
--split test \
--workers 50 \
--environment-class e2b
```

Or specify it in your YAML config:
```yaml
environment:
environment_class: e2b
sandbox_timeout: 3600 # seconds the sandbox stays alive
cpu_count: 2
memory_mb: 2048
```

## Configuration reference

| Field | Default | Description |
|-------|---------|-------------|
| `image` | *(required)* | Docker Hub image to use as the sandbox base |
| `cwd` | `/` | Default working directory for commands |
| `timeout` | `30` | Per-command timeout in seconds |
| `env` | `{}` | Environment variables set in every command |
| `sandbox_timeout` | `3600` | How long the sandbox stays alive (seconds) |
| `cpu_count` | `2` | vCPUs allocated to the sandbox |
| `memory_mb` | `2048` | Memory allocated to the sandbox (MiB) |
| `build_timeout` | `1800` | Max seconds to wait for a template build |
| `skip_cache` | `False` | Force-rebuild the template even if it exists |
| `api_key` | `None` | E2B API key (falls back to `E2B_API_KEY` env var) |
| `registry_username` | `None` | Username for private Docker registry auth |
| `registry_password` | `None` | Password for private Docker registry auth |

{% include-markdown "../../_footer.md" %}
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ full = [
"swe-rex>=1.4.0",
"mini-swe-agent[modal]",
"mini-swe-agent[contree]",
"mini-swe-agent[e2b]",
]

modal = [
Expand Down Expand Up @@ -81,6 +82,10 @@ contree = [
"contree-sdk>=0.2.0",
]

e2b = [
"e2b>=1.0.0",
]

[project.urls]
Documentation = "https://mini-swe-agent.com/latest/"
Repository = "https://github.com/SWE-agent/mini-swe-agent"
Expand Down
1 change: 1 addition & 0 deletions src/minisweagent/environments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"swerex_modal": "minisweagent.environments.extra.swerex_modal.SwerexModalEnvironment",
"bubblewrap": "minisweagent.environments.extra.bubblewrap.BubblewrapEnvironment",
"contree": "minisweagent.environments.extra.contree.ContreeEnvironment",
"e2b": "minisweagent.environments.extra.e2b.E2BEnvironment",
}


Expand Down
Loading