Coding Agents & Terminal · Detailed guide · verified 2026-08-28

swe-rex:Detailed Guide

Sandboxed code execution for coding agents: run commands and tests safely locally or in the cloud, in parallel.

swe-rex Detailed Guide

Version 1.4.0~1.4.0 | category runtime | security (reviewed) | sources: official project docs (English README/docs) + measured in this marketplace (2026-08-28)
Companion: site docs (manifest + guide + evidence) | quick version: site docs

1. When to use it

SWE-ReX (by the SWE-agent team, MIT, ~580 stars) is a sandboxed code executor for agents: runs isolated environments locally or in the cloud, lets an agent execute code and run commands inside, supports large-scale parallelism. CLI form = swerex-remote execution server (Docker backend); there is also a Python API for programmatic agent integration.

In one sentence: an agent's "safe execution workshop" — code runs in the sandbox, never touches your host.

What this tool solves: letting your Agent execute code in a sandbox — isolated local/cloud execution with parallelism (by SWE-agent). Agent code no longer touches your machine directly: swerex-remote starts the sandbox execution server, and the agent client connects and runs commands.

When to use it:

  • You want an isolated code execution environment for your Agent (run commands, run tests);
  • You need parallel execution (sandbox isolation + parallelism);
  • You want to wire the sandbox into your own Agent flow with the Python API (RemoteSandbox).

When not to use it: you don't need isolated execution and can run locally; or you don't have Docker (sandbox execution depends on Docker, sandbox run not tested in this environment).

Notes: heavy entry — sandbox execution depends on Docker; the CLI/library install itself is verified, sandbox runtime is not (no Docker environment).

2. Capability list

CapabilityPurpose
Sandboxed code executionSee the agent-executable guide
Remote/local execution serverSee the agent-executable guide
Parallel executionSee the agent-executable guide
Python API integrationSee the agent-executable guide
Auth-token protectionSee the agent-executable guide

3. Quick install

note: verified path in this environment; Tsinghua mirror required on mainland
# Source: Trove detailed guide · verified 2026-08-28
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple swe-rex==1.4.0
swerex-remote --help

Expected output: usage: swerex-remote [-h] [--host HOST] [--port PORT] --auth-token AUTH_TOKEN

Step 1: Confirm the package and import surface

Why: swerex-remote --help printing the server argument surface + import swerex not erroring means the install and library path work (verified in this environment).

# Source: Trove detailed guide · verified 2026-08-28
swerex-remote --help
python3 -c "import swerex; print('swerex OK')"

Expected output: usage: swerex-remote [-h] [--host HOST] [--port PORT] --auth-token AUTH_TOKEN;swerex OK

Stuck? How to recover:

  • command not found → activate the venv first in venv setups, confirm Python >= 3.10;
  • import failed → confirm pip and python3 are in the same environment.

Step 2: Confirm the sandbox path (needs Docker, not tested in this environment)

Why: the server can listen + the client's run("echo hi") returns hi means the sandbox execution path is complete; sandbox execution depends on Docker, and without Docker it reports docker-missing.

# Source: Trove detailed guide · verified 2026-08-28
swerex-remote --host 127.0.0.1 --port 8000 --auth-token <token>

Expected output: 服务器监听(供 agent 客户端连接执行代码)

# Source: Trove detailed guide · verified 2026-08-28
python3 - <<'PY'
import asyncio
from swerex import RemoteSandbox
async def main:
    sandbox = RemoteSandbox(host="127.0.0.1", port=8000, auth_token="<token>")
    print(await sandbox.run("echo hi"))
asyncio.run(main)
PY

Expected output: hi(需先启动服务器;本环境无 Docker 未实测)

Stuck? How to recover:

  • Docker missing error → install/start Docker first (precheck reports docker-missing);
  • connection refused / token mismatch → confirm the server is running, and port and auth-token match on both sides.

Install variants

