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: Tiles, config sections

Kilian Lieretfb72afdc1a46
diff --git a/docs/background/architecture.md b/docs/background/architecture.md
index 67a3a443..6560762d 100644
--- a/docs/background/architecture.md
+++ b/docs/background/architecture.md
@@ -1,5 +1,8 @@
# Architecture
+!!! warning "Out of date"
+ This page is a bit out of date for SWE-agent 1.0.0. We're working on it!
+
This page walks you through the general architecture of the SWE-agent package. Want to just run it? Jump ahead to the [installation](../installation/index.md) or [usage](../usage/index.md) sections.
![architecture](../assets/architecture.png)
diff --git a/docs/config/config.md b/docs/config/config.md
index e9627c45..7380c4af 100644
--- a/docs/config/config.md
+++ b/docs/config/config.md
@@ -1,8 +1,11 @@
# Configuration
+!!! warning "Under construction"
+ This section is under construction. SWE-agent 1.0.0 is much more flexible, but that also means that we need to cover more ground here.
+
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...
+A configuration is represented in one or more `.yaml` files, 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 (see [here](commands.md) for more details)
* Write **prompts** that are deterministically/conditionally shown to the agent over the course of a single trajectory.
@@ -11,103 +14,19 @@ A configuration is represented as a single `.yaml` file, specified by the `--con
!!! 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 the [`config/`](https://github.com/princeton-nlp/SWE-agent/tree/main/config) directory, we recommend looking at...
-
-* [`configs/`](https://github.com/princeton-nlp/SWE-agent/tree/main/config/) for examples of properly formatted configuration files. Each configuration differs in its set of commands, input/output format, demonstrations, etc.
-* [`commands/`](https://github.com/princeton-nlp/SWE-agent/tree/main/config/commands) for the bash implementations of the custom commands that SWE-agent uses to navigate + edit the codebase. More information [here](commands.md).
+## Example configuration
-!!! hint "Relative paths"
- Relative paths in config files are resolved to the `SWE_AGENT_CONFIG_ROOT` environment variable (if set)
- or the SWE-agent repository root.
+This is the current default:
<details>
<summary><code>default_from_url.yaml</code></summary>
-```yaml
+```yaml title="config/default_from_url.yaml"
--8<-- "config/default_from_url.yaml"
```
</details>
-## 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.
-
-![template workflow](../assets/template_workflow.png)
-
-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.
+!!! hint "Relative paths"
+ Relative paths in config files are resolved to the `SWE_AGENT_CONFIG_ROOT` environment variable (if set)
+ or the SWE-agent repository root.
-{% include-markdown "../_footer.md" %}
\ No newline at end of file
diff --git a/docs/config/demonstrations.md b/docs/config/demonstrations.md
index 6b1d8de3..24017fb8 100644
--- a/docs/config/demonstrations.md
+++ b/docs/config/demonstrations.md
@@ -1,25 +1,28 @@
# Changing the demonstrations
+!!! warning "Under construction"
+ We're in the process of updating this page to reflect SWE-agent 1.0.0.
+
An important way to show LMs how to use commands and interact with the environment is through providing a demonstration - which is basically a completed [trajectory](../usage/trajectories.md) that the LM can learn from.
-For simplicity we only ingest demonstrations in the from of a trajectory file. However, since trajectory files are usually JSON, you can convert them to yaml using the `make_demos/convert_traj_to_demo.py` script to be more human-readable and easier to edit.
+For simplicity we only ingest demonstrations in the from of a trajectory file. However, since trajectory files are usually JSON, you can convert them to yaml using the `sweagent traj-to-demo` command to be more human-readable and easier to edit.
-Demo (yaml) files are stored in the `make_demos/demos` directory by default and consist primarily of the sequence of actions that an LM would need to take to complete a task. It's important that your demo have the proper format to be parsed by SWE-agent and your config.
+Demo (yaml) files are stored in the `demos/` directory by default and consist primarily of the sequence of actions that an LM would need to take to complete a task. It's important that your demo have the proper format to be parsed by SWE-agent and your config.
## Manually creating a custom trajectory <a name="manual"></a>
-You can manually generate a trajectory by running the agent with `--model_name human_thought`.
+You can manually generate a trajectory by running the agent with `--agent.model.name=human_thought`.
This lets you input, at each turn, the thought (ending with END_THOUGHT) and then the action (a single command).
You should then convert that trajectory into a demonstration as shown below.
-To edit text in `human_thought` mode:
+To edit text in `human_thought` mode with the traditional line-based editor:
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.
-If you would like to run `human_thought` mode without having to type in a thought at each turn (for debugging for example), use `--model_name human`.
+If you would like to run `human_thought` mode without having to type in a thought at each turn (for debugging for example), use `--agent.model.name=human`.
## Converting an existing trajectory into a demonstration
@@ -28,10 +31,10 @@ Here's how you can make a demo from an existing trajectory file (like the one cr
1. Find a basic trajectory that you already like and want to use as the basis for your demo.
For instance, consider the `.traj` files in the [`trajectories/demonstrations/` folder](https://github.com/princeton-nlp/SWE-agent/tree/main/trajectories/demonstrations)
or find the trajectory from the previous step (the path will be printed at the bottom).
-2. Run `python convert_traj_to_demo.py <path to trajectory file.traj>` to convert the trajectory to a demo.
- This demo will be saved as a readable yaml file in the `make_demos/demos` directory.
+2. Run `sweagent traj-to-demo --traj_path<path to trajectory file.traj>` to convert the trajectory to a demo.
+ This demo will be saved as a readable yaml file in the `demos/` directory.
3. Edit the demo by hand to make it work for your particular use case and configuration.
-4. (Optional) Run `python run_replay.py --traj_path <path to demo> --config_file <path to config file>` to execute the actions of the demo, have the system generate the execution output, and ensure that it works as expected.
+4. (Optional) Run `sweagent run-replay --traj_path <path to demo>` to execute the actions of the demo, have the system generate the execution output, and ensure that it works as expected.
5. Inspect the resulting trajectory to ensure it was executed correctly.
6. Specify the path to your demonstration in your [config file](config.md)
diff --git a/docs/config/index.md b/docs/config/index.md
new file mode 120000
index 00000000..3dc87373
--- /dev/null
+++ b/docs/config/index.md
@@ -0,0 +1 @@
+config.md
\ No newline at end of file
diff --git a/docs/config/templates.md b/docs/config/templates.md
new file mode 100644
index 00000000..f46ef763
--- /dev/null
+++ b/docs/config/templates.md
@@ -0,0 +1,20 @@
+
+## Configuring templates
+
+The following diagram illustrates where each template is shown within a single episode of solving one task instance.
+
+![template workflow](../assets/template_workflow.png)
+
+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.
+
+!!! tip "All options"
+ See the [template reference](../reference/agent_config.md#sweagent.agent.agents.TemplateConfig) for all options.
+
+{% include-markdown "../_footer.md" %}
+
diff --git a/docs/index.md b/docs/index.md
index a6b24ab6..b13a3d30 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -6,20 +6,17 @@ title: "Getting Started"
<img src="assets/readme_assets/swe-agent-banner.png" alt="SWE-agent banner" style="height: 12em;">
</div>
-SWE-agent is an open-source platform for deploying language model (LM) agents in isolated computer environments.
-It manages an LM of your choice (e.g. GPT-4o, Claude Sonnet 3.5, or a local LM) to autonomously perform tasks within these environments using customizable [agent-computer interfaces](https://arxiv.org/abs/2405.15793) (ACIs).
+SWE-agent lets your language model of choice (e.g. GPT-4o or Claude Sonnet 3.5) autonomously use tools to:
-Use SWE-agent to: [fix issues in real GitHub repositories](background#swe-agent), perform tasks on the web, and solve your own custom tasks!
+* [fix issues in real GitHub repositories](usage/hello_world.md),
+* perform tasks on the web,
+* crack cybersecurity challenges, or
+* [any custom task](usage/coding_challenges.md).
-<div class="grid cards" markdown>
-
-- :material-book:{ .lg .middle } __Background & goals__
+It does so by using configurable [agent-computer interfaces](https://arxiv.org/abs/2405.15793) (ACIs) to interact with isolated computer environments.
- ---
-
- Learn more about the project goals and academic research.
+<div class="grid cards" markdown>
- [:octicons-arrow-right-24: Learn more](background/index.md)
- :material-download:{ .lg .middle } __Installation__
@@ -31,30 +28,30 @@ Use SWE-agent to: [fix issues in real GitHub repositories](background#swe-agent)
[:octicons-arrow-right-24: Get started](installation/index.md)
-- :material-cog:{ .lg .middle } __Configuration__
+- :material-cog:{ .lg .middle } __Hello world__
---
- SWE-agent can be tweaked extensively without modifying the code.
+ Solve a GitHub issue with SWE-agent.
- [:octicons-arrow-right-24: Modify SWE-agent behavior](usage/index.md)
+ [:octicons-arrow-right-24: Hello world](usage/hello_world.md)
-- :material-lightbulb:{ .lg .middle } __Development__
+- :material-lightbulb:{ .lg .middle } __User guides__
---
- Dig into SWE-agent's code and build your own agent!
+ Dive deeper into SWE-agent's features and goals.
- [:octicons-arrow-right-24: Development information](reference/index.md)
+ [:octicons-arrow-right-24: User guides](usage/index.md)
-- :material-newspaper:{ .lg .middle } __Changelog__
+- :material-book:{ .lg .middle } __Background & goals__
---
- See what's new in SWE-agent.
+ Learn more about the project goals and academic research.
- [:octicons-arrow-right-24: Read the changelog](installation/changelog.md)
+ [:octicons-arrow-right-24: Learn more](background/index.md)
</div>
diff --git a/docs/usage/index.md b/docs/usage/index.md
index 61adfde8..3fa6b466 100644
--- a/docs/usage/index.md
+++ b/docs/usage/index.md
@@ -1,23 +1,24 @@
-# Usage
+# User guides
-We currently provide two interfaces to SWE-agent:
+This part of the documentation covers more details about configuring and developing SWE-agent.
+Just want to run it? See [getting started](../index.md) instead!
<div class="grid cards" markdown>
-- :material-keyboard:{ .lg .middle } __Command line interface (CLI)__
+- :material-book:{ .lg .middle } __Background & goals__
---
- The default way of running SWE-agent with maximum options.
+ Learn more about the project goals and academic research.
- [:octicons-arrow-right-24: Get started](cl_tutorial.md)
+ [:octicons-arrow-right-24: Learn more](../background/index.md)
-- :material-mouse:{ .lg .middle } __Graphical user interface__
+- :material-cog:{ .lg .middle } __Configuration__
---
- We provide a browser-based graphical user interface particularly optimized for developers wanting to use SWE-agent as a tool.
+ How to configure SWE-agent.
- [:octicons-arrow-right-24: Get started](web_ui.md)
+ [:octicons-arrow-right-24: Configuration](../config/config.md)
</div>
diff --git a/docs/usage/migration.md b/docs/usage/migration.md
new file mode 100644
index 00000000..4d2b61fe
--- /dev/null
+++ b/docs/usage/migration.md
@@ -0,0 +1,25 @@
+## SWE-agent 1.0.0 migration guide
+
+Welcome to the new SWE-agent! Everything has changed -- hopefully for the better!
+
+If you're familiar with the old SWE-agent, here are the main changes you need to be aware of
+
+## Command line interface and basic configuration
+
+* Instead of the `run.py` script, we now have a central `sweagent` entry point that you can call after installing the package.
+ This should be much more convenient!
+* Instead of one `run.py` command, we now have several subcommands: `sweagent run` to run over single issues, `sweagent run-batch` to run over a whole batch of issues, and various utility commands. Run `sweagent --help` to see all options. Splitting up both commands made it easier to make both use cases more convenient and flexible.
+* We have switched to a hierarchical configuration system. This means that command line options look something like this: `--agent.model.name=gpt-4o`.
+ The configuration files have also been updated to reflect this.
+
+## More advanced configuration
+
+* Tools now live in tool bundles in the `tools/` directory. You can mix and match tools to your liking.
+
+## Code
+
+The codebase has been nearly rewritten from scratch and both more powerful and more flexible.
+
+* The biggest change is [SWE-ReX](https://github.com/swe-agent/SWE-ReX), our new "backend" that handles all code execution.
+* As a result of this, the `SWEEnv` class is basically gone and only is a small wrapper around a `swerex` runtime
+* The `Agent` class also has gotten a lot simpler. It also delegates a lot of tool/execution logic to the new `Tools` class.
diff --git a/mkdocs.yml b/mkdocs.yml
index f8148449..495fec72 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -73,10 +73,12 @@ nav:
- "index": "background/index.md"
- "Architecture": "background/architecture.md"
- "Agent tools": "background/aci.md"
- - "Interactive agent tools": "background/iat.md"
+ # - "Interactive agent tools": "background/iat.md"
- "Output files": "usage/trajectories.md"
- - "Configuration":
+ - Configuration:
+ - "index": "config/index.md"
- "Config files": "config/config.md"
+ - "Templates": "config/templates.md"
- "Demonstrations": "config/demonstrations.md"
- Development:
- "Contribution guide": "dev/contribute.md"