SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]
Doc: Msot of the batch mode tutorial compelted
Kilian Lieret42fef0db3494
diff --git a/assets/batch_animated.gif b/assets/batch_animated.gifnew file mode 100644index 00000000..9007a6dbBinary files /dev/null and b/assets/batch_animated.gif differdiff --git a/docs/assets/batch_animated.gif b/docs/assets/batch_animated.gifnew file mode 100644index 00000000..9007a6dbBinary files /dev/null and b/docs/assets/batch_animated.gif differdiff --git a/docs/faq.md b/docs/faq.mdindex 9d196a4a..6e774c5e 100644--- a/docs/faq.md+++ b/docs/faq.md@@ -1,17 +1,22 @@# Frequently Asked Questions+> What models are supported?++Probably all of them! There's even a few for testing. See [models](../installation/keys.md).++> What's up with all the output files?++You're probably most interested in the `*.traj` files, which contain complete records of SWE-agent's thought process and actions. See [output files](usage/trajectories.md) for more information.+> How can I change the demonstrations given to SWE-agent?At the start of each run, we feed the agent a demonstration trajectory, showing it how to solve an example issue.This substantially improves the agent's abilities to solve novel issues.If you'd like to modify or totally change this demonstration, to better fit your use case, see [this](config/demonstrations.md).-> Does SWE-agent run on windows?--You can run it in a [docker container](installation/docker.md), though this is not our first-choice for running SWE-agent. SWE-agent runs best on Mac and Linux, as these are the environments we use for SWE-agent development.-We're open to merge simple fixes to make the [development setup](installation/source.md) work on Windows.+> Does SWE-agent run on Windows/MacOS/Linux?-> Which LMs do you support?+Yes! Your only limitation might be the availability of the docker containers for your environments.+But you can always execute SWE-agent in the cloud.-See [models](installation/keys.md).\ No newline at end of file+{% include-markdown "_footer.md" %}\ No newline at end of filediff --git a/docs/installation/keys.md b/docs/installation/keys.mdindex ee434b31..4e6cc75b 100644--- a/docs/installation/keys.md+++ b/docs/installation/keys.md@@ -20,9 +20,6 @@ Here's an exampleSee the following links for tutorials on obtaining [Anthropic](https://docs.anthropic.com/en/api/getting-started), [OpenAI](https://platform.openai.com/docs/quickstart/step-2-set-up-your-api-key), and [Github](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) tokens.-!!! tip "Models"- Some more information about the available models in our [usage FAQ](../usage/usage_faq.md).-### Models for testingWe also provide models for testing SWE-agent without spending any creditsdiff --git a/docs/reference/batch_instances.md b/docs/reference/batch_instances.mdnew file mode 100644index 00000000..06faebd0--- /dev/null+++ b/docs/reference/batch_instances.md@@ -0,0 +1,7 @@+::: sweagent.run.batch_instances+ options:+ members_order: source+ show_root_heading: false+ show_root_toc_entry: false+ show_source: false+ parameter_headings: false\ No newline at end of filediff --git a/docs/reference/run_batch_config.md b/docs/reference/run_batch_config.mdnew file mode 100644index 00000000..abc46cab--- /dev/null+++ b/docs/reference/run_batch_config.md@@ -0,0 +1 @@+::: sweagent.run.run_batch.RunBatchConfig\ No newline at end of filediff --git a/docs/usage/batch_mode.md b/docs/usage/batch_mode.mdnew file mode 100644index 00000000..b81cf7b0--- /dev/null+++ b/docs/usage/batch_mode.md@@ -0,0 +1,163 @@+# Batch mode++!!! abstract "Running on many issues at once"+ You have used `sweagent run`. To become a real power user, we'll convert you to `sweagent run-batch` and you can run on a hundred issues at once.++ * Please make sure you're familiar with [the command line basics](cl_tutorial.md).+ * The default examples will be executing code in a Docker sandbox, so make sure you have docker installed ([docker troubleshooting](../installation/tips.md)).+ If you cannot run docker, skim through the examples below and adapt accordingly.++## A first example: SWE-bench++So you've decided to run SWE-agent on a lot of issues in parallel. Great, the `run-batch` command is exactly here for that.+Let's run on three [SWE-bench](https://www.swebench.com/) issues which will be downloaded automatically.++```bash+sweagent run-batch \+ --config config/default.yaml \+ --agent.model.name gpt-4o \+ --agent.model.per_instance_cost_limit 2.00 \+ --instances.type swe_bench \ # (1)!+ --instances.subset lite \ # (2)!+ --instances.split dev \ # (3)!+ --instances.slice :3 \ # (4)!+ --instances.shuffle=True # (5)!+```++1. There's a couple of built-in ways to configure instances. This option selects the SWE-bench dataset.+2. There's a few datasets provided by the SWE-bench project. Lite is a subset of GitHub issues with a few heuristic filters that makes them more likely to be solvable.+3. Most datasets have a `dev` and a `test` split.+4. The `--slice` option allows you to select a subset of instances from the dataset. It works just the way to pythons `list[...]` slicing, so you can specify `:10` to take the first 10 instances, `10:20` to take the next 10, `-10:` to take the last 10, or `10:20:2` to take every second instance in that range.+5. Shuffle all instances before slicing.++* There's some things that you should recognize: All of the `--agent` options are available and you can still specify `--config` files.+* However, the `--problem_statement`, `--repo`, and `--env` options obviously need to change, because you now want to populate these settings automatically from a source.++This is where the new option comes in: `--instances`, specifying the **instance source** together with a few options.++!!! tip "Tooltips"+ Click on the :material-chevron-right-circle: icon in the right margin of the code snippet to see more information about the line.++The output should remind you a lot like the output of the [hello world tutorial](hello_world.md), except for the progress bar at the bottom.+Kind of slow, isn't it?+++!!! tip "All command line options"+ * See [`RunBatchConfig`](../reference/run_batch_config.md/#sweagent.run.run_batch.RunBatchConfig) for an overview of all options.+ * SWE-bench config: [`SWEBenchInstances`](../reference/batch_instances.md/#sweagent.run.batch_instances.SWEBenchInstances).++## Running in parallel++Let's speed things up and run on 5 instances at once. Only a single line to change:++```bash hl_lines="4-4"+sweagent run-batch \+ --config config/default.yaml \+ --agent.model.name gpt-4o \+ --num_workers 3 \+ --agent.model.per_instance_cost_limit 2.00 \+ --instances.type swe_bench \+ --instances.subset lite \+ --instances.split dev \+ --instances.slice :3 \+ --instances.shuffle=True+```++You'll see output that looks like this (only with 3 workers instead of 30):++<figure markdown="span">+{: style="max-width: 500px; border-radius: 10px;"}+<figcaption>SWE-Agent running on 30 SWE-bench instances</figcaption>+</figure>++!!! tip "All command line options"+ See [`RunBatchConfig`](../reference/run_batch_config.md/#sweagent.run.run_batch.RunBatchConfig) for an overview of all options.++## Loading instances from a file++```bash+sweagent run-batch \+ --config config/default.yaml \+ --agent.model.name gpt-4o \+ --instances.type file \+ --instances.path instances.yaml # (1)!+ --instances.slice :3 \+ --instances.shuffle=True+```++1. We support `.jsonl`, `.json`, and `.yaml` files.++Here'the simplest example of what such a file can look like++```yaml title="instances.yaml"+- image_name: "python:3.11" # (1)!+ problem_statement: "A simple test problem"+ id: "simple_test_problem"+- image_name: "python:3.11"+ problem_statement: "Another test problem"+ id: "simple_test_problem_2"+```++1. Must be available locally or on dockerhub.++!!! tip "More options"+ * There's a few more fields that you can populate. See [`SimpleBatchInstances`](../reference/batch_instances.md/#sweagent.run.batch_instances.SimpleBatchInstance) for more information.+ * For all command line options with this instance type, see [`InstancesFromFile`](../reference/batch_instances.md/#sweagent.run.batch_instances.InstancesFromFile).++## Huggingface instances++If you upload your dataset to Huggingface in a similar style as the example we just saw, you can load it like this:++```bash+sweagent run-batch \+ ...+ --instances.type huggingface \+ --instances.dataset_name "your_username/your_dataset" \+ --instances.split "dev" \+ --instances.slice :3 \+ --instances.shuffle=True+```++!!! tip "All instance options"+ See [`InstancesFromHuggingFace`](../reference/batch_instances.md/#sweagent.run.batch_instances.InstancesFromHuggingFace).++## Expert instances++If this is not enough for your use case, you can also specify a full set of `Environment`, `ProblemStatement`, and `Repository` config objects:++```bash+sweagent run-batch \+ ...+ --instances.type expert_file \+ --instances.path instances.yaml+```++where `instances.yaml` could look like this:++```yaml title="instances.yaml"+- env:+ deployment:+ type: docker+ image: python:3.11+ problem_statement:+ type: text+ text: "A simple test problem"+ id: "simple_test_problem"+ repo:+ type: github+ github_url: "https://github.com/swe-agent/test-repo"+- env:+ deployment:+ type: docker+ image: python:3.11+ problem_statement:+ type: text+ text: "A simple test problem 2"+ id: "simple_test_problem_2"+```++!!! tip "All instance options"+ See [`ExpertInstances`](../reference/batch_instances.md/#sweagent.run.batch_instances.ExpertInstancesFromFile).++## Output files and next steps+diff --git a/docs/usage/benchmarking.md b/docs/usage/benchmarking.mdindex 26b1a83d..876593cf 100644--- a/docs/usage/benchmarking.md+++ b/docs/usage/benchmarking.md@@ -1,6 +1,6 @@# Benchmarking-!!! note "Scope"+!!! abstract "Benchmarking on SWE-bench"This page talks about benchmarking on SWE-bench to measure the software engineering capabilities of SWE-agent.Benchmarking for the other modes (programming challenges, cybersecurity) are coming soon.diff --git a/docs/usage/hello_world.md b/docs/usage/hello_world.mdindex a93eeae2..8d89234c 100644--- a/docs/usage/hello_world.md+++ b/docs/usage/hello_world.md@@ -29,7 +29,7 @@ python run.py \1. This limits the inference cost per instance to $2. The default is $3.!!! tip "Annotations"- Notice the :material-chevron-right-circle: icon in the left margin in the code snippet? Click on it to display more information+ Notice the :material-chevron-right-circle: icon in the right margin in the code snippet? Click on it to display more informationabout the line.The example above uses the `gpt4` model from OpenAI. In order to use it, you need to add your OpenAI API key to the environment:diff --git a/mkdocs.yml b/mkdocs.ymlindex b13e17c9..f18e12a3 100644--- a/mkdocs.yml+++ b/mkdocs.yml@@ -64,8 +64,9 @@ nav:- "Command line basics": "usage/cl_tutorial.md"- "Solving coding challenges": "usage/coding_challenges.md"- "Trajectory inspector": "usage/inspector.md"+ - "Batch mode": "usage/batch_mode.md"- "Benchmarking": "usage/benchmarking.md"- - "FAQ": "usage/usage_faq.md"+ - "FAQ": "faq.md"- User Guides:- "usage/index.md"- Project overview:@@ -89,9 +90,12 @@ nav:- "Model config": "reference/model_config.md"- "Agent config": "reference/agent_config.md"- "Environment config": "reference/env_config.md"- - "Agent class": "reference/agent.md"- - "Environment class": "reference/env.md"- - "Exceptions": "reference/exceptions.md"+ - "Run batch": "reference/run_batch_config.md"+ - "Batch instances": "reference/batch_instances.md"+ - Classes:+ - "Agent class": "reference/agent.md"+ - "Environment class": "reference/env.md"+ - "Exceptions": "reference/exceptions.md"plugins:- glightbox- searchdiff --git a/sweagent/run/run_batch.py b/sweagent/run/run_batch.pyindex 4e0473ca..cebbd4c8 100644--- a/sweagent/run/run_batch.py+++ b/sweagent/run/run_batch.py@@ -14,7 +14,7 @@ sweagent run-batch \\--instances.type swe_bench \\ # configure instances--instances.subset lite \\--instances.split dev \\- --instances.split :50 \\ # first 50 instances+ --instances.slice :50 \\ # first 50 instances--instances.shuffle=True \\ # shuffle instances (with fixed seed)--config config/default.yaml \\ # configure model--agent.model.name gpt-4o