- mini-SWE-agent implements an AI software engineering agent that solves github issues and similar programming challenges
- The idea of this project is to write the simplest, smallest, most readable agent.
The project is structured as
minisweagent/__init__ # Protocols/interfaces for all base classes
minisweagent/agents # Agent control flow & loop
minisweagent/environments # Executing agent actions
minisweagent/models # LM interfaces
minisweagent/run # Run scripts that serve as an entry point- The project embraces polymorphism: Every individual class should be simple, but we offer alternatives
- Every use case should start with a run script, that picks one agent, environment, and model class to run
- Target python 3.10 or higher
- Use python with type annotations. Use
listinstead ofList. - Use
pathlibinstead ofos.path. UsePath.read_text()overwith ...open()constructs. - Use
typerto add interfaces - Keep code comments to a minimum and only highlight particularly logically challenging things
- Do not append to the README unless specifically requested
- Use
jinjafor formatting templates - Use
dataclassfor keeping track config - Do not catch exceptions unless explicitly told to.
- Write concise, short, minimal code.
- In most cases, avoid initializing variables just to pass them to a function. Instead just pass the expression to the function directly.
- Not every exception has to be caught. Exceptions are a good way to show problems to a user.
- This repository rewards minimal code. Try to be as concise as possible.
Here's an example for rule 11:
# bad
a = func()
Class(a)
# good
Class(func())- Use
pytest, notunittest. - Do not mock/patch anything that you're not explicitly asked to do
- Avoid writing trivial tests. Every test should test for at least one, preferably multiple points of failure
- Avoid splitting up code in multiple lines like this:
a=func()\n assert a=b. Instead, just doassert func() == b - The first argument to
pytest.mark.parametrizeshould be a tuple (not a string! not a list!), the second argument must be a list (not a tuple!).
Here's an example for rule 4:
# bad
result = func()
assert result == b
# good
assert func() == bUse the following format for commit messages:
ci: descriptionfor all testing related changes, and changes to github workflows etc.dev: descriptionfor development related changes, including updates to the cursor or claude rulesfix(component): descriptionfor bug fixesfeat(component): descriptionfor new featuresenh(component): descriptionfor enhancementsdocs: descriptionfor documentationref(component): descriptionfor refactoringchore: descriptionfor maintenance tasks (pre-commit hooks, imports, etc.)
Generally, the description should focus on the intent of the changes, not the implementation details.
Do NOT add "Co-authored-by: Cursor" lines to the commit message or to the trailer.
While preparing the commit message, flag critical issues that should be addressed before committing. Do not flag style issues or minor changes.
Flag the following:
- Anything that might raise an unhandled exception in an unintentional manner
- Anything that looks logically wrong or inconsistent
- Breaking changes to protocols/interfaces without corresponding updates to implementations
Flag the following style issue as minor:
- Imports not at top of file
Use these component names in parentheses for fix, feat, enh, and ref commits:
models- Changes to model interfaces (litellm, anthropic, openai, portkey, openrouter)agents- Changes to agent classes (default, interactive, multimodal)env- Changes to environments (docker, local, singularity, bubblewrap, swerex)config- Changes to configuration files or config handlingrun- Changes to run scripts (mini, hello_world)benchmarks- Changes to benchmark runners (swebench, inspector)cli- Changes to CLI argument handlingdeps- Dependency updates