PathCommandMeasured
Main path (measured)pip install -i https://pypi.tuna.tsinghua.edu.cn/simple swe-rex==1.4.0 && swerex...✅ measured in this marketplace
Mirror/proxySee quick guide and semi_auto_note; for China installs follow the swe-rex guidemeasured
Semi-auto note: measured command = pip install -i Tsinghua mirror swe-rex==1.4.0 (verified in a venv in this environment 2026-08-28, Python 3.14); CLI = swerex-remote (sandbox execution server, --host/--port/--auth-token); real sandbox execution depends on Docker (not measured here — no Docker execution sandbox); release v1.4.0 (2025-08-14, slightly old) has no assets, distributed via PyPI; library form (swerex Python API) for programmatic integration
  • Sandbox execution: depends on Docker, containers managed by Docker; no Docker in this environment, server run and sandbox execution honestly marked not tested.
  • Server form: swerex-remote is a foreground/managed process; stop the process when not needed (no system service registration).
  • Write surface: pip environment + Docker containers, doesn't write user config directories.
  • Co-install: judged possible-compatible with code-review-graph / repomix — write surfaces don't overlap (sandbox containers / graph data / output files), co-install not tested.

4. Why this happens (mechanism & shared surface)

How it works: the pip package swe-rex provides the swerex-remote CLI (sandbox execution server: --host/--port/--auth-token) + the Python library swerex (RemoteSandbox client: host/port/auth_token → run("command")). Start the server first, then the client connects and executes.

Key concepts:

  • swerex-remote: sandbox execution server (needs Docker + auth token);
  • RemoteSandbox: Python client API;
  • auth-token: connection authentication.

Where it writes: the pip environment; sandbox containers are managed by Docker (needs Docker).

Measured command = pip install -i Tsinghua mirror swe-rex==1.4.0 (verified in a venv in this environment 2026-08-28, Python 3.14); CLI = swerex-remote (sandbox execution server, --host/--port/--auth-token); real sandbox execution depends on Docker (not measured here — no Docker execution sandbox); release v1.4.0 (2025-08-14, slightly old) has no assets, distributed via PyPI; library form (swerex Python API) for programmatic integration

5. Common operations

Step 1: Install the package (why the version is locked: 1.4.0 is the verified collection version)

Why: pip install (Tsinghua mirror on mainland). After install verify the CLI argument surface + the library imports — both verified in this environment.

# Source: Trove detailed guide · verified 2026-08-28
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple swe-rex==1.4.0
swerex-remote --help

Expected output: usage: swerex-remote [-h] [--host HOST] [--port PORT] --auth-token AUTH_TOKEN

# Source: Trove detailed guide · verified 2026-08-28
python3 -c "import swerex; print('swerex OK')"

Expected output: swerex OK

After install, confirm:

  • swerex-remote --help prints the server argument surface;
  • import swerex doesn't error.

Stuck? How to recover:

  • pip slow → confirm the Tsinghua mirror prefix;
  • Python version → confirm >= 3.10.

Step 2: Start the sandbox execution server (needs Docker + auth token; sandbox run not tested in this environment)

Why: swerex-remote --host 127.0.0.1 --port 8000 --auth-token <token> starts the server. Sandbox execution depends on Docker — no Docker in this environment, server run not tested; the command form comes from --help.

# Source: Trove detailed guide · verified 2026-08-28
swerex-remote --host 127.0.0.1 --port 8000 --auth-token <token>

Expected output: 服务器监听(供 agent 客户端连接执行代码)

After install, confirm:

  • the server listens on 127.0.0.1:8000 (needs a Docker environment to verify).

Stuck? How to recover:

  • Docker missing error → sandbox execution depends on Docker (precheck reports docker-missing); install/start Docker first;
  • port taken → change --port.

Step 3: Wire in with the Python API (official form)

Why: the RemoteSandbox client connects to the server and executes commands. Needs the Step 2 server running; not tested in this environment (no Docker).

# Source: Trove detailed guide · verified 2026-08-28
python3 - <<'PY'
import asyncio
from swerex import RemoteSandbox
async def main:
    sandbox = RemoteSandbox(host="127.0.0.1", port=8000, auth_token="<token>")
    print(await sandbox.run("echo hi"))
asyncio.run(main)
PY

Expected output: hi(需先启动服务器;本环境未实测——无 Docker)

Stuck? How to recover:

  • connection refused → confirm the server is running (Step 2) and the port matches;
  • token mismatch → server and client auth-tokens must match.

Startup and entry

  • Server: swerex-remote --host ... --port ... --auth-token ...;
  • Client: RemoteSandbox (Python API).

Common operations

Operation 1: View the CLI surface (verified in this environment)

# Source: Trove detailed guide · verified 2026-08-28
swerex-remote --help

