swe-rex
Sandboxed code execution for AI agents, locally or on the cloud.
What it is and what it does
SWE-ReX is a runtime abstraction layer that lets AI agents execute shell commands in sandboxed environments without caring whether they run locally, in Docker, on AWS, or on Modal. It handles the messy details of spawning sessions, detecting command completion, capturing output and exit codes, and managing multiple parallel shells—so your agent code stays the same whether you're testing locally or scaling to dozens of parallel runs.
The package is built on fastapi and uvicorn, suggesting it exposes a web service interface for remote execution. It integrates with pexpect and bashlex to parse and interact with shell sessions, and uses pydantic for configuration validation. It's designed for developers building AI agents that need to run arbitrary commands in controlled environments without reimplementing infrastructure plumbing.
Use it for:
- Let an AI agent run code-fixing commands in an isolated Docker container without hardcoding container-specific logic in your agent.
- Evaluate an AI agent on a benchmark by spinning up parallel shell sessions and running the agent on each without managing infrastructure.
- Build a multi-tool agent that uses ipython, gdb, and bash interactively, with SWE-ReX handling session multiplexing and output parsing.
- Deploy an agent to Modal or AWS and have it execute shell commands remotely while your agent code remains unchanged.
- Run many agents in parallel locally or on the cloud without writing custom process management or container orchestration code.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
SWE-ReX provides a runtime interface for AI agents to execute shell commands in sandboxed environments—local, Docker, AWS, or Modal—with a unified API that abstracts away infrastructure details.
Yes, if you are building AI agents that need to execute shell commands in sandboxed or remote environments. The package solves a real infrastructure abstraction problem and is actively maintained with no known vulnerabilities. Install friction is low and the permissive MIT license removes legal friction. Start with the base install; add optional dependencies only if you need Modal, Fargate, or Daytona support.
Install
swe-rex on PyPI
pip
pip install swe-rexuv
uv add swe-rexpoetry
poetry add swe-rexInstalling swe-rex
Before you install
Low friction install with a pure-Python wheel. Active maintenance (last commit 2026-08-10) and recent releases (1.4.0 on 2025-08-14) suggest ongoing support. Eight runtime dependencies including fastapi, uvicorn, and pydantic indicate a web-service-oriented architecture.
License in practice
MIT license (permissive) allows unrestricted use, modification, and distribution with minimal legal friction for commercial or private projects.
Quickstart
pip install swe-rex
from swe_rex import LocalExecutor
executor = LocalExecutor()
result = executor.run_command('echo hello')
Requires Python >=3.10. For cloud platforms (Modal, Fargate, Daytona), additional optional dependencies and platform credentials are needed.
Verify before relying
- Exact API surface and how to instantiate executors for different platforms (Docker, AWS, Modal) beyond the install extras shown.
- Whether interactive tools like ipython or gdb require special configuration or just work out of the box.
- Performance characteristics and latency overhead when running commands remotely vs. locally.
- Limits on parallel agent count or resource consumption when scaling to many concurrent sessions.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 8 — fastapi, uvicorn, requests, pydantic, pexpect, bashlex, python-multipart, rich |
| Maintenance | actively maintained — 365 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,151,672/month — #2,724 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: swe_rex-1.4.0-py3-none-any.whl
Keywords: nlp, agents, code
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
mini-swe-agentAn AI agent that solves software engineering…
permissive · top 5,000 on PyPI
swesmithSWE-smith generates large-scale software…
permissive · top 5,000 on PyPI
pykaosPyKAOS provides an abstraction layer for agents…
unclear · top 15,000 on PyPI
swebenchSWE-bench is a benchmark framework for…
permissive · top 1,000 on PyPI
spotinst-agentSpotinst-agent is a remote execution agent that…
permissive · top 15,000 on PyPI
spotinst-agent-2Spotinst Agent is a remote script executor that…
permissive · top 15,000 on PyPI
e2bE2B provides a Python SDK to create and control…
permissive · top 5,000 on PyPI
pydantic-ai-backendProvides sandboxed execution and file…
permissive · top 15,000 on PyPI
harborHarbor is a framework for running and…
permissive · top 5,000 on PyPI
google-agents-cliA CLI toolchain that equips coding agents…
permissive · top 15,000 on PyPI