Skip to content

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: Move config docs to mkdocs

Kilian Lieret45c03b703f3e
diff --git a/.github/workflows/build-docs.yaml b/.github/workflows/build-docs.yaml
index a82fcc9c..28a61302 100644
--- a/.github/workflows/build-docs.yaml
+++ b/.github/workflows/build-docs.yaml
@@ -30,6 +30,6 @@ jobs:
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
- - run: uv pip install mkdocs-material
+ - run: uv pip install mkdocs-material mkdocs-glightbox
- run: mkdocs gh-deploy --force
diff --git a/config/README.md b/config/README.md
deleted file mode 100644
index 15a47005..00000000
--- a/config/README.md
+++ /dev/null
@@ -1,92 +0,0 @@
-# Configuration
-
-This folder contains details describing how to write your own configurations to control how agents can interact with the `SWEEnv` environment.
-A configuration is represented as a single `.yaml` file, allowing you to...
-* Define the **commands** that agents may use to traverse + modify a codebase.
-* Write **prompts** that are deterministically/conditionally shown to the agent over the course of a single trajectory.
-* Control the **input/output interface** that sits between the agent and `SWEEnv`.
-
-## Configuration File Fields
-The configuration is a `.yaml` file that consists of several fields. They are fully represented in this following outline:
-
-```yaml
-# Prompt Templates: Control how observations of environment are shown to agent
-system_template: | # .yaml syntax for multi-line string value
- First `system` message shown to agent
-instance_template: |- # .yaml syntax for multi-line string value w/ no new line
- Instance prompt, contains task instance-specific content
-next_step_template: |-
- Format template of per-turn observation (Contains standard output from agent's action)
-next_step_no_output_template: |-
- Format template of observation when there is no standard output from the agent's action
-format_error_template: |-
- Format template of error message (Used when agent's action causes an error)
-demonstration_template: |
- Format template for showing a demonstration to the agent
-demonstrations:
-- `trajectories/<username>/<experiment folder>/*.traj`
-- File is a demonstration of how to solve a task. This could an agent generated trajectory.
-- You can include 1+ demonstrations
-
-# Environment States: Define features of the SWEEnv environment
-env_variables:
-# Default variables for SWEEnv at the beginning of each instance
- CURRENT_FILE: 0
- CURRENT_LINE:
- OVERLAP:
- SEARCH_FILES:
- SEARCH_INDEX:
- SEARCH_RESULTS:
- WINDOW_SIZE:
- START_INDEX:
- END_INDEX:
- START_CURSOR:
- END_CUROSR:
- START_CURSORS_MARK:
- END_CURSOR_MARK:
-state_command: |
-# `state_command` allows you to update state variables to reflect any aspect of the environment (e.g. current working directory)
- name: state
- code: |
- state() { echo '{"pwd": "'$PWD'"}';
-
-# Action Interface: Define how an agent interacts with the SWEEnv environment
-command_files:
-- path/to/bash_file.sh
-- Each file contains a list of commands implemented in bash
-- You can include 1+ command files
-parse_command: Reference to functionality for defining command documentation
-history_processor: Reference to functionality for controlling agent's message history
-parse_function: Parser run on agent output
-```
-
-In this directory, we recommend looking at...
-* `configs/` for examples of properly formatted configuration files. Each configuration differs in its set of commands, input/output format, demonstrations, etc.
-* `commands/` for the bash implementations of the custom commands that SWE-agent uses to navigate + edit the codebase.
-
-## How a Configuration File is Processed
-Some notes on processing that occurs on config fields when SWE-agent is run:
-* Commands specified in `command_files` will be parsed into a single block of documentation text that can be referenced as `{command_docs}`.
-* `env_variables` are the default variables for the bash environment at the beginning of each instance.
-* `state_command` is used to extract state information from the bash environment (formatted as json) to be used in the templates given to the agent.
-
-Possible variables that can be used in templates are:
-- `{command_docs}` (an automatically compiled collection of available commands + their docstrings)
-- any variable given in `env_variables` (same spelling), e.g., `{WINDOW_SIZE}`
-- any variable extracted as json as part of the `state_command` function
-- the last observation `{observation}`
-- ... this list will grow as we implement more features!
-
-## Template Workflow
-The following diagram illustrates where each template is shown within a single episode of solving one task instance.
-
-<p align="center">
- <img src="../assets/template_workflow.png" alt="Template Workflow">
-</p>
-
-One of three templates can be shown per turn:
-* "Next Step" (`next_step_template`): Displayed if the model's action successfully runs. The output and a prompt for the next action is shown
-* "Next Step (No Output)" (`next_step_no_output_template`): Displayed if the model's action successfully runs, but does not produce any standard output (e.g. `rm`, `cd`)
-* "Format Error" (`format_error_template`): Displayed if the model's response is malformed. Over the next two turns...
- * If one of the model's next response is correct, the message history is updated such that the "Format Error" turn is not kept. The episode continues.
- * If the model's next two responses are both malformed, the episode terminates.
diff --git a/config/README.md b/config/README.md
new file mode 120000
index 00000000..abfccfaf
--- /dev/null
+++ b/config/README.md
@@ -0,0 +1 @@
+../docs/dev/config.md
\ No newline at end of file
diff --git a/docs/dev/config.md b/docs/dev/config.md
new file mode 100644
index 00000000..6232d30d
--- /dev/null
+++ b/docs/dev/config.md
@@ -0,0 +1,100 @@
+# Configuration
+
+This page contains details describing how to write your own configurations to control how agents can interact with the `SWEEnv` environment.
+
+A configuration is represented as a single `.yaml` file, specified by the `--config` flag in the [command line interface](../usage/cl_tutorial.md), allowing you to...
+
+* Define the **commands** that agents may use to traverse + modify a codebase.
+* Write **prompts** that are deterministically/conditionally shown to the agent over the course of a single trajectory.
+* Control the **input/output interface** that sits between the agent and `SWEEnv`.
+
+!!! tip "Default config files"
+ Our default config files are in the [`config/`](https://github.com/princeton-nlp/SWE-agent/tree/main/config) directory.
+
+## Configuration File Fields
+
+The configuration is a `.yaml` file that consists of several fields. They are fully represented in this following outline:
+
+```yaml
+# Prompt Templates: Control how observations of environment are shown to agent
+system_template: | # .yaml syntax for multi-line string value
+ First `system` message shown to agent
+instance_template: |- # .yaml syntax for multi-line string value w/ no new line
+ Instance prompt, contains task instance-specific content
+next_step_template: |-
+ Format template of per-turn observation (Contains standard output from agent's action)
+next_step_no_output_template: |-
+ Format template of observation when there is no standard output from the agent's action
+format_error_template: |-
+ Format template of error message (Used when agent's action causes an error)
+demonstration_template: |
+ Format template for showing a demonstration to the agent
+demonstrations:
+- `trajectories/<username>/<experiment folder>/*.traj`
+- File is a demonstration of how to solve a task. This could an agent generated trajectory.
+- You can include 1+ demonstrations
+
+# Environment States: Define features of the SWEEnv environment
+env_variables:
+# Default variables for SWEEnv at the beginning of each instance
+ CURRENT_FILE: 0
+ CURRENT_LINE:
+ OVERLAP:
+ SEARCH_FILES:
+ SEARCH_INDEX:
+ SEARCH_RESULTS:
+ WINDOW_SIZE:
+ START_INDEX:
+ END_INDEX:
+ START_CURSOR:
+ END_CUROSR:
+ START_CURSORS_MARK:
+ END_CURSOR_MARK:
+state_command: |
+# `state_command` allows you to update state variables to reflect any aspect of the environment (e.g. current working directory)
+ name: state
+ code: |
+ state() { echo '{"pwd": "'$PWD'"}';
+
+# Action Interface: Define how an agent interacts with the SWEEnv environment
+command_files:
+- path/to/bash_file.sh
+- Each file contains a list of commands implemented in bash
+- You can include 1+ command files
+parse_command: Reference to functionality for defining command documentation
+history_processor: Reference to functionality for controlling agent's message history
+parse_function: Parser run on agent output
+```
+
+In this directory, we recommend looking at...
+* `configs/` for examples of properly formatted configuration files. Each configuration differs in its set of commands, input/output format, demonstrations, etc.
+* `commands/` for the bash implementations of the custom commands that SWE-agent uses to navigate + edit the codebase.
+
+## How a Configuration File is Processed
+Some notes on processing that occurs on config fields when SWE-agent is run:
+
+* Commands specified in `command_files` will be parsed into a single block of documentation text that can be referenced as `{command_docs}`.
+* `env_variables` are the default variables for the bash environment at the beginning of each instance.
+* `state_command` is used to extract state information from the bash environment (formatted as json) to be used in the templates given to the agent.
+
+Possible variables that can be used in templates are:
+- `{command_docs}` (an automatically compiled collection of available commands + their docstrings)
+- any variable given in `env_variables` (same spelling), e.g., `{WINDOW_SIZE}`
+- any variable extracted as json as part of the `state_command` function
+- the last observation `{observation}`
+- ... this list will grow as we implement more features!
+
+## Template Workflow
+The following diagram illustrates where each template is shown within a single episode of solving one task instance.
+
+<p align="center">
+ <img src="/assets/readme_assets/template_workflow.png" alt="Template Workflow">
+</p>
+
+One of three templates can be shown per turn:
+
+* "Next Step" (`next_step_template`): Displayed if the model's action successfully runs. The output and a prompt for the next action is shown
+* "Next Step (No Output)" (`next_step_no_output_template`): Displayed if the model's action successfully runs, but does not produce any standard output (e.g. `rm`, `cd`)
+* "Format Error" (`format_error_template`): Displayed if the model's response is malformed. Over the next two turns...
+ * If one of the model's next response is correct, the message history is updated such that the "Format Error" turn is not kept. The episode continues.
+ * If the model's next two responses are both malformed, the episode terminates.
diff --git a/docs/dev.md b/docs/dev/contribute.md
similarity index 100%
rename from docs/dev.md
rename to docs/dev/contribute.md
diff --git a/docs/modify.md b/docs/dev/modify.md
similarity index 85%
rename from docs/modify.md
rename to docs/dev/modify.md
index b58eedd5..422c4fc1 100644
--- a/docs/modify.md
+++ b/docs/dev/modify.md
@@ -1,13 +1,9 @@
# Modifying the behavior of SWE-agent
-## Code structure
+## Changing prompts and other configuration
-* See the [`scripts/`](https://github.com/princeton-nlp/SWE-agent/tree/main/scripts/) folder for other useful scripts and details.
-* See the [`config/`](https://github.com/princeton-nlp/SWE-agent/tree/main/config/) folder for details about how you can define your own configuration!
-* See the [`sweagent/agent/`](https://github.com/princeton-nlp/SWE-agent/tree/main/sweagent/agent/) folder for details about the logic behind configuration based workflows.
-* See the [`sweagent/environment/`](https://github.com/princeton-nlp/SWE-agent/tree/main/sweagent/environment/) folder for details about the `SWEEnv` environment (interface + implementation).
-* See the [`trajectories/`](https://github.com/princeton-nlp/SWE-agent/tree/main/trajectories) folder for details about the output of `run.py`.
-* See the [`evaluation/`](https://github.com/princeton-nlp/SWE-agent/tree/main/evaluation/) folder for details about how evaluation works.
+The easiest way to modify the behavior of SWE-agent is to change prompts and similar settings.
+This can be done using the config files. See [here](config.md) for more information.
## Changing the demonstrations
@@ -18,4 +14,13 @@ To edit text in ```human``` mode:
1. Run the command ```edit edit_start_line:edit_end_line```
2. Write the text you want to insert. Feel free to write the text across multiple lines.
-3. Press ```return``` then write ```end_of_edit``` and then press ```return``` again to submit the edit.
\ No newline at end of file
+3. Press ```return``` then write ```end_of_edit``` and then press ```return``` again to submit the edit.
+
+## Code structure
+
+* See the [`scripts/`](https://github.com/princeton-nlp/SWE-agent/tree/main/scripts/) folder for other useful scripts and details.
+* See the [`config/`](https://github.com/princeton-nlp/SWE-agent/tree/main/config/) folder for details about how you can define your own configuration!
+* See the [`sweagent/agent/`](https://github.com/princeton-nlp/SWE-agent/tree/main/sweagent/agent/) folder for details about the logic behind configuration based workflows.
+* See the [`sweagent/environment/`](https://github.com/princeton-nlp/SWE-agent/tree/main/sweagent/environment/) folder for details about the `SWEEnv` environment (interface + implementation).
+* See the [`trajectories/`](https://github.com/princeton-nlp/SWE-agent/tree/main/trajectories) folder for details about the output of `run.py`.
+* See the [`evaluation/`](https://github.com/princeton-nlp/SWE-agent/tree/main/evaluation/) folder for details about how evaluation works.
diff --git a/docs/usage/cl_tutorial.md b/docs/usage/cl_tutorial.md
index d38390f3..05539f1d 100644
--- a/docs/usage/cl_tutorial.md
+++ b/docs/usage/cl_tutorial.md
@@ -22,7 +22,7 @@ Here,
* `--model_name` sets the language model that is used by SWE-agent (with `gpt4` being the default). More information on the available models in our [FAQ](faq.md)
* `--data_path` points to the source of the *problem statement* (for example, the GitHub issue that you want to solve). You can also point it to local files (see [below](#specifying-the-repository))
-* `--config_file` includes settings such as the prompts. Changing the config file is the easiest way to get started with modifying SWE-agent (more advanced options are discussed [here](../modify.md)).
+* `--config_file` includes settings such as the prompts. Changing the config file is the easiest way to get started with modifying SWE-agent (more advanced options are discussed [here](../dev/config.md)).
* `--per_instance_cost_limit` limits the total inference cost to $2 (default is $3).
!!! tip "All options"
diff --git a/docs/usage/web_ui.md b/docs/usage/web_ui.md
index 667b2e66..4232811e 100644
--- a/docs/usage/web_ui.md
+++ b/docs/usage/web_ui.md
@@ -8,7 +8,8 @@ To start our web UI, simply run
from the root of the repository.
-If the user interface doesn't automatically open in your browser, please open it at `http://localhost:3000`.
+If the user interface doesn't automatically open in your browser, please open it at `http://localhost:3000`.
+Running from GitHub codespaces? More tips [here](../installation/codespaces.md#running-the-web-ui).
!!! warning "Limitations"
Currently, the web interface only has a subset of the options of the command line interface (CLI).
\ No newline at end of file
diff --git a/mkdocs.yml b/mkdocs.yml
index 9008f9f3..752b819d 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -51,9 +51,12 @@ nav:
- "FAQ": "usage/faq.md"
- "Benchmarking": "usage/benchmarking.md"
- Development:
- - "Modifying swe-agent": "modify.md"
- - "Contribution guide": "dev.md"
+ - "Modifying swe-agent": "dev/modify.md"
+ - "Config files": "dev/config.md"
+ - "Contribution guide": "dev/dev.md"
+plugins:
+ - glightbox
repo_url: https://github.com/princeton-nlp/SWE-agent
repo_name: princeton-nlp/SWE-agent