Skip to content

Contribute to SWE-agent

Formatting change

We've recently added automated formatting to our code base. If you are dealing with merge-conflicts when opening a PR or updating your fork, please first install pre-commit and run pre-commit run --all-files and try again.

The easiest way to contribute is to give us feedback.

  • Something isn't working? Open a bug report. Rule of thumb: If you're running something and you get some error messages, this is the issue type for you.
  • You have a concrete question? Open a question issue.
  • You are missing something? Open a feature request issue
  • Open-ended discussion? Talk on discord. Note that all actionable items should be an issue though.

Wanna do more and actually contribute code? Great! Please see the following sections for tips and guidelines!

Development repository set-up

Please install the repository from source, following our usual instructions but add the [dev] option to the pip command (you can just run the command again):

pip install -e '.[dev]'

Then, make sure to set up pre-commit:

# cd to our repo root
pre-commit install

pre-commit will check for formatting and basic syntax errors before your commits.

Autofixes

Most problems (including formatting) will be automatically fixed. Therefore, if pre-commit/git commit fails on its first run, simply try running it a second time.

Some more autofixes can be enabled with the --unsafe-fixes option from ruff:

pipx run ruff check --fix --unsafe-fixes

Running tests

We provide a lot of tests that can be very helpful for rapid development. Run them with

pytest

Some of the tests might be slower than others. You can exclude them with

pytest -m "not slow"

You can run all tests in parallel with pytest-xdist:

pytest -n auto

If you are using VSCode, you might want to add the following two files:

.vscode/launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Debug Tests",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "purpose": ["debug-test"],
            "console": "integratedTerminal",
            "env": {
                "PYTEST_ADDOPTS": "--no-cov"
            },
            "justMyCode": false
        }
    ]
}
.vscode/settings.json
{
    "python.testing.pytestArgs": [
        "sweagent",
        "--cov=sweagent/",
        "--cov-report=xml:cov.xml",
        "-n", "auto",
        "tests"
    ],
    "python.testing.unittestEnabled": false,
    "python.testing.pytestEnabled": true,
    "git.ignoreLimitWarning": true
}

Debugging

We recommend to install pdbpp for some improved debugger features:

pip install pdbpp

Set breakpoints with breakpoint() and then run sweagent with pdb:

pdb -m sweagent <command> -- <more command line arguments> # (1)!
  1. Note the -- before the options passed to sweagent. This is to separate options passed to pdb from those that are passed to sweagent.

Tips for pull requests

  • If you see a lot of formatting-related merge conflicts, please see here.
  • Please open separate PRs for separate issues. This makes it easier to incorporate part of your changes.
  • It might be good to open an issue and discuss first before investing time on an experimental feature.
  • Don't know where to get started? Look for issues marked 👋 good first issue or 🙏 help wanted
  • When changing the behavior of the agent, we need to have some indication that it actually improves the success rate of SWE-agent. However, if you make the behavior optional without complicating SWE-agent (for example by providing new commands), we might be less strict.
  • Please add simple unit tests or integration tests wherever possible. Take a look in the tests directory for inspiration. We emphasize simple easy-tow-rite tests that get a lot of coverage.

Building the documentation

Simply run

# cd repo root
mkdocs serve

and point your browser to port 8000 or click one of the links in the output.

Diving into the code

  • Code structure and reference


    Read the reference for more information on our code.

    Read more