Expected output: 服务器参数面(--host/--port/--auth-token)

Operation 2: Verify the library imports (verified in this environment)

# Source: Trove detailed guide · verified 2026-08-28
python3 -c "import swerex; print('swerex OK')"

Expected output: swerex OK

Operation 3: Start the sandbox execution server (needs Docker + auth token; sandbox run not tested in this environment)

# Source: Trove detailed guide · verified 2026-08-28
swerex-remote --host 127.0.0.1 --port 8000 --auth-token <token>

Expected output: 服务器监听(供 agent 客户端连接执行代码)

Operation 4: Wire in with the Python API (official form)

# Source: Trove detailed guide · verified 2026-08-28
python3 - <<'PY'
import asyncio
from swerex import RemoteSandbox
async def main:
    sandbox = RemoteSandbox(host="127.0.0.1", port=8000, auth_token="<token>")
    print(await sandbox.run("echo hi"))
asyncio.run(main)
PY

Expected output: hi(需先启动服务器;本环境未实测——无 Docker)

Data and directories

  • pip environment; sandbox containers managed by Docker (images/data on the Docker side).

6. Conflict pairs (summary)

Same source as the tool-page matrix — 19 pairs total (6 measured compatible / 13 inferred possibly compatible / 0 inferred possibly conflicting); full pairs, states and evidence: Conflict pairs (co-install matrix).

7. Quick troubleshooting

  • No standalone handbook yet; for install/uninstall issues first see the agent-executable guide notes

8. Uninstall and residue check

# Source: Trove detailed guide · verified 2026-08-28
pip uninstall -y swe-rex 2>/dev/null || true
note: pip package auto-uninstall (idempotent); sandbox containers cleaned as needed
# Source: Trove detailed guide · verified 2026-08-28
pip uninstall -y swe-rex 2>/dev/null || true
command -v swerex-remote >/dev/null 2>&1 && echo '残留: swerex-remote 仍存在' || echo 'swe-rex removed: OK'

Expected output: swe-rex removed: OK

9. FAQ

  • Runtime preflight (needs Python >= 3.10; sandbox execution needs Docker)
  • Official PyPI path (measured here); China installs must use the Tsinghua mirror
  • Each operation = one command block + expected output
  • pip package auto-uninstalls (idempotent); sandbox containers cleaned as needed
  • Heavy entry: sandbox execution depends on Docker (images + containers); this marketplace measured to the CLI/library layer, no real sandbox run
  • Q: Can I use it without Docker? A: install and CLI/library smoke work (verified in this environment); sandbox execution (swerex-remote starting the server) depends on Docker, not tested.
  • Q: How do I stop the server? A: Ctrl+C for a foreground process, or manage it as a managed process (systemd etc.).
  • Q: What is auth-token? A: the connection auth token, generated by yourself (e.g. openssl rand -hex 16); server and client must match.
  • Q: Install with repomix / code-review-graph? A: judged possible-compatible — write surfaces don't overlap (sandbox containers / output files / graph data), co-install not tested.
  • Q: Where to report problems? A: install/uninstall issues on this marketplace go through the entry feedback channel; project issues go to the author's repository.
  • Version: [1.4.0, 1.4.0] locked (verified collection version; release v1.4.0 has no separate assets, distributed via PyPI).
  • Environment: Python >= 3.10; sandbox execution needs Docker (sandbox run not tested in this environment).
  • Network: pip via the Tsinghua mirror (verified mainland path).
  • Write surface: pip environment; sandbox containers managed by Docker.
  • Background process: swerex-remote is a server form (foreground/managed process).
  • Co-install: judged possible-compatible with code-review-graph / repomix — write surfaces don't overlap (sandbox containers / graph data / output files), co-install not tested.

10. Sources

  • Verified: local repro log (2026-08-28, pip install + swerex-remote --help + import smoke).
  • Not tested: the sandbox execution server and RemoteSandbox runtime (no Docker) — commands from --help/official docs, honestly labeled.

External tutorials (unverified)

Third-party tutorials are not individually verified; check against this page and official docs.

Merged sources

This page merges multiple source articles — deduplicated by content hash, measured, and rewritten by AI. Sources are not scattered; they all live on this single page.

No merged sources yet: this page distills local verification and community rewrites; provenance details live on the linked solution page.

← Back to swe-rex solution page | Coding Agents & Terminal domain