mini-swe-agent is not just a CLI tool — it is a fully importable Python library. You can instantiate an agent, run it on any task string, and inspect or persist the resulting trajectory, all from your own Python code. This makes it straightforward to embed mini-swe-agent inside larger pipelines, evaluation harnesses, or custom run scripts.Documentation 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.
Python bindings are included in the standard
pip install mini-swe-agent install. No separate setup is required. For contributing or modifying source, follow the dev install in the quickstart.Hello world
The minimal example creates aDefaultAgent with a model and a local environment, then calls agent.run(task).
Choosing a model
You can select a model with automatic class resolution viaget_model, or instantiate a model class directly.
Return value of agent.run()
agent.run() returns the extra dict from the final exit message. It always contains at least two keys:
| Key | Type | Description |
|---|---|---|
exit_status | str | Why the agent stopped ("Submitted", "LimitsExceeded", etc.) |
submission | str | The agent’s final answer or output |
Accessing the full trajectory
Afteragent.run() returns, agent.messages contains the complete message history — every system prompt, user message, assistant response, and observation, in order.
Saving the trajectory to disk
agent.save(path) serializes the full trajectory (messages, config, cost stats, version) to a JSON file. It also returns the serialized data as a dict.
Cost and call tracking
DefaultAgent tracks cumulative cost and the number of model calls on the instance:
Choosing an environment
- LocalEnvironment
- DockerEnvironment
Executes bash commands directly on the host machine using You can pass
subprocess.run. Suitable for development and trusted workloads.cwd, timeout, or custom env vars: