Nano SWE Agent

2.2.8 · active · verified Sat Apr 11

mini-SWE-agent is a minimalist yet powerful AI software engineering agent, designed to solve GitHub issues and assist in command-line tasks. It's built on a radically simple 100-line Python core, primarily leveraging bash for actions and supporting various models via LiteLLM. Widely adopted by institutions like Meta and Stanford, it focuses on performance, deployability across different environments (local, Docker), and is actively developed with frequent updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize and run a `DefaultAgent` using a LiteLLM-compatible model (like OpenAI's GPT models) within a `LocalEnvironment`. The agent is tasked with writing a Python function and its tests. Ensure your LLM API key and preferred model name are set, either directly or via environment variables.

import os
from minisweagent.agents.default import DefaultAgent
from minisweagent.models.litellm_model import LitellmModel
from minisweagent.environments.local import LocalEnvironment

# Set your LLM API key and model name
os.environ["OPENAI_API_KEY"] = os.environ.get("MINI_SWE_AGENT_OPENAI_KEY", "sk-YOUR_OPENAI_KEY")
model_name = os.environ.get("MINI_SWE_AGENT_MODEL_NAME", "gpt-4o-mini") # Or "claude-3-sonnet", etc.

agent = DefaultAgent(
    LitellmModel(model_name=model_name),
    LocalEnvironment(),
)

task = "Write a Python function to calculate the nth Fibonacci number, with tests."
result = agent.run(task)

print(f"Agent finished with status: {result.get('exit_status')}")
print(f"Submission: {result.get('submission')}")

view raw JSON →