Example
mini-SWE-agent — a shell-only coding agent

A real, runnable mini-project. Download it and run with Docker.

June 28, 2026

mini-SWE-agent — a shell-only coding agent

A minimal mini-SWE-agent binding: a DefaultAgent drives a LocalEnvironment with a text-based LiteLLM model. It reads a task, runs one bash command at a time, observes the output, and loops until it submits. The model is routed through LiteLLM, so the same code works with Anthropic Claude, OpenAI, or Google AI Studio (Gemini) — just change MODEL in .env.

Use a capable model (e.g. claude-opus-4-8, gpt-4o). The agent protocol — reply with one mswea_bash_command fence, then submit — is unreliable with small models, which tend to loop or mis-format.

Configure

cd samples/mini-swe-agent_1
cp .env.sample .env
# edit .env: set MODEL and the matching provider key

MODEL picks the provider:

Provider MODEL example Key in .env
Anthropic Claude claude-opus-4-8 ANTHROPIC_API_KEY
OpenAI gpt-4o OPENAI_API_KEY
Google AI Studio gemini/gemini-2.5-flash GEMINI_API_KEY
Ollama (local) ollama_chat/qwen3.5:9b OLLAMA_API_BASE

.env is gitignored — only .env.sample is committed.

Ollama (local models): first pull the model on the host — ollama pull qwen3.5:9b (or ollama run qwen3.5:9b). Then set MODEL=ollama_chat/qwen3.5:9b and point OLLAMA_API_BASE at the server — no API key needed. In a devcontainer with DooD the container reaches the host's Ollama at http://host.docker.internal:11434; running locally use http://localhost:11434.

Run with Docker

cd samples/mini-swe-agent_1
docker build -t aas-mini-swe-agent .
docker run --rm --env-file .env aas-mini-swe-agent \
  "Print the result of 2 + 2 using a single shell command, then submit."

Run with Docker (in a devcontainer with DooD)

In a dev container that talks to the host Docker daemon (Docker-outside-of-Docker), the foreground docker run above often prints nothing and exits 0 — but the run itself succeeds. The agent runs to completion and Docker captures all of its output; only the live attached stream drops it over the VM boundary. You can confirm this: docker logs on the same container shows the full output, the container exits 0, and it is not an OOM. Run detached and follow the logs instead:

cd samples/mini-swe-agent_1
docker build -t aas-mini-swe-agent .
docker logs -f "$(docker run -d --env-file .env aas-mini-swe-agent \
  "Print the result of 2 + 2 using a single shell command, then submit.")"

Run locally

cd samples/mini-swe-agent_1
pip install -r requirements.txt
python app.py "Print the result of 2 + 2 using a single shell command, then submit."

python-dotenv loads .env automatically. Get keys from Anthropic, OpenAI, or Google AI Studio.


Example run

Output varies by model and run — LLMs are non-deterministic, so the exact wording (and an agent's steps) differ each time. Below is one run with claude-opus-4-8.

--- assistant ---
THOUGHT: The task simply asks to print the result of 2 + 2 using a single shell command. Let me do that.

```mswea_bash_command
echo $((2 + 2))
```

--- user ---
<returncode>0</returncode>
<output>
4
</output>

--- assistant ---
THOUGHT: The command printed 4 as expected. Now I'll submit.

```mswea_bash_command
echo COMPLETE_TASK_AND_SUBMIT_FINAL_OUTPUT
```

=== Submitted ===

Files

.env.sample
# Copy this file to `.env` and fill in the key for the provider you want.
#   cp .env.sample .env
#
# One codebase, many providers — mini-SWE-agent routes via LiteLLM based on MODEL.
# Use a capable model: the agent protocol is unreliable with small models.

# Pick the model. Examples:
#   claude-opus-4-8              Anthropic Claude   -> needs ANTHROPIC_API_KEY
#   gpt-4o                       OpenAI             -> needs OPENAI_API_KEY
#   gemini/gemini-2.5-flash      Google AI Studio   -> needs GEMINI_API_KEY
#   ollama_chat/qwen3.5:9b       Ollama (local)     -> needs OLLAMA_API_BASE, no key
MODEL=claude-opus-4-8

# Set only the key for the provider you chose; leave the rest blank.
ANTHROPIC_API_KEY=
OPENAI_API_KEY=
GEMINI_API_KEY=

# Ollama only — where the Ollama server runs (pull the model first, e.g.
# `ollama pull qwen3.5:9b`). Other providers ignore this line.
#   Local, no Docker:           http://localhost:11434
#   Docker / DooD on the host:  http://host.docker.internal:11434
OLLAMA_API_BASE=http://host.docker.internal:11434