An environment is responsible for executing shell commands and returning their output. Every environment exposes the same minimal interface: anDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/swe-agent/mini-swe-agent/llms.txt
Use this file to discover all available pages before exploring further.
execute(action, cwd, *, timeout) method that accepts an action dict (with a "command" key) and returns a dict with output, returncode, and exception_info keys.
Environments are selected via the environment_class key in a YAML config or by importing the class directly in Python. The helper get_environment from minisweagent.environments can instantiate any environment from a plain dict.
get_environment are: local, docker, singularity, bubblewrap, contree, swerex_docker, swerex_modal.
LocalEnvironment
Executes commands directly on the host machine viasubprocess.run. No container or sandbox is involved. Suitable for development, CI, or any context where the host filesystem is the workspace.
Working directory for all commands. Defaults to the current working directory
of the Python process when left empty.
Extra environment variables merged into the process environment via
os.environ | config.env. Host variables not in this dict are still
inherited.Per-command timeout in seconds. Raises a
subprocess.TimeoutExpired
exception (caught and returned as an error dict) when exceeded.DockerEnvironment
Starts a long-lived Docker container at construction time and runs each command viadocker exec. The container is removed when the environment object is garbage-collected or cleanup() is called explicitly.
Docker image to run. The image is pulled if not present locally. Pull timeout
is controlled by
pull_timeout.Working directory inside the container.
Environment variables set inside the container. Takes precedence over
forward_env values if there is a conflict.Names of host environment variables to forward into the container. Variables
are only forwarded if they are set on the host.
Per-command timeout in seconds for
docker exec calls.Path to the container runtime executable. Override via the
MSWEA_DOCKER_EXECUTABLE environment variable or this config field. Useful
for Podman or other Docker-compatible runtimes.Additional arguments appended to
docker run. The default --rm removes the
container after it stops.Maximum duration the container is kept alive, expressed as a
sleep-compatible
duration string (e.g. "2h", "30m").Timeout in seconds for the initial image pull.
Interpreter used to run each command. The command string is appended as the
final argument. Override to change shell flags (e.g. remove
-l to skip
login-shell initialisation) or use a different interpreter such as Python.SingularityEnvironment
Runs each command inside a Singularity/Apptainer container. At construction time the image is converted to a writable sandbox directory in the system temp folder. The sandbox is cleaned up when the object is destroyed.Singularity image URI or path (e.g.
docker://python:3.12-slim or a local
.sif file path).Working directory inside the container for command execution.
Environment variables set inside the container via
--env KEY=VALUE.Host environment variable names to forward into the container. Only forwarded
when set on the host.
Per-command timeout in seconds.
Path to the Singularity/Apptainer executable. Override via
MSWEA_SINGULARITY_EXECUTABLE.Number of retry attempts for the
singularity build --sandbox step, which
can occasionally fail on network-backed images.Arguments inserted before the subcommand (e.g.
--quiet, --debug).Arguments appended to
singularity exec. The defaults isolate the container
from the host environment and run with a fakeroot.BubblewrapEnvironment
Runs commands inside an unprivileged Linux sandbox created by Bubblewrap (bwrap). A fresh temporary working directory is created for each environment instance and cleaned up on destruction.
Note: This environment is experimental and Linux-only.
Working directory inside the sandbox. Defaults to the auto-generated
temporary directory for this environment instance.
Environment variables to set inside the sandbox via
--setenv.Per-command timeout in seconds.
Path to the Bubblewrap executable. Override via
MSWEA_BUBBLEWRAP_EXECUTABLE.Full list of arguments passed to
bwrap before the command. The default
mounts /usr, /bin, /lib, /lib64, /etc as read-only, creates a
tmpfs at /tmp, and sets a restricted PATH. Override this list to
customise the sandbox layout.ContreeEnvironment
Runs commands inside a ConTree container managed via thecontree-sdk Python package. Requires the optional dependency: pip install contree-sdk.
Configuration for the ConTree client. Accepts a
ContreeConfig object or a
plain dict that will be converted to one.OCI image reference to run (e.g.
python:3.12-slim).If set, the image is pulled by this tag. Falls back to importing by the
image reference and tagging it.Working directory inside the container.
When
true, runs mkdir -p <cwd> before the first command.Environment variables set in the container. Takes precedence over
forward_env on conflict.Host environment variable names to forward into the container.
Interpreter used to run commands.
Per-command timeout in seconds.
Registry username used when importing a private image.
Registry password used when importing a private image.
SwerexDockerEnvironment
Runs commands in a Docker container managed by SWE-ReX. Requires the optional dependency:pip install swerex.
Docker image to deploy.
Default working directory for command execution.
Per-command timeout in seconds.
Additional keyword arguments forwarded to
swerex.deployment.docker.DockerDeployment.SwerexModalEnvironment
Runs commands inside a Modal serverless sandbox via SWE-ReX. Useful for large-scale parallel evaluations and training workloads. Requires the optional dependencies:pip install swerex modal.
Image to use for the Modal deployment. Accepts:
- Docker Hub image name (e.g.
python:3.11-slim) - ECR image URI
- Path to a Dockerfile
Default working directory inside the sandbox.
Per-command execution timeout in seconds.
Environment variables passed to each command execution.
Seconds to wait for the Modal sandbox runtime to become ready.
How long the Modal sandbox may stay alive in total (seconds).
Overall deployment timeout in seconds.
Whether to install
pipx in the container. Required by the SWE-ReX runtime.Additional keyword arguments forwarded directly to
modal.Sandbox.create.Selecting an environment via CLI
When using themini CLI, pass --environment-class (or set it in your YAML config):