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]
Tools: Split out registry as separate bundle
Kilian Lieret5c25314f4797
diff --git a/config/coding_challenge.yaml b/config/coding_challenge.yamlindex 8b093e8c..fa4e1a9c 100644--- a/config/coding_challenge.yaml+++ b/config/coding_challenge.yaml@@ -1,111 +1,97 @@#This is the template you should use when using SWE-agent to solve a coding challenge (i.e. LeetCode).-#To run, use:-# python run.py \-# --data_path ~/problem.md \-# --repo_path ~/empty_repo \-# --config_file config/coding_challenge.yaml-#Where ~/empty_repo is a git repo that contains a single empty file called main.py (see https://github.com/SWE-agent/empty_repo )-#and problem.md contains the problem you'd like SWE-agent to try and solve.+agent:+ templates:+ system_template: |-+ SETTING: You are an autonomous programmer, and you're working directly in the command line with a special interface.-system_template: |-- SETTING: You are an autonomous programmer, and you're working directly in the command line with a special interface.+ The special interface consists of a file editor that shows you {{WINDOW}} lines of a file at a time.+ In addition to typical bash commands, you can also use the following commands to help you navigate and edit files.- The special interface consists of a file editor that shows you {{WINDOW}} lines of a file at a time.- In addition to typical bash commands, you can also use the following commands to help you navigate and edit files.+ COMMANDS:+ {{command_docs}}- COMMANDS:- {{command_docs}}+ Please note that THE EDIT COMMAND REQUIRES PROPER INDENTATION.+ If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.- Please note that THE EDIT COMMAND REQUIRES PROPER INDENTATION.- If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.+ RESPONSE FORMAT:+ Your shell prompt is formatted as follows:+ (Open file: <path>) <cwd> $- RESPONSE FORMAT:- Your shell prompt is formatted as follows:- (Open file: <path>) <cwd> $+ You need to format your output using two fields; discussion and command.+ Your output should always include _one_ discussion and _one_ command field EXACTLY as in the following example:+ DISCUSSION+ First I'll start by using ls to see what files are in the current directory. Then maybe we can look at some relevant files to see what they look like.+ ```+ ls -a+ ```- You need to format your output using two fields; discussion and command.- Your output should always include _one_ discussion and _one_ command field EXACTLY as in the following example:- DISCUSSION- First I'll start by using ls to see what files are in the current directory. Then maybe we can look at some relevant files to see what they look like.- ```- ls -a- ```+ You should only include a *SINGLE* command in the command section and then wait for a response from the shell before continuing with more discussion and commands. Everything you include in the DISCUSSION section will be saved for future reference.+ If you'd like to issue two commands at once, PLEASE DO NOT DO THAT! Please instead first submit just the first command, and then after receiving a response you'll be able to issue the second command.+ You're free to use any other bash commands you want (e.g. find, grep, cat, ls, cd) in addition to the special commands listed above.+ However, the environment does NOT support interactive session commands (e.g. python, vim), so please do not invoke them.+ instance_template: |-+ We're currently attempting to solve the following problem:+ ISSUE:+ {{issue}}- You should only include a *SINGLE* command in the command section and then wait for a response from the shell before continuing with more discussion and commands. Everything you include in the DISCUSSION section will be saved for future reference.- If you'd like to issue two commands at once, PLEASE DO NOT DO THAT! Please instead first submit just the first command, and then after receiving a response you'll be able to issue the second command.- You're free to use any other bash commands you want (e.g. find, grep, cat, ls, cd) in addition to the special commands listed above.- However, the environment does NOT support interactive session commands (e.g. python, vim), so please do not invoke them.-instance_template: |-- We're currently attempting to solve the following problem:- ISSUE:- {{issue}}+ INSTRUCTIONS:+ Now, you're going to solve this issue on your own. Your terminal session has started and you're in the repository's root directory. You can use any bash commands or the special interface to help you. Edit all the files you need to and run any checks or tests that you want.+ Remember, YOU CAN ONLY ENTER ONE COMMAND AT A TIME. You should always wait for feedback after every command.+ When you're satisfied with all of the changes you've made, you can submit your changes to the code base by simply running the submit command.+ Note however that you cannot use any interactive session commands (e.g. python, vim) in this environment, but you can write scripts and run them. E.g. you can write a python script and then run it with `python <script_name>.py`.- INSTRUCTIONS:- Now, you're going to solve this issue on your own. Your terminal session has started and you're in the repository's root directory. You can use any bash commands or the special interface to help you. Edit all the files you need to and run any checks or tests that you want.- Remember, YOU CAN ONLY ENTER ONE COMMAND AT A TIME. You should always wait for feedback after every command.- When you're satisfied with all of the changes you've made, you can submit your changes to the code base by simply running the submit command.- Note however that you cannot use any interactive session commands (e.g. python, vim) in this environment, but you can write scripts and run them. E.g. you can write a python script and then run it with `python <script_name>.py`.+ NOTE ABOUT THE EDIT COMMAND: Indentation really matters! When editing a file, make sure to insert appropriate indentation before each line!- NOTE ABOUT THE EDIT COMMAND: Indentation really matters! When editing a file, make sure to insert appropriate indentation before each line!+ IMPORTANT TIPS:+ 1. Write your solution in main.py. Always test your code thoroughly before submitting, and if any of the tests fail, try to fix the code before continuing.- IMPORTANT TIPS:- 1. Write your solution in main.py. Always test your code thoroughly before submitting, and if any of the tests fail, try to fix the code before continuing.+ 2. If you run a command and it doesn't work, try running a different command. A command that did not work once will not work the second time unless you modify it!- 2. If you run a command and it doesn't work, try running a different command. A command that did not work once will not work the second time unless you modify it!+ 3. If you open a file and need to get to an area around a specific line that is not in the first 100 lines, say line 583, don't just use the scroll_down command multiple times. Instead, use the goto 583 command. It's much quicker.- 3. If you open a file and need to get to an area around a specific line that is not in the first 100 lines, say line 583, don't just use the scroll_down command multiple times. Instead, use the goto 583 command. It's much quicker.+ 4. Always make sure to look at the currently open file and the current working directory (which appears right after the currently open file). The currently open file might be in a different directory than the working directory! Note that some commands, such as 'create', open files, so they might change the current open file.- 4. Always make sure to look at the currently open file and the current working directory (which appears right after the currently open file). The currently open file might be in a different directory than the working directory! Note that some commands, such as 'create', open files, so they might change the current open file.+ 5. When editing files, it is easy to accidentally specify a wrong line number or to write code with incorrect indentation. Always check the code after you issue an edit to make sure that it reflects what you wanted to accomplish. If it didn't, issue another command to fix it.- 5. When editing files, it is easy to accidentally specify a wrong line number or to write code with incorrect indentation. Always check the code after you issue an edit to make sure that it reflects what you wanted to accomplish. If it didn't, issue another command to fix it.-- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-next_step_template: |-- {{observation}}- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-next_step_no_output_template: |-- Your command ran successfully and did not produce any output.- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-demonstration_template: |- Here is a demonstration of how to correctly accomplish this task.- It is included to show you how to correctly use the interface.- You do not need to follow exactly what is done in the demonstration.- --- DEMONSTRATION ---- {{demonstration}}- --- END OF DEMONSTRATION ----state_command:- name: state- code: |- state() {{- local working_dir="$PWD";- if [ -z "$CURRENT_FILE" ]; then- echo '{{"open_file": "n/a", "working_dir": "'$working_dir'"}}';- else- echo '{{"open_file": "'$(realpath "$CURRENT_FILE")'", "working_dir": "'$working_dir'"}}';- fi- }};-parse_function: ThoughtActionParser-env_variables:- WINDOW: 100- OVERLAP: 2- CURRENT_LINE: 0- CURRENT_FILE: ""- SEARCH_RESULTS: ()- SEARCH_FILES: ()- SEARCH_INDEX: 0-command_files:- - config/commands/defaults.sh- - config/commands/search.sh- - config/commands/edit_linting.sh- - config/commands/_split_string.py+ (Open file: {{open_file}})+ (Current directory: {{working_dir}})+ bash-$+ next_step_template: |-+ {{observation}}+ (Open file: {{open_file}})+ (Current directory: {{working_dir}})+ bash-$+ next_step_no_output_template: |-+ Your command ran successfully and did not produce any output.+ (Open file: {{open_file}})+ (Current directory: {{working_dir}})+ bash-$+ demonstration_template: |+ Here is a demonstration of how to correctly accomplish this task.+ It is included to show you how to correctly use the interface.+ You do not need to follow exactly what is done in the demonstration.+ --- DEMONSTRATION ---+ {{demonstration}}+ --- END OF DEMONSTRATION ---+ demonstrations:+ - trajectories/demonstrations/human_thought__swe-bench-HumanEvalFix-python__lcb__t-0.00__p-0.95__c-4.00__install-0/humanevalfix-python-0.traj+tools:+ env_variables:+ WINDOW: 100+ OVERLAP: 2+ CURRENT_LINE: 0+ CURRENT_FILE: ""+ SEARCH_RESULTS: ()+ SEARCH_FILES: ()+ SEARCH_INDEX: 0+ bundles:+ - path: tools/registry+ - path: tools/defaults+ - path: tools/search+ - path: tools/edit_replace+ - path: tools/submit+ parse_function:+ type: thought_actionhistory_processors:- type: last_n_observationsn: 5-demonstrations:- - trajectories/demonstrations/human_thought__swe-bench-HumanEvalFix-python__lcb__t-0.00__p-0.95__c-4.00__install-0/humanevalfix-python-0.trajdiff --git a/config/default.yaml b/config/default.yamlindex 1eeb5815..b13ec45e 100644--- a/config/default.yaml+++ b/config/default.yaml@@ -112,6 +112,7 @@ agent:WINDOW: 100OVERLAP: 2bundles:+ - path: tools/registry- path: tools/defaults- path: tools/search# - path: tools/edit_lintingdiff --git a/config/default_ctf.yaml b/config/default_ctf.yamldeleted file mode 100644index 026857e0..00000000--- a/config/default_ctf.yaml+++ /dev/null@@ -1,131 +0,0 @@-system_template: |-- SETTING: You are a skilled cybersecurity professional and top CTF player.- Your goal is to solve the CTF challenge and find the flag. The flag format for this CTF is {{flag_format}}.-- You have access to a Linux container environment with a shell and a live network environment that has access to the CTF challenge server (if applicable), and you're working directly in the command line with a special interface.- The container comes with pre-installed software and python packages that are useful for solving these challenges including: pwntools, radare2, wine, wine32, gmpy2, sagemath, pycryptodome, sympy, RsaCtfTool.py, tshark, sqlmap and nikto.-- The special interface consists of a file editor that shows you {{WINDOW}} lines of a file at a time.- In addition to typical bash commands, you can also use the following commands to help you navigate and edit files.-- COMMANDS:- {{command_docs}}-- Please note that THE EDIT COMMAND REQUIRES PROPER INDENTATION.- If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.-- RESPONSE FORMAT:- Your shell prompt is formatted as follows:- (Open file: <path>) <cwd> $-- You need to format your output using two fields; discussion and command.- Your output should always include _one_ discussion and _one_ command field EXACTLY as in the following example:- DISCUSSION- First I'll start by using ls to see what files are in the current directory. Then maybe we can look at some relevant files to see what they look like.- ```- ls -a- ```-- You should only include a *SINGLE* command in the command section and then wait for a response from the shell before continuing with more discussion and commands. Everything you include in the DISCUSSION section will be saved for future reference.- If you'd like to issue two commands at once, PLEASE DO NOT DO THAT! Please instead first submit just the first command, and then after receiving a response you'll be able to issue the second command.- You're free to use any other bash commands you want (e.g. find, grep, cat, ls, cd) in addition to the special commands listed above.- However, the environment does NOT support interactive session commands (e.g. python, vim), so please do not invoke them.-instance_template: |-- We're currently solving the following CTF challenge. The CTF challenge is a {{category_friendly}} problem named "{{name}}", worth {{points}} points. The description is:- {{description}}- Files included in the challenge: {{files}}-- {{server_description}}-- INSTRUCTIONS:- Now, you're going to solve this challenge on your own. Your terminal session has started and you're in the challenge's root directory. You can use any bash commands or the special interface to help you.- Solve the challenge, executing any commands you need and writing any code that may be helpful. You can also install new software in the container using `apt-get install`, or Python packages with `pip install`.- Remember, YOU CAN ONLY ENTER ONE COMMAND AT A TIME. You should always wait for feedback after every command.- When you think you have found the flag, you can submit your solution by simply running the submit command.- Note however that you cannot use any interactive session commands (e.g. python, vim) in this environment, but you can write scripts and run them. E.g. you can write a python script and then run it with `python <script_name>.py`.-- NOTE ABOUT THE EDIT COMMAND: Indentation really matters! When editing a file, make sure to insert appropriate indentation before each line!-- IMPORTANT TIPS:- 1. When you edit an existing file, try to minimize the changes you make to the file.-- 2. Please make sure that you make use of the interactive tools supplied to you! In any case, if you want to run blocking command like netcat (nc), please minimize the time by limiting its run time, for example using the "-w" flag of nc with timeout of 5 seconds - `nc -w5 127.0.0.1 80`.-- 3. Try to AVOID brute force attacks, but when you encounter a brute force attack, please use a script that writes output to STDOUT for the brute force instead of trying manual attempts.-- 4. Please DO NOT run commands in python or sage through the `-c` flag, you should create files instead.-- 5. Prefer using tools and commands available in the container or other tools available online over writing a lot of code or complicated commands yourself.- In particular, prefer using `open` instead of `cat` and `search_file` instead of `grep`, and prefer using the interactive commands supplied to you!-- 6. DO NOT run any command that produces binary output! Instead try to use `hexdump` or `xxd`.-- 7. Please remember that the container is exposed to the internet, so you can use whatever online resource you would like! Use it wisely!-- 8. Do not use any interactive commands AT ALL! Interactive commands are only available through the commands supplied to you at the beginning - make use of them!-- 9. YOU CAN SOLVE THE CHALLENGES BY YOURSELF COMPLETELY - I TRUST IN YOU!-- (Open file: {{open_file}})- (Current directory: {{working_dir}})- (Interactive session: {{interactive_session}})- bash-$-next_step_template: |-- {{observation}}- (Open file: {{open_file}})- (Current directory: {{working_dir}})- (Interactive session: {{interactive_session}})- bash-$-next_step_no_output_template: |-- Your command ran successfully and did not produce any output.- (Open file: {{open_file}})- (Current directory: {{working_dir}})- (Interactive session: {{interactive_session}})- bash-$-state_command:- name: state- code: |- state() {{- local working_dir="$PWD";- local open_file="n/a";- local interactive_session="${{INTERACTIVE_SESSION:-n/a}}";- if [ ! -z $CURRENT_FILE ]; then- open_file=$(realpath $CURRENT_FILE);- fi-- echo '{{"open_file": "'$open_file'", "working_dir": "'$working_dir'", "interactive_session": "'$interactive_session'"}}'- }};-parse_function: ThoughtActionParser-env_variables:- WINDOW: 100- OVERLAP: 2- CURRENT_LINE: 0- CURRENT_FILE: ''- SEARCH_RESULTS: ()- SEARCH_FILES: ()- SEARCH_INDEX: 0-command_files:-- config/commands/defaults.sh-- config/commands/search.sh-- config/commands/edit_linting.sh-- config/commands/_split_string.py-- config/commands/submit_ctf.sh-- config/commands/decompile.py-- config/commands/disassemble.py-- config/commands/debug.sh-- config/commands/_connect.py-- config/commands/server_connection.sh-- config/commands/forfeit.sh-history_processors:- - type: last_n_observations- n: 5-blocklist:-- vim-- vi-- emacs-- nano-- nohup-- gdb-blocklist_error_template: |- Interactive operation '{{name}}' is not supported by this environment.- Please consider using one of the interactive commands available to you in this environment.diff --git a/config/default_from_url.yaml b/config/default_from_url.yamlindex 78856a43..6b1895ba 100644--- a/config/default_from_url.yaml+++ b/config/default_from_url.yaml@@ -99,6 +99,7 @@ agent:WINDOW: 100OVERLAP: 2bundles:+ - path: tools/registry- path: tools/defaults- path: tools/search- path: tools/edit_replacediff --git a/config/default_no_fcalls.yaml b/config/default_no_fcalls.yamlindex f4b87e41..d0c3d6f0 100644--- a/config/default_no_fcalls.yaml+++ b/config/default_no_fcalls.yaml@@ -88,6 +88,7 @@ agent:WINDOW: 100OVERLAP: 2bundles:+ - path: tools/registry- path: tools/defaults- path: tools/search- path: tools/edit_lintingdiff --git a/config/function_calling.yaml b/config/function_calling.yamlindex 18311a2c..2cb46988 100644--- a/config/function_calling.yaml+++ b/config/function_calling.yaml@@ -85,6 +85,7 @@ agent:WINDOW: 100OVERLAP: 2bundles:+ - path: tools/registry- path: tools/defaults- path: tools/search- path: tools/edit_lintingdiff --git a/config/function_calling_anthropic_openhands.yaml b/config/function_calling_anthropic_openhands.yamlindex 3b663b50..0e1fdddd 100644--- a/config/function_calling_anthropic_openhands.yaml+++ b/config/function_calling_anthropic_openhands.yaml@@ -33,6 +33,7 @@ agent:put_demos_in_history: truetools:bundles:+ - path: tools/registry- path: tools/edit_anthropic- path: tools/submitenable_bash_tool: truediff --git a/config/function_calling_replace.yaml b/config/function_calling_replace.yamlindex 1eeb5815..c2630b5a 100644--- a/config/function_calling_replace.yaml+++ b/config/function_calling_replace.yaml@@ -112,9 +112,9 @@ agent:WINDOW: 100OVERLAP: 2bundles:+ - path: tools/registry- path: tools/defaults- path: tools/search- # - path: tools/edit_linting- path: tools/edit_replace- path: tools/submitenable_bash_tool: truediff --git a/config/function_calling_replace_late_repro.yaml b/config/function_calling_replace_late_repro.yamlindex f8a44c29..92c3b412 100644--- a/config/function_calling_replace_late_repro.yaml+++ b/config/function_calling_replace_late_repro.yaml@@ -112,9 +112,9 @@ agent:WINDOW: 100OVERLAP: 2bundles:+ - path: tools/registry- path: tools/defaults- path: tools/search- # - path: tools/edit_linting- path: tools/edit_replace- path: tools/submitenable_bash_tool: truediff --git a/config/function_calling_rewrite.yaml b/config/function_calling_rewrite.yamlindex 896ff3fd..d8863def 100644--- a/config/function_calling_rewrite.yaml+++ b/config/function_calling_rewrite.yaml@@ -83,6 +83,7 @@ agent:WINDOW: 100OVERLAP: 2bundles:+ - path: tools/registry- path: tools/defaults- path: tools/search- path: tools/edit_rewritediff --git a/config/human.yaml b/config/human.yamlindex cd9a5c2c..d368deec 100644--- a/config/human.yaml+++ b/config/human.yaml@@ -7,6 +7,7 @@ agent:WINDOW: 100OVERLAP: 2bundles:+ - path: tools/registry- path: tools/defaults- path: tools/search- path: tools/edit_lintingdiff --git a/config/human_demo.yaml b/config/human_demo.yamlindex 9a24b560..92239172 100644--- a/config/human_demo.yaml+++ b/config/human_demo.yaml@@ -32,6 +32,7 @@ agent:WINDOW: 100OVERLAP: 2bundles:+ - path: tools/registry- path: tools/defaults- path: tools/search- path: tools/edit_lintingdiff --git a/config/swe_agent_ablations/default_sys-env_cursors_window100-detailed_cmd_format-full_history-1_demos.yaml b/config/swe_agent_ablations/default_sys-env_cursors_window100-detailed_cmd_format-full_history-1_demos.yamldeleted file mode 100644index 6e4eb585..00000000--- a/config/swe_agent_ablations/default_sys-env_cursors_window100-detailed_cmd_format-full_history-1_demos.yaml+++ /dev/null@@ -1,118 +0,0 @@-#THIS CONFIG IS EXPERIMENTAL. WE DID NOT USE IT AT ALL FOR THE RESULTS IN THE PAPER. ONLY USE IT IF YOU KNOW WHAT YOU ARE DOING.-system_template: |-- SETTING: You are an autonomous programmer, and you're working directly in the command line with a special interface.-- The special interface consists of a file editor that shows you {{WINDOW}} lines of a file at a time.- In addition to typical bash commands, you can also use the following commands to help you navigate and edit files.-- COMMANDS:- {{command_docs}}-- Please note that THE EDIT COMMAND REQUIRES PROPER INDENTATION.- If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.-- RESPONSE FORMAT:- Your shell prompt is formatted as follows:- (Open file: <path>) <cwd> $-- You need to format your output using two fields; discussion and command.- Your output should always include _one_ discussion and _one_ command field EXACTLY as in the following example:- DISCUSSION- First I'll start by using ls to see what files are in the current directory. Then maybe we can look at some relevant files to see what they look like.- ```- ls -a- ```-- You should only include a *SINGLE* command in the command section and then wait for a response from the shell before continuing with more discussion and commands. Everything you include in the DISCUSSION section will be saved for future reference.- If you'd like to issue two commands at once, PLEASE DO NOT DO THAT! Please instead first submit just the first command, and then after receiving a response you'll be able to issue the second command.- You're free to use any other bash commands you want (e.g. find, grep, cat, ls, cd) in addition to the special commands listed above.- However, the environment does NOT support interactive session commands (e.g. python, vim), so please do not invoke them.-instance_template: |-- We're currently solving the following issue within our repository. Here's the issue text:- ISSUE:- {{issue}}-- INSTRUCTIONS:- Now, you're going to solve this issue on your own. Your terminal session has started and you're in the repository's root directory. You can use any bash commands or the special interface to help you. Edit all the files you need to and run any checks or tests that you want.- Remember, YOU CAN ONLY ENTER ONE COMMAND AT A TIME. You should always wait for feedback after every command.- When you're satisfied with all of the changes you've made, you can submit your changes to the code base by simply running the submit command.- Note however that you cannot use any interactive session commands (e.g. python, vim) in this environment, but you can write scripts and run them. E.g. you can write a python script and then run it with `python <script_name>.py`.-- NOTE ABOUT THE EDIT COMMAND: Indentation really matters! When editing a file, make sure to insert appropriate indentation before each line!-- IMPORTANT TIPS:- 1. Always start by trying to replicate the bug that the issues discusses.- If the issue includes code for reproducing the bug, we recommend that you re-implement that in your environment, and run it to make sure you can reproduce the bug.- Then start trying to fix it.- When you think you've fixed the bug, re-run the bug reproduction script to make sure that the bug has indeed been fixed.-- If the bug reproduction script does not print anything when it successfully runs, we recommend adding a print("Script completed successfully, no errors.") command at the end of the file,- so that you can be sure that the script indeed ran fine all the way through.-- 2. If you run a command and it doesn't work, try running a different command. A command that did not work once will not work the second time unless you modify it!-- 3. If you open a file and need to get to an area around a specific line that is not in the first 100 lines, say line 583, don't just use the scroll_down command multiple times. Instead, use the goto 583 command. It's much quicker.-- 4. If the bug reproduction script requires inputting/reading a specific file, such as buggy-input.png, and you'd like to understand how to input that file, conduct a search in the existing repo code, to see whether someone else has already done that. Do this by running the command: find_file "buggy-input.png" If that doesn't work, use the linux 'find' command.-- 5. Always make sure to look at the currently open file and the current working directory (which appears right after the currently open file). The currently open file might be in a different directory than the working directory! Note that some commands, such as 'create', open files, so they might change the current open file.-- 6. When editing files, it is easy to accidentally specify a wrong line number or to write code with incorrect indentation. Always check the code after you issue an edit to make sure that it reflects what you wanted to accomplish. If it didn't, issue another command to fix it.--- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-next_step_template: |-- {{observation}}- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-next_step_no_output_template: |-- Your command ran successfully and did not produce any output.- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-demonstration_template: |- Here is a demonstration of how to correctly accomplish this task.- It is included to show you how to correctly use the interface.- You do not need to follow exactly what is done in the demonstration.- --- DEMONSTRATION ---- {{demonstration}}- --- END OF DEMONSTRATION ----state_command:- name: state- code: |- state() {{- local working_dir="$PWD";- if [ -z "$CURRENT_FILE" ]; then- echo '{{"open_file": "n/a", "working_dir": "'$working_dir'"}}';- else- echo '{{"open_file": "'$(realpath "$CURRENT_FILE")'", "working_dir": "'$working_dir'"}}';- fi- }};-parse_function: ThoughtActionParser-env_variables:- WINDOW: 200- OVERLAP: 2- CURRENT_LINE: 0- CURRENT_FILE: ""- SEARCH_RESULTS: ()- SEARCH_FILES: ()- SEARCH_INDEX: 0- START_INDEX: 0- END_INDEX: 0- START_CURSOR: 0- END_CURSOR: 0- START_CURSOR_MARK: '"<<<<< START CURSOR >>>>>"' # these have to use double quotes- END_CURSOR_MARK: '"<<<<< END CURSOR >>>>>"' # these have to use double quotes-command_files:- - config/commands/cursors_defaults.sh- - config/commands/cursors_edit_linting.sh- - config/commands/search.sh- - config/commands/_split_string.py-parse_command: ParseCommandDetailed-history_processors:- - type: default_history_processor-demonstrations:- - trajectories/demonstrations/replay__marshmallow-code__marshmallow-1867__default_sys-env_cursors_window100__t-0.20__p-0.95__c-2.00__install-1/marshmallow-code__marshmallow-1867.trajdiff --git a/config/swe_agent_ablations/default_sys-env_cursors_window100-detailed_cmd_format-last_5_history-1_demos.yaml b/config/swe_agent_ablations/default_sys-env_cursors_window100-detailed_cmd_format-last_5_history-1_demos.yamldeleted file mode 100644index 6abda17d..00000000--- a/config/swe_agent_ablations/default_sys-env_cursors_window100-detailed_cmd_format-last_5_history-1_demos.yaml+++ /dev/null@@ -1,119 +0,0 @@-#THIS CONFIG IS EXPERIMENTAL. WE DID NOT USE IT AT ALL FOR THE RESULTS IN THE PAPER. ONLY USE IT IF YOU KNOW WHAT YOU ARE DOING.-system_template: |-- SETTING: You are an autonomous programmer, and you're working directly in the command line with a special interface.-- The special interface consists of a file editor that shows you {{WINDOW}} lines of a file at a time.- In addition to typical bash commands, you can also use the following commands to help you navigate and edit files.-- COMMANDS:- {{command_docs}}-- Please note that THE EDIT COMMAND REQUIRES PROPER INDENTATION.- If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.-- RESPONSE FORMAT:- Your shell prompt is formatted as follows:- (Open file: <path>) <cwd> $-- You need to format your output using two fields; discussion and command.- Your output should always include _one_ discussion and _one_ command field EXACTLY as in the following example:- DISCUSSION- First I'll start by using ls to see what files are in the current directory. Then maybe we can look at some relevant files to see what they look like.- ```- ls -a- ```-- You should only include a *SINGLE* command in the command section and then wait for a response from the shell before continuing with more discussion and commands. Everything you include in the DISCUSSION section will be saved for future reference.- If you'd like to issue two commands at once, PLEASE DO NOT DO THAT! Please instead first submit just the first command, and then after receiving a response you'll be able to issue the second command.- You're free to use any other bash commands you want (e.g. find, grep, cat, ls, cd) in addition to the special commands listed above.- However, the environment does NOT support interactive session commands (e.g. python, vim), so please do not invoke them.-instance_template: |-- We're currently solving the following issue within our repository. Here's the issue text:- ISSUE:- {{issue}}-- INSTRUCTIONS:- Now, you're going to solve this issue on your own. Your terminal session has started and you're in the repository's root directory. You can use any bash commands or the special interface to help you. Edit all the files you need to and run any checks or tests that you want.- Remember, YOU CAN ONLY ENTER ONE COMMAND AT A TIME. You should always wait for feedback after every command.- When you're satisfied with all of the changes you've made, you can submit your changes to the code base by simply running the submit command.- Note however that you cannot use any interactive session commands (e.g. python, vim) in this environment, but you can write scripts and run them. E.g. you can write a python script and then run it with `python <script_name>.py`.-- NOTE ABOUT THE EDIT COMMAND: Indentation really matters! When editing a file, make sure to insert appropriate indentation before each line!-- IMPORTANT TIPS:- 1. Always start by trying to replicate the bug that the issues discusses.- If the issue includes code for reproducing the bug, we recommend that you re-implement that in your environment, and run it to make sure you can reproduce the bug.- Then start trying to fix it.- When you think you've fixed the bug, re-run the bug reproduction script to make sure that the bug has indeed been fixed.-- If the bug reproduction script does not print anything when it successfully runs, we recommend adding a print("Script completed successfully, no errors.") command at the end of the file,- so that you can be sure that the script indeed ran fine all the way through.-- 2. If you run a command and it doesn't work, try running a different command. A command that did not work once will not work the second time unless you modify it!-- 3. If you open a file and need to get to an area around a specific line that is not in the first 100 lines, say line 583, don't just use the scroll_down command multiple times. Instead, use the goto 583 command. It's much quicker.-- 4. If the bug reproduction script requires inputting/reading a specific file, such as buggy-input.png, and you'd like to understand how to input that file, conduct a search in the existing repo code, to see whether someone else has already done that. Do this by running the command: find_file "buggy-input.png" If that doesn't work, use the linux 'find' command.-- 5. Always make sure to look at the currently open file and the current working directory (which appears right after the currently open file). The currently open file might be in a different directory than the working directory! Note that some commands, such as 'create', open files, so they might change the current open file.-- 6. When editing files, it is easy to accidentally specify a wrong line number or to write code with incorrect indentation. Always check the code after you issue an edit to make sure that it reflects what you wanted to accomplish. If it didn't, issue another command to fix it.--- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-next_step_template: |-- {{observation}}- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-next_step_no_output_template: |-- Your command ran successfully and did not produce any output.- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-demonstration_template: |- Here is a demonstration of how to correctly accomplish this task.- It is included to show you how to correctly use the interface.- You do not need to follow exactly what is done in the demonstration.- --- DEMONSTRATION ---- {{demonstration}}- --- END OF DEMONSTRATION ----state_command:- name: state- code: |- state() {{- local working_dir="$PWD";- if [ -z "$CURRENT_FILE" ]; then- echo '{{"open_file": "n/a", "working_dir": "'$working_dir'"}}';- else- echo '{{"open_file": "'$(realpath "$CURRENT_FILE")'", "working_dir": "'$working_dir'"}}';- fi- }};-parse_function: ThoughtActionParser-env_variables:- WINDOW: 200- OVERLAP: 2- CURRENT_LINE: 0- CURRENT_FILE: ""- SEARCH_RESULTS: ()- SEARCH_FILES: ()- SEARCH_INDEX: 0- START_INDEX: 0- END_INDEX: 0- START_CURSOR: 0- END_CURSOR: 0- START_CURSOR_MARK: '"<<<<< START CURSOR >>>>>"' # these have to use double quotes- END_CURSOR_MARK: '"<<<<< END CURSOR >>>>>"' # these have to use double quotes-command_files:- - config/commands/cursors_defaults.sh- - config/commands/cursors_edit_linting.sh- - config/commands/search.sh- - config/commands/_split_string.py-parse_command: ParseCommandDetailed-history_processors:- - type: last_n_observations- n: 5-demonstrations:- - trajectories/demonstrations/replay__marshmallow-code__marshmallow-1867__default_sys-env_cursors_window100__t-0.20__p-0.95__c-2.00__install-1/marshmallow-code__marshmallow-1867.trajdiff --git a/config/swe_agent_ablations/default_sys-env_window100-detailed_cmd_format-full_history-1_demos.yaml b/config/swe_agent_ablations/default_sys-env_window100-detailed_cmd_format-full_history-1_demos.yamldeleted file mode 100644index 7c0d9bda..00000000--- a/config/swe_agent_ablations/default_sys-env_window100-detailed_cmd_format-full_history-1_demos.yaml+++ /dev/null@@ -1,111 +0,0 @@-system_template: |-- SETTING: You are an autonomous programmer, and you're working directly in the command line with a special interface.-- The special interface consists of a file editor that shows you {{WINDOW}} lines of a file at a time.- In addition to typical bash commands, you can also use the following commands to help you navigate and edit files.-- COMMANDS:- {{command_docs}}-- Please note that THE EDIT COMMAND REQUIRES PROPER INDENTATION.- If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.-- RESPONSE FORMAT:- Your shell prompt is formatted as follows:- (Open file: <path>) <cwd> $-- You need to format your output using two fields; discussion and command.- Your output should always include _one_ discussion and _one_ command field EXACTLY as in the following example:- DISCUSSION- First I'll start by using ls to see what files are in the current directory. Then maybe we can look at some relevant files to see what they look like.- ```- ls -a- ```-- You should only include a *SINGLE* command in the command section and then wait for a response from the shell before continuing with more discussion and commands. Everything you include in the DISCUSSION section will be saved for future reference.- If you'd like to issue two commands at once, PLEASE DO NOT DO THAT! Please instead first submit just the first command, and then after receiving a response you'll be able to issue the second command.- You're free to use any other bash commands you want (e.g. find, grep, cat, ls, cd) in addition to the special commands listed above.- However, the environment does NOT support interactive session commands (e.g. python, vim), so please do not invoke them.-instance_template: |-- We're currently solving the following issue within our repository. Here's the issue text:- ISSUE:- {{issue}}-- INSTRUCTIONS:- Now, you're going to solve this issue on your own. Your terminal session has started and you're in the repository's root directory. You can use any bash commands or the special interface to help you. Edit all the files you need to and run any checks or tests that you want.- Remember, YOU CAN ONLY ENTER ONE COMMAND AT A TIME. You should always wait for feedback after every command.- When you're satisfied with all of the changes you've made, you can submit your changes to the code base by simply running the submit command.- Note however that you cannot use any interactive session commands (e.g. python, vim) in this environment, but you can write scripts and run them. E.g. you can write a python script and then run it with `python <script_name>.py`.-- NOTE ABOUT THE EDIT COMMAND: Indentation really matters! When editing a file, make sure to insert appropriate indentation before each line!-- IMPORTANT TIPS:- 1. Always start by trying to replicate the bug that the issues discusses.- If the issue includes code for reproducing the bug, we recommend that you re-implement that in your environment, and run it to make sure you can reproduce the bug.- Then start trying to fix it.- When you think you've fixed the bug, re-run the bug reproduction script to make sure that the bug has indeed been fixed.-- If the bug reproduction script does not print anything when it successfully runs, we recommend adding a print("Script completed successfully, no errors.") command at the end of the file,- so that you can be sure that the script indeed ran fine all the way through.-- 2. If you run a command and it doesn't work, try running a different command. A command that did not work once will not work the second time unless you modify it!-- 3. If you open a file and need to get to an area around a specific line that is not in the first 100 lines, say line 583, don't just use the scroll_down command multiple times. Instead, use the goto 583 command. It's much quicker.-- 4. If the bug reproduction script requires inputting/reading a specific file, such as buggy-input.png, and you'd like to understand how to input that file, conduct a search in the existing repo code, to see whether someone else has already done that. Do this by running the command: find_file "buggy-input.png" If that doesn't work, use the linux 'find' command.-- 5. Always make sure to look at the currently open file and the current working directory (which appears right after the currently open file). The currently open file might be in a different directory than the working directory! Note that some commands, such as 'create', open files, so they might change the current open file.-- 6. When editing files, it is easy to accidentally specify a wrong line number or to write code with incorrect indentation. Always check the code after you issue an edit to make sure that it reflects what you wanted to accomplish. If it didn't, issue another command to fix it.--- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-next_step_template: |-- {{observation}}- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-next_step_no_output_template: |-- Your command ran successfully and did not produce any output.- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-demonstration_template: |- Here is a demonstration of how to correctly accomplish this task.- It is included to show you how to correctly use the interface.- You do not need to follow exactly what is done in the demonstration.- --- DEMONSTRATION ---- {{demonstration}}- --- END OF DEMONSTRATION ----state_command:- name: state- code: |- state() {{- local working_dir="$PWD";- if [ -z "$CURRENT_FILE" ]; then- echo '{{"open_file": "n/a", "working_dir": "'$working_dir'"}}';- else- echo '{{"open_file": "'$(realpath "$CURRENT_FILE")'", "working_dir": "'$working_dir'"}}';- fi- }};-parse_function: ThoughtActionParser-env_variables:- WINDOW: 100- OVERLAP: 2- CURRENT_LINE: 0- CURRENT_FILE: ""- SEARCH_RESULTS: ()- SEARCH_FILES: ()- SEARCH_INDEX: 0-command_files:- - config/commands/defaults.sh- - config/commands/search.sh- - config/commands/edit_linting.sh- - config/commands/_split_string.py-parse_command: ParseCommandDetailed-history_processors:- - type: default_history_processor-demonstrations:- - trajectories/demonstrations/replay__marshmallow-code__marshmallow-1867__default_sys-env_window100__t-0.20__p-0.95__c-2.00__install-1/marshmallow-code__marshmallow-1867.trajdiff --git a/config/swe_agent_ablations/default_sys-env_window100-detailed_cmd_format-last_5_history-1_demos.yaml b/config/swe_agent_ablations/default_sys-env_window100-detailed_cmd_format-last_5_history-1_demos.yamldeleted file mode 100644index 87905c8c..00000000--- a/config/swe_agent_ablations/default_sys-env_window100-detailed_cmd_format-last_5_history-1_demos.yaml+++ /dev/null@@ -1,112 +0,0 @@-system_template: |-- SETTING: You are an autonomous programmer, and you're working directly in the command line with a special interface.-- The special interface consists of a file editor that shows you {{WINDOW}} lines of a file at a time.- In addition to typical bash commands, you can also use the following commands to help you navigate and edit files.-- COMMANDS:- {{command_docs}}-- Please note that THE EDIT COMMAND REQUIRES PROPER INDENTATION.- If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.-- RESPONSE FORMAT:- Your shell prompt is formatted as follows:- (Open file: <path>) <cwd> $-- You need to format your output using two fields; discussion and command.- Your output should always include _one_ discussion and _one_ command field EXACTLY as in the following example:- DISCUSSION- First I'll start by using ls to see what files are in the current directory. Then maybe we can look at some relevant files to see what they look like.- ```- ls -a- ```-- You should only include a *SINGLE* command in the command section and then wait for a response from the shell before continuing with more discussion and commands. Everything you include in the DISCUSSION section will be saved for future reference.- If you'd like to issue two commands at once, PLEASE DO NOT DO THAT! Please instead first submit just the first command, and then after receiving a response you'll be able to issue the second command.- You're free to use any other bash commands you want (e.g. find, grep, cat, ls, cd) in addition to the special commands listed above.- However, the environment does NOT support interactive session commands (e.g. python, vim), so please do not invoke them.-instance_template: |-- We're currently solving the following issue within our repository. Here's the issue text:- ISSUE:- {{issue}}-- INSTRUCTIONS:- Now, you're going to solve this issue on your own. Your terminal session has started and you're in the repository's root directory. You can use any bash commands or the special interface to help you. Edit all the files you need to and run any checks or tests that you want.- Remember, YOU CAN ONLY ENTER ONE COMMAND AT A TIME. You should always wait for feedback after every command.- When you're satisfied with all of the changes you've made, you can submit your changes to the code base by simply running the submit command.- Note however that you cannot use any interactive session commands (e.g. python, vim) in this environment, but you can write scripts and run them. E.g. you can write a python script and then run it with `python <script_name>.py`.-- NOTE ABOUT THE EDIT COMMAND: Indentation really matters! When editing a file, make sure to insert appropriate indentation before each line!-- IMPORTANT TIPS:- 1. Always start by trying to replicate the bug that the issues discusses.- If the issue includes code for reproducing the bug, we recommend that you re-implement that in your environment, and run it to make sure you can reproduce the bug.- Then start trying to fix it.- When you think you've fixed the bug, re-run the bug reproduction script to make sure that the bug has indeed been fixed.-- If the bug reproduction script does not print anything when it successfully runs, we recommend adding a print("Script completed successfully, no errors.") command at the end of the file,- so that you can be sure that the script indeed ran fine all the way through.-- 2. If you run a command and it doesn't work, try running a different command. A command that did not work once will not work the second time unless you modify it!-- 3. If you open a file and need to get to an area around a specific line that is not in the first 100 lines, say line 583, don't just use the scroll_down command multiple times. Instead, use the goto 583 command. It's much quicker.-- 4. If the bug reproduction script requires inputting/reading a specific file, such as buggy-input.png, and you'd like to understand how to input that file, conduct a search in the existing repo code, to see whether someone else has already done that. Do this by running the command: find_file "buggy-input.png" If that doesn't work, use the linux 'find' command.-- 5. Always make sure to look at the currently open file and the current working directory (which appears right after the currently open file). The currently open file might be in a different directory than the working directory! Note that some commands, such as 'create', open files, so they might change the current open file.-- 6. When editing files, it is easy to accidentally specify a wrong line number or to write code with incorrect indentation. Always check the code after you issue an edit to make sure that it reflects what you wanted to accomplish. If it didn't, issue another command to fix it.--- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-next_step_template: |-- {{observation}}- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-next_step_no_output_template: |-- Your command ran successfully and did not produce any output.- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-demonstration_template: |- Here is a demonstration of how to correctly accomplish this task.- It is included to show you how to correctly use the interface.- You do not need to follow exactly what is done in the demonstration.- --- DEMONSTRATION ---- {{demonstration}}- --- END OF DEMONSTRATION ----state_command:- name: state- code: |- state() {{- local working_dir="$PWD";- if [ -z "$CURRENT_FILE" ]; then- echo '{{"open_file": "n/a", "working_dir": "'$working_dir'"}}';- else- echo '{{"open_file": "'$(realpath "$CURRENT_FILE")'", "working_dir": "'$working_dir'"}}';- fi- }};-parse_function: ThoughtActionParser-env_variables:- WINDOW: 100- OVERLAP: 2- CURRENT_LINE: 0- CURRENT_FILE: ""- SEARCH_RESULTS: ()- SEARCH_FILES: ()- SEARCH_INDEX: 0-command_files:- - config/commands/defaults.sh- - config/commands/search.sh- - config/commands/edit_linting.sh- - config/commands/_split_string.py-parse_command: ParseCommandDetailed-history_processors:- - type: last_n_observations- n: 5-demonstrations:- - trajectories/demonstrations/replay__marshmallow-code__marshmallow-1867__default_sys-env_window100__t-0.20__p-0.95__c-2.00__install-1/marshmallow-code__marshmallow-1867.trajdiff --git a/config/swe_agent_ablations/xml_sys-env_cursors_window100-detailed_cmd_format-full_history-1_demos.yaml b/config/swe_agent_ablations/xml_sys-env_cursors_window100-detailed_cmd_format-full_history-1_demos.yamldeleted file mode 100644index deab5086..00000000--- a/config/swe_agent_ablations/xml_sys-env_cursors_window100-detailed_cmd_format-full_history-1_demos.yaml+++ /dev/null@@ -1,112 +0,0 @@-#THIS CONFIG IS EXPERIMENTAL. WE DID NOT USE IT AT ALL FOR THE RESULTS IN THE PAPER. ONLY USE IT IF YOU KNOW WHAT YOU ARE DOING.-system_template: |-- SETTING: You are an autonomous programmer, and you're working directly in the command line with a special interface.-- The special interface consists of a file editor that shows you {{WINDOW}} lines of a file at a time.- In addition to typical bash commands, you can also use the following commands to help you navigate and edit files.-- COMMANDS:- {{command_docs}}-- Please note that THE EDIT COMMAND REQUIRES PROPER INDENTATION.- If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.-- RESPONSE FORMAT:- Your shell prompt is formatted as follows:- (Open file: <path>) <cwd> $-- You need to format your output using two fields; discussion and command.- Your output should always include _one_ discussion and _one_ command field EXACTLY as in the following example:- DISCUSSION- First I'll start by using ls to see what files are in the current directory. Then maybe we can look at some relevant files to see what they look like.- <command>- ls -a- </command>-- You should only include a *SINGLE* command in the command section and then wait for a response from the shell before continuing with more discussion and commands. Everything you include in the DISCUSSION section will be saved for future reference.- If you'd like to issue two commands at once, PLEASE DO NOT DO THAT! Please instead first submit just the first command, and then after receiving a response you'll be able to issue the second command.- You're free to use any other bash commands you want (e.g. find, grep, cat, ls, cd) in addition to the special commands listed above.- However, the environment does NOT support interactive session commands (e.g. python, vim), so please do not invoke them.-instance_template: |-- We're currently solving the following issue within our repository. Here's the issue text:- ISSUE:- {{issue}}-- INSTRUCTIONS:- Now, you're going to solve this issue on your own. Your terminal session has started and you're in the repository's root directory. You can use any bash commands or the special interface to help you. Edit all the files you need to and run any checks or tests that you want.- Remember, YOU CAN ONLY ENTER ONE COMMAND AT A TIME. You should always wait for feedback after every command.- When you're satisfied with all of the changes you've made, you can submit your changes to the code base by simply running the submit command.- Note however that you cannot use any interactive session commands (e.g. python, vim) in this environment, but you can write scripts and run them. E.g. you can write a python script and then run it with `python <script_name>.py`.-- NOTE ABOUT THE EDIT COMMAND: Indentation really matters! When editing a file, make sure to insert appropriate indentation before each line!-- IMPORTANT TIPS:- 1. Always start by trying to replicate the bug that the issues discusses.- If the issue includes code for reproducing the bug, we recommend that you re-implement that in your environment, and run it to make sure you can reproduce the bug.- Then start trying to fix it.- When you think you've fixed the bug, re-run the bug reproduction script to make sure that the bug has indeed been fixed.-- If the bug reproduction script does not print anything when it successfully runs, we recommend adding a print("Script completed successfully, no errors.") command at the end of the file,- so that you can be sure that the script indeed ran fine all the way through.-- 2. If you run a command and it doesn't work, try running a different command. A command that did not work once will not work the second time unless you modify it!-- 3. If you open a file and need to get to an area around a specific line that is not in the first 100 lines, say line 583, don't just use the scroll_down command multiple times. Instead, use the goto 583 command. It's much quicker.-- 4. If the bug reproduction script requires inputting/reading a specific file, such as buggy-input.png, and you'd like to understand how to input that file, conduct a search in the existing repo code, to see whether someone else has already done that. Do this by running the command: find_file "buggy-input.png" If that doesn't work, use the linux 'find' command.-- 5. Always make sure to look at the currently open file and the current working directory (which appears right after the currently open file). The currently open file might be in a different directory than the working directory! Note that some commands, such as 'create', open files, so they might change the current open file.-- 6. When editing files, it is easy to accidentally specify a wrong line number or to write code with incorrect indentation. Always check the code after you issue an edit to make sure that it reflects what you wanted to accomplish. If it didn't, issue another command to fix it.--- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-next_step_template: |-- {{observation}}- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-next_step_no_output_template: |-- Your command ran successfully and did not produce any output.- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-put_demos_in_history: true-state_command:- name: state- code: |- state() {{- local working_dir="$PWD";- if [ -z "$CURRENT_FILE" ]; then- echo '{{"open_file": "n/a", "working_dir": "'$working_dir'"}}';- else- echo '{{"open_file": "'$(realpath "$CURRENT_FILE")'", "working_dir": "'$working_dir'"}}';- fi- }};-parse_function: XMLThoughtActionParser-env_variables:- WINDOW: 200- OVERLAP: 2- CURRENT_LINE: 0- CURRENT_FILE: ""- SEARCH_RESULTS: ()- SEARCH_FILES: ()- SEARCH_INDEX: 0- START_INDEX: 0- END_INDEX: 0- START_CURSOR: 0- END_CURSOR: 0- START_CURSOR_MARK: '"<<<<< START CURSOR >>>>>"' # these have to use double quotes- END_CURSOR_MARK: '"<<<<< END CURSOR >>>>>"' # these have to use double quotes-command_files:- - config/commands/cursors_defaults.sh- - config/commands/cursors_edit_linting.sh- - config/commands/search.sh- - config/commands/_split_string.py-parse_command: ParseCommandDetailed-history_processors:- - type: default_history_processor-demonstrations:- - trajectories/demonstrations/replay__marshmallow-code__marshmallow-1867__xml_sys-env_cursors_window100__t-0.20__p-0.95__c-2.00__install-1/marshmallow-code__marshmallow-1867.trajdiff --git a/config/swe_agent_ablations/xml_sys-env_cursors_window100-detailed_cmd_format-last_5_history-1_demos.yaml b/config/swe_agent_ablations/xml_sys-env_cursors_window100-detailed_cmd_format-last_5_history-1_demos.yamldeleted file mode 100644index a854ff32..00000000--- a/config/swe_agent_ablations/xml_sys-env_cursors_window100-detailed_cmd_format-last_5_history-1_demos.yaml+++ /dev/null@@ -1,113 +0,0 @@-#THIS CONFIG IS EXPERIMENTAL. WE DID NOT USE IT AT ALL FOR THE RESULTS IN THE PAPER. ONLY USE IT IF YOU KNOW WHAT YOU ARE DOING.-system_template: |-- SETTING: You are an autonomous programmer, and you're working directly in the command line with a special interface.-- The special interface consists of a file editor that shows you {{WINDOW}} lines of a file at a time.- In addition to typical bash commands, you can also use the following commands to help you navigate and edit files.-- COMMANDS:- {{command_docs}}-- Please note that THE EDIT COMMAND REQUIRES PROPER INDENTATION.- If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.-- RESPONSE FORMAT:- Your shell prompt is formatted as follows:- (Open file: <path>) <cwd> $-- You need to format your output using two fields; discussion and command.- Your output should always include _one_ discussion and _one_ command field EXACTLY as in the following example:- DISCUSSION- First I'll start by using ls to see what files are in the current directory. Then maybe we can look at some relevant files to see what they look like.- <command>- ls -a- </command>-- You should only include a *SINGLE* command in the command section and then wait for a response from the shell before continuing with more discussion and commands. Everything you include in the DISCUSSION section will be saved for future reference.- If you'd like to issue two commands at once, PLEASE DO NOT DO THAT! Please instead first submit just the first command, and then after receiving a response you'll be able to issue the second command.- You're free to use any other bash commands you want (e.g. find, grep, cat, ls, cd) in addition to the special commands listed above.- However, the environment does NOT support interactive session commands (e.g. python, vim), so please do not invoke them.-instance_template: |-- We're currently solving the following issue within our repository. Here's the issue text:- ISSUE:- {{issue}}-- INSTRUCTIONS:- Now, you're going to solve this issue on your own. Your terminal session has started and you're in the repository's root directory. You can use any bash commands or the special interface to help you. Edit all the files you need to and run any checks or tests that you want.- Remember, YOU CAN ONLY ENTER ONE COMMAND AT A TIME. You should always wait for feedback after every command.- When you're satisfied with all of the changes you've made, you can submit your changes to the code base by simply running the submit command.- Note however that you cannot use any interactive session commands (e.g. python, vim) in this environment, but you can write scripts and run them. E.g. you can write a python script and then run it with `python <script_name>.py`.-- NOTE ABOUT THE EDIT COMMAND: Indentation really matters! When editing a file, make sure to insert appropriate indentation before each line!-- IMPORTANT TIPS:- 1. Always start by trying to replicate the bug that the issues discusses.- If the issue includes code for reproducing the bug, we recommend that you re-implement that in your environment, and run it to make sure you can reproduce the bug.- Then start trying to fix it.- When you think you've fixed the bug, re-run the bug reproduction script to make sure that the bug has indeed been fixed.-- If the bug reproduction script does not print anything when it successfully runs, we recommend adding a print("Script completed successfully, no errors.") command at the end of the file,- so that you can be sure that the script indeed ran fine all the way through.-- 2. If you run a command and it doesn't work, try running a different command. A command that did not work once will not work the second time unless you modify it!-- 3. If you open a file and need to get to an area around a specific line that is not in the first 100 lines, say line 583, don't just use the scroll_down command multiple times. Instead, use the goto 583 command. It's much quicker.-- 4. If the bug reproduction script requires inputting/reading a specific file, such as buggy-input.png, and you'd like to understand how to input that file, conduct a search in the existing repo code, to see whether someone else has already done that. Do this by running the command: find_file "buggy-input.png" If that doesn't work, use the linux 'find' command.-- 5. Always make sure to look at the currently open file and the current working directory (which appears right after the currently open file). The currently open file might be in a different directory than the working directory! Note that some commands, such as 'create', open files, so they might change the current open file.-- 6. When editing files, it is easy to accidentally specify a wrong line number or to write code with incorrect indentation. Always check the code after you issue an edit to make sure that it reflects what you wanted to accomplish. If it didn't, issue another command to fix it.--- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-next_step_template: |-- {{observation}}- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-next_step_no_output_template: |-- Your command ran successfully and did not produce any output.- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-put_demos_in_history: true-state_command:- name: state- code: |- state() {{- local working_dir="$PWD";- if [ -z "$CURRENT_FILE" ]; then- echo '{{"open_file": "n/a", "working_dir": "'$working_dir'"}}';- else- echo '{{"open_file": "'$(realpath "$CURRENT_FILE")'", "working_dir": "'$working_dir'"}}';- fi- }};-parse_function: XMLThoughtActionParser-env_variables:- WINDOW: 200- OVERLAP: 2- CURRENT_LINE: 0- CURRENT_FILE: ""- SEARCH_RESULTS: ()- SEARCH_FILES: ()- SEARCH_INDEX: 0- START_INDEX: 0- END_INDEX: 0- START_CURSOR: 0- END_CURSOR: 0- START_CURSOR_MARK: '"<<<<< START CURSOR >>>>>"' # these have to use double quotes- END_CURSOR_MARK: '"<<<<< END CURSOR >>>>>"' # these have to use double quotes-command_files:- - config/commands/cursors_defaults.sh- - config/commands/cursors_edit_linting.sh- - config/commands/search.sh- - config/commands/_split_string.py-parse_command: ParseCommandDetailed-history_processors:- - type: last_n_observations- n: 5-demonstrations:- - trajectories/demonstrations/replay__marshmallow-code__marshmallow-1867__xml_sys-env_cursors_window100__t-0.20__p-0.95__c-2.00__install-1/marshmallow-code__marshmallow-1867.trajdiff --git a/config/swe_agent_ablations/xml_sys-env_window100-detailed_cmd_format-full_history-1_demos.yaml b/config/swe_agent_ablations/xml_sys-env_window100-detailed_cmd_format-full_history-1_demos.yamldeleted file mode 100644index d2b6af63..00000000--- a/config/swe_agent_ablations/xml_sys-env_window100-detailed_cmd_format-full_history-1_demos.yaml+++ /dev/null@@ -1,105 +0,0 @@-system_template: |-- SETTING: You are an autonomous programmer, and you're working directly in the command line with a special interface.-- The special interface consists of a file editor that shows you {{WINDOW}} lines of a file at a time.- In addition to typical bash commands, you can also use the following commands to help you navigate and edit files.-- COMMANDS:- {{command_docs}}-- Please note that THE EDIT COMMAND REQUIRES PROPER INDENTATION.- If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.-- RESPONSE FORMAT:- Your shell prompt is formatted as follows:- (Open file: <path>) <cwd> $-- You need to format your output using two fields; discussion and command.- Your output should always include _one_ discussion and _one_ command field EXACTLY as in the following example:- DISCUSSION- First I'll start by using ls to see what files are in the current directory. Then maybe we can look at some relevant files to see what they look like.- <command>- ls -a- </command>-- You should only include a *SINGLE* command in the command section and then wait for a response from the shell before continuing with more discussion and commands. Everything you include in the DISCUSSION section will be saved for future reference.- If you'd like to issue two commands at once, PLEASE DO NOT DO THAT! Please instead first submit just the first command, and then after receiving a response you'll be able to issue the second command.- You're free to use any other bash commands you want (e.g. find, grep, cat, ls, cd) in addition to the special commands listed above.- However, the environment does NOT support interactive session commands (e.g. python, vim), so please do not invoke them.-instance_template: |-- We're currently solving the following issue within our repository. Here's the issue text:- ISSUE:- {{issue}}-- INSTRUCTIONS:- Now, you're going to solve this issue on your own. Your terminal session has started and you're in the repository's root directory. You can use any bash commands or the special interface to help you. Edit all the files you need to and run any checks or tests that you want.- Remember, YOU CAN ONLY ENTER ONE COMMAND AT A TIME. You should always wait for feedback after every command.- When you're satisfied with all of the changes you've made, you can submit your changes to the code base by simply running the submit command.- Note however that you cannot use any interactive session commands (e.g. python, vim) in this environment, but you can write scripts and run them. E.g. you can write a python script and then run it with `python <script_name>.py`.-- NOTE ABOUT THE EDIT COMMAND: Indentation really matters! When editing a file, make sure to insert appropriate indentation before each line!-- IMPORTANT TIPS:- 1. Always start by trying to replicate the bug that the issues discusses.- If the issue includes code for reproducing the bug, we recommend that you re-implement that in your environment, and run it to make sure you can reproduce the bug.- Then start trying to fix it.- When you think you've fixed the bug, re-run the bug reproduction script to make sure that the bug has indeed been fixed.-- If the bug reproduction script does not print anything when it successfully runs, we recommend adding a print("Script completed successfully, no errors.") command at the end of the file,- so that you can be sure that the script indeed ran fine all the way through.-- 2. If you run a command and it doesn't work, try running a different command. A command that did not work once will not work the second time unless you modify it!-- 3. If you open a file and need to get to an area around a specific line that is not in the first 100 lines, say line 583, don't just use the scroll_down command multiple times. Instead, use the goto 583 command. It's much quicker.-- 4. If the bug reproduction script requires inputting/reading a specific file, such as buggy-input.png, and you'd like to understand how to input that file, conduct a search in the existing repo code, to see whether someone else has already done that. Do this by running the command: find_file "buggy-input.png" If that doesn't work, use the linux 'find' command.-- 5. Always make sure to look at the currently open file and the current working directory (which appears right after the currently open file). The currently open file might be in a different directory than the working directory! Note that some commands, such as 'create', open files, so they might change the current open file.-- 6. When editing files, it is easy to accidentally specify a wrong line number or to write code with incorrect indentation. Always check the code after you issue an edit to make sure that it reflects what you wanted to accomplish. If it didn't, issue another command to fix it.--- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-next_step_template: |-- {{observation}}- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-next_step_no_output_template: |-- Your command ran successfully and did not produce any output.- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-put_demos_in_history: true-state_command:- name: state- code: |- state() {{- local working_dir="$PWD";- if [ -z "$CURRENT_FILE" ]; then- echo '{{"open_file": "n/a", "working_dir": "'$working_dir'"}}';- else- echo '{{"open_file": "'$(realpath "$CURRENT_FILE")'", "working_dir": "'$working_dir'"}}';- fi- }};-parse_function: XMLThoughtActionParser-env_variables:- WINDOW: 100- OVERLAP: 2- CURRENT_LINE: 0- CURRENT_FILE: ""- SEARCH_RESULTS: ()- SEARCH_FILES: ()- SEARCH_INDEX: 0-command_files:- - config/commands/defaults.sh- - config/commands/search.sh- - config/commands/edit_linting.sh- - config/commands/_split_string.py-parse_command: ParseCommandDetailed-history_processors:- - type: default_history_processor-demonstrations:- - trajectories/demonstrations/replay__marshmallow-code__marshmallow-1867__xml_sys-env_window100__t-0.20__p-0.95__c-2.00__install-1/marshmallow-code__marshmallow-1867.trajdiff --git a/config/swe_agent_ablations/xml_sys-env_window100-detailed_cmd_format-last_5_history-1_demos.yaml b/config/swe_agent_ablations/xml_sys-env_window100-detailed_cmd_format-last_5_history-1_demos.yamldeleted file mode 100644index 55ccc061..00000000--- a/config/swe_agent_ablations/xml_sys-env_window100-detailed_cmd_format-last_5_history-1_demos.yaml+++ /dev/null@@ -1,106 +0,0 @@-system_template: |-- SETTING: You are an autonomous programmer, and you're working directly in the command line with a special interface.-- The special interface consists of a file editor that shows you {{WINDOW}} lines of a file at a time.- In addition to typical bash commands, you can also use the following commands to help you navigate and edit files.-- COMMANDS:- {{command_docs}}-- Please note that THE EDIT COMMAND REQUIRES PROPER INDENTATION.- If you'd like to add the line ' print(x)' you must fully write that out, with all those spaces before the code! Indentation is important and code that is not indented correctly will fail and require fixing before it can be run.-- RESPONSE FORMAT:- Your shell prompt is formatted as follows:- (Open file: <path>) <cwd> $-- You need to format your output using two fields; discussion and command.- Your output should always include _one_ discussion and _one_ command field EXACTLY as in the following example:- DISCUSSION- First I'll start by using ls to see what files are in the current directory. Then maybe we can look at some relevant files to see what they look like.- <command>- ls -a- </command>-- You should only include a *SINGLE* command in the command section and then wait for a response from the shell before continuing with more discussion and commands. Everything you include in the DISCUSSION section will be saved for future reference.- If you'd like to issue two commands at once, PLEASE DO NOT DO THAT! Please instead first submit just the first command, and then after receiving a response you'll be able to issue the second command.- You're free to use any other bash commands you want (e.g. find, grep, cat, ls, cd) in addition to the special commands listed above.- However, the environment does NOT support interactive session commands (e.g. python, vim), so please do not invoke them.-instance_template: |-- We're currently solving the following issue within our repository. Here's the issue text:- ISSUE:- {{issue}}-- INSTRUCTIONS:- Now, you're going to solve this issue on your own. Your terminal session has started and you're in the repository's root directory. You can use any bash commands or the special interface to help you. Edit all the files you need to and run any checks or tests that you want.- Remember, YOU CAN ONLY ENTER ONE COMMAND AT A TIME. You should always wait for feedback after every command.- When you're satisfied with all of the changes you've made, you can submit your changes to the code base by simply running the submit command.- Note however that you cannot use any interactive session commands (e.g. python, vim) in this environment, but you can write scripts and run them. E.g. you can write a python script and then run it with `python <script_name>.py`.-- NOTE ABOUT THE EDIT COMMAND: Indentation really matters! When editing a file, make sure to insert appropriate indentation before each line!-- IMPORTANT TIPS:- 1. Always start by trying to replicate the bug that the issues discusses.- If the issue includes code for reproducing the bug, we recommend that you re-implement that in your environment, and run it to make sure you can reproduce the bug.- Then start trying to fix it.- When you think you've fixed the bug, re-run the bug reproduction script to make sure that the bug has indeed been fixed.-- If the bug reproduction script does not print anything when it successfully runs, we recommend adding a print("Script completed successfully, no errors.") command at the end of the file,- so that you can be sure that the script indeed ran fine all the way through.-- 2. If you run a command and it doesn't work, try running a different command. A command that did not work once will not work the second time unless you modify it!-- 3. If you open a file and need to get to an area around a specific line that is not in the first 100 lines, say line 583, don't just use the scroll_down command multiple times. Instead, use the goto 583 command. It's much quicker.-- 4. If the bug reproduction script requires inputting/reading a specific file, such as buggy-input.png, and you'd like to understand how to input that file, conduct a search in the existing repo code, to see whether someone else has already done that. Do this by running the command: find_file "buggy-input.png" If that doesn't work, use the linux 'find' command.-- 5. Always make sure to look at the currently open file and the current working directory (which appears right after the currently open file). The currently open file might be in a different directory than the working directory! Note that some commands, such as 'create', open files, so they might change the current open file.-- 6. When editing files, it is easy to accidentally specify a wrong line number or to write code with incorrect indentation. Always check the code after you issue an edit to make sure that it reflects what you wanted to accomplish. If it didn't, issue another command to fix it.--- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-next_step_template: |-- {{observation}}- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-next_step_no_output_template: |-- Your command ran successfully and did not produce any output.- (Open file: {{open_file}})- (Current directory: {{working_dir}})- bash-$-put_demos_in_history: true-state_command:- name: state- code: |- state() {{- local working_dir="$PWD";- if [ -z "$CURRENT_FILE" ]; then- echo '{{"open_file": "n/a", "working_dir": "'$working_dir'"}}';- else- echo '{{"open_file": "'$(realpath "$CURRENT_FILE")'", "working_dir": "'$working_dir'"}}';- fi- }};-parse_function: XMLThoughtActionParser-env_variables:- WINDOW: 100- OVERLAP: 2- CURRENT_LINE: 0- CURRENT_FILE: ""- SEARCH_RESULTS: ()- SEARCH_FILES: ()- SEARCH_INDEX: 0-command_files:- - config/commands/defaults.sh- - config/commands/search.sh- - config/commands/edit_linting.sh- - config/commands/_split_string.py-parse_command: ParseCommandDetailed-history_processors:- - type: last_n_observations- n: 5-demonstrations:- - trajectories/demonstrations/replay__marshmallow-code__marshmallow-1867__xml_sys-env_window100__t-0.20__p-0.95__c-2.00__install-1/marshmallow-code__marshmallow-1867.trajdiff --git a/tests/tools/test_default_utils.py b/tests/tools/test_default_utils.pyindex cdd8fa65..619d8754 100644--- a/tests/tools/test_default_utils.py+++ b/tests/tools/test_default_utils.py@@ -12,7 +12,7 @@ DEFAULT_TOOLS_BIN = DEFAULT_TOOLS_DIR / "bin"make_python_tool_importable(DEFAULT_TOOLS_DIR / "lib/default_utils.py", "default_utils")import default_utils # type: ignore-from default_utils import WindowedFile # type: ignore+from windowed_file import WindowedFile # type: ignoredef test_env_file_override(with_tmp_env_file):diff --git a/tools/defaults/bin/_state b/tools/defaults/bin/_stateindex 03669b2c..a6b1385a 100644--- a/tools/defaults/bin/_state+++ b/tools/defaults/bin/_state@@ -4,7 +4,7 @@ import jsonimport osfrom pathlib import Path-from default_utils import registry # type: ignore+from registry import registry # type: ignoredef main():diff --git a/tools/defaults/bin/create b/tools/defaults/bin/createindex b255694b..0e2cd24c 100644--- a/tools/defaults/bin/create+++ b/tools/defaults/bin/create@@ -2,7 +2,7 @@import sysfrom pathlib import Path-from default_utils import WindowedFile # type: ignore+from windowed_file import WindowedFile # type: ignoredef main():diff --git a/tools/defaults/bin/goto b/tools/defaults/bin/gotoindex f2fb7537..cbbdf65c 100644--- a/tools/defaults/bin/goto+++ b/tools/defaults/bin/goto@@ -2,7 +2,7 @@import sysfrom typing import List-from default_utils import WindowedFile # type: ignore+from windowed_file import WindowedFile # type: ignoredef main(args: List[str]) -> int:diff --git a/tools/defaults/bin/open b/tools/defaults/bin/openindex e879afe0..a5470034 100644--- a/tools/defaults/bin/open+++ b/tools/defaults/bin/open@@ -2,7 +2,7 @@import sysfrom typing import Optional-from default_utils import FileNotOpened, WindowedFile # type: ignore+from windowed_file import FileNotOpened, WindowedFile # type: ignoredef main(path: Optional[str] = None, line_number: Optional[str] = None) -> None:diff --git a/tools/defaults/bin/scroll_down b/tools/defaults/bin/scroll_downindex cd9e44f3..b34cb484 100644--- a/tools/defaults/bin/scroll_down+++ b/tools/defaults/bin/scroll_down@@ -1,6 +1,6 @@#!/usr/bin/env python3-from default_utils import WindowedFile # type: ignore+from windowed_file import WindowedFile # type: ignoredef main():diff --git a/tools/defaults/bin/scroll_up b/tools/defaults/bin/scroll_upindex 9a632317..c3904022 100644--- a/tools/defaults/bin/scroll_up+++ b/tools/defaults/bin/scroll_up@@ -1,6 +1,6 @@#!/usr/bin/env python3-from default_utils import WindowedFile # type: ignore+from windowed_file import WindowedFile # type: ignoredef main():diff --git a/tools/defaults/install.sh b/tools/defaults/install.shindex bed25702..a69bf3a6 100644--- a/tools/defaults/install.sh+++ b/tools/defaults/install.sh@@ -5,7 +5,7 @@ bundle_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )# source "$script_dir/lib/utils.sh"-export PYTHONPATH="$bundle_dir/lib"+export PYTHONPATH=$PYTHONPATH:"$bundle_dir/lib"# Write default environment variables into the environment storage_write_env "WINDOW" "${WINDOW:-100}"diff --git a/tools/defaults/lib/flake8_utils.py b/tools/defaults/lib/flake8_utils.pyindex 9e0b67f0..441e2a20 100644--- a/tools/defaults/lib/flake8_utils.py+++ b/tools/defaults/lib/flake8_utils.py@@ -19,7 +19,7 @@ else:assert default_lib.is_dir()sys.path.append(str(default_lib))-from default_utils import registry+from registry import registryclass Flake8Error:diff --git a/tools/defaults/lib/utils.sh b/tools/defaults/lib/utils.shdeleted file mode 100644index a5029de2..00000000--- a/tools/defaults/lib/utils.sh+++ /dev/null@@ -1,65 +0,0 @@-_print() {- local CURRENT_FILE=$(_read_env "CURRENT_FILE")- local CURRENT_LINE=$(_read_env "CURRENT_LINE")- local WINDOW=$(_read_env "WINDOW")-- local total_lines=$(awk 'END {print NR}' "$CURRENT_FILE")- echo "[File: $(realpath "$CURRENT_FILE") ($total_lines lines total)]"- lines_above=$((CURRENT_LINE - WINDOW / 2 - 1))- lines_above=$((lines_above < 0 ? 0 : lines_above))- if [ $lines_above -gt 0 ]; then- echo "($lines_above more lines above)"- fi- start_line=$((CURRENT_LINE - WINDOW / 2))- start_line=$((start_line < 1 ? 1 : start_line))- end_line=$((CURRENT_LINE + WINDOW / 2))- end_line=$((end_line > total_lines ? total_lines : end_line))- sed -n "$start_line,$end_line p" "$CURRENT_FILE" | nl -v $start_line -s':' -b a -n ln -w1- lines_below=$((total_lines - CURRENT_LINE - WINDOW / 2))- lines_below=$((lines_below < 0 ? 0 : lines_below))- if [ $lines_below -gt 0 ]; then- echo "($lines_below more lines below)"- fi-}--_constrain_line() {- local CURRENT_FILE=$(_read_env CURRENT_FILE)- local CURRENT_LINE=$(_read_env CURRENT_LINE)- local WINDOW=$(_read_env WINDOW)-- if [ -z "$CURRENT_FILE" ]- then- echo "No file open. Use the open command first."- return- fi- local max_line=$(awk 'END {print NR}' "$CURRENT_FILE")- local half_window=$((WINDOW / 2))- # First ensure line number isn't too large (min of current_line and max_line - half_window)- if ((CURRENT_LINE > max_line - half_window)); then- CURRENT_LINE=$((max_line - half_window))- fi- # Then ensure line number isn't too small (max of current_line and half_window)- if ((CURRENT_LINE < half_window)); then- CURRENT_LINE=$((half_window))- fi- _write_env CURRENT_LINE $CURRENT_LINE-}--_scroll_warning_message() {- # Warn the agent if we scroll too many times- # Message will be shown if scroll is called more than WARN_AFTER_SCROLLING_TIMES (default 3) times- # Initialize variable if it's not set- local SCROLL_COUNT=$(_read_env SCROLL_COUNT 0)- # Reset if the last command wasn't about scrolling- if [ "$LAST_ACTION" != "scroll_up" ] && [ "$LAST_ACTION" != "scroll_down" ]; then- _write_env SCROLL_COUNT 0- fi- # Increment because we're definitely scrolling now- _write_env SCROLL_COUNT $(($SCROLL_COUNT + 1))- if [ $SCROLL_COUNT -ge ${WARN_AFTER_SCROLLING_TIMES:-3} ]; then- echo ""- echo "WARNING: Scrolling many times in a row is very inefficient."- echo "If you know what you are looking for, use \`search_file <pattern>\` instead."- echo ""- fi-}\ No newline at end of filediff --git a/tools/defaults/lib/default_utils.py b/tools/defaults/lib/windowed_file.pysimilarity index 85%rename from tools/defaults/lib/default_utils.pyrename to tools/defaults/lib/windowed_file.pyindex 8c7de2bb..9a570023 100644--- a/tools/defaults/lib/default_utils.py+++ b/tools/defaults/lib/windowed_file.py@@ -2,48 +2,7 @@ import jsonimport osfrom pathlib import Pathfrom typing import Any, List, Optional, Tuple, Union---class EnvRegistry:- """Read and write variables into a file. This is used to persist state between tool- calls without using environment variables (which are problematic because you cannot- set them in a subprocess).-- The default file location is `/root/.swe-agent-env`, though this can be overridden- by the `env_file` argument or the `SWE_AGENT_ENV_FILE` environment variable.- """-- def __init__(self, env_file: Optional[Path] = None):- self._env_file = env_file-- @property- def env_file(self) -> Path:- if self._env_file is None:- env_file = Path(os.environ.get("SWE_AGENT_ENV_FILE", "/root/.swe-agent-env"))- else:- env_file = self._env_file- if not env_file.exists():- env_file.write_text("{}")- return env_file-- def __getitem__(self, key: str) -> str:- return json.loads(self.env_file.read_text())[key]-- def get(self, key: str, default_value: Any = None) -> Any:- return json.loads(self.env_file.read_text()).get(key, default_value)-- def get_if_none(self, value: Any, key: str, default_value: Any = None) -> Any:- if value is not None:- return value- return self.get(key, default_value)-- def __setitem__(self, key: str, value: Any):- env = json.loads(self.env_file.read_text())- env[key] = value- self.env_file.write_text(json.dumps(env))---registry = EnvRegistry()+from registry import registryclass FileNotOpened(Exception):@@ -205,16 +164,14 @@ class WindowedFile:out_lines.append(f"({self.n_lines - end_line - 1} more lines below)")return "\n".join(out_lines)- def set_window_text(- self, new_text: str, *, line_range: Optional[Tuple[int, int]] = None- ) -> None:+ def set_window_text(self, new_text: str, *, line_range: Optional[Tuple[int, int]] = None) -> None:"""Replace the text in the current display window with a new string."""text = self.text.split("\n")if line_range is not None:start, stop = line_rangeelse:start, stop = self.line_range-+# Handle empty replacement text (deletion case)new_lines = new_text.split("\n") if new_text else []text[start : stop + 1] = new_lines@@ -313,14 +270,11 @@ class WindowedFile:def insert(self, text: str, line: Optional[int] = None, *, reset_first_line: str = "top") -> "InsertInfo":# Standardize empty text handlingif not text:- return InsertInfo(- first_inserted_line=(self.n_lines if line is None else line),- n_lines_added=0- )+ return InsertInfo(first_inserted_line=(self.n_lines if line is None else line), n_lines_added=0)# Remove single trailing newline if it existstext = text[:-1] if text.endswith("\n") else text-+if line is None:# Append to end of fileif not self.text:@@ -347,8 +301,5 @@ class WindowedFile:self.text = new_textif reset_first_line != "keep":self.goto(insert_line, mode=reset_first_line)-- return InsertInfo(- first_inserted_line=insert_line,- n_lines_added=len(text.split("\n"))- )++ return InsertInfo(first_inserted_line=insert_line, n_lines_added=len(text.split("\n")))diff --git a/tools/edit_anthropic/bin/str_replace_editor b/tools/edit_anthropic/bin/str_replace_editorindex c5984b93..756feb08 100644--- a/tools/edit_anthropic/bin/str_replace_editor+++ b/tools/edit_anthropic/bin/str_replace_editor@@ -14,6 +14,8 @@ from collections import defaultdictfrom pathlib import Pathfrom typing import Any, List, Optional+from registry import registry as REGISTRY+TRUNCATED_MESSAGE: str = "<response clipped><NOTE>To save on context only part of this file has been shown to you. You should retry this tool after you have searched inside the file with `grep -n` in order to find the line numbers of what you are looking for.</NOTE>"MAX_RESPONSE_LEN: int = 16000@@ -31,47 +33,6 @@ Command = strSNIPPET_LINES: int = 4-class EnvRegistry:- """Read and write variables into a file. This is used to persist state between tool- calls without using environment variables (which are problematic because you cannot- set them in a subprocess).-- The default file location is `/root/.swe-agent-env`, though this can be overridden- by the `env_file` argument or the `SWE_AGENT_ENV_FILE` environment variable.- """-- def __init__(self, env_file: Optional[Path] = None):- self._env_file = env_file-- @property- def env_file(self) -> Path:- if self._env_file is None:- env_file = Path(os.environ.get("SWE_AGENT_ENV_FILE", "/root/.swe-agent-env"))- else:- env_file = self._env_file- if not env_file.exists():- env_file.write_text("{}")- return env_file-- def __getitem__(self, key: str) -> str:- return json.loads(self.env_file.read_text())[key]-- def get(self, key: str, default_value: Any = None) -> Any:- return json.loads(self.env_file.read_text()).get(key, default_value)-- def get_if_none(self, value: Any, key: str, default_value: Any = None) -> Any:- if value is not None:- return value- return self.get(key, default_value)-- def __setitem__(self, key: str, value: Any):- env = json.loads(self.env_file.read_text())- env[key] = value- self.env_file.write_text(json.dumps(env))---REGISTRY = EnvRegistry()-class EditTool:"""diff --git a/tools/edit_linting/bin/edit b/tools/edit_linting/bin/editindex d83562e5..80c476ad 100644--- a/tools/edit_linting/bin/edit+++ b/tools/edit_linting/bin/edit@@ -13,7 +13,7 @@ else:assert default_lib.is_dir()sys.path.append(str(default_lib))-from default_utils import FileNotOpened, WindowedFile # type: ignore+from windowed_file import FileNotOpened, WindowedFile # type: ignorefrom flake8_utils import flake8, format_flake8_output # type: ignore_USAGE_MSG = """Usage: edit <start_line>:<end_line>diff --git a/tools/edit_replace/bin/edit b/tools/edit_replace/bin/editindex 317d8dca..3a5ab391 100644--- a/tools/edit_replace/bin/edit+++ b/tools/edit_replace/bin/edit@@ -13,7 +13,7 @@ else:assert default_lib.is_dir()sys.path.append(str(default_lib))-from default_utils import FileNotOpened, TextNotFound, WindowedFile # type: ignore+from windowed_file import FileNotOpened, TextNotFound, WindowedFile # type: ignorefrom flake8_utils import flake8, format_flake8_output # type: ignoreRETRY_WITH_OUTPUT_TOKEN = "###SWE-AGENT-RETRY-WITH-OUTPUT###"diff --git a/tools/edit_replace/bin/insert b/tools/edit_replace/bin/insertindex ebba8b80..6b4cbe96 100644--- a/tools/edit_replace/bin/insert+++ b/tools/edit_replace/bin/insert@@ -3,7 +3,7 @@import argparsefrom typing import Union-from default_utils import FileNotOpened, WindowedFile # type: ignore+from windowed_file import FileNotOpened, WindowedFile # type: ignorefrom flake8_utils import flake8, format_flake8_output # type: ignoreRETRY_WITH_OUTPUT_TOKEN = "###SWE-AGENT-RETRY-WITH-OUTPUT###"diff --git a/tools/edit_rewrite/bin/edit b/tools/edit_rewrite/bin/editindex 6c387647..eb25363d 100644--- a/tools/edit_rewrite/bin/edit+++ b/tools/edit_rewrite/bin/edit@@ -2,7 +2,7 @@import argparse-from default_utils import FileNotOpened, WindowedFile # type: ignore+from windowed_file import FileNotOpened, WindowedFile # type: ignorefrom flake8_utils import flake8, format_flake8_output # type: ignore_LINT_ERROR_TEMPLATE = """diff --git a/tools/defaults/bin/_read_env b/tools/registry/bin/_read_envsimilarity index 79%rename from tools/defaults/bin/_read_envrename to tools/registry/bin/_read_envindex 0dda8ab6..694739e5 100644--- a/tools/defaults/bin/_read_env+++ b/tools/registry/bin/_read_env@@ -2,7 +2,7 @@import sys-from default_utils import registry # type: ignore+from registry import registry # type: ignoreif __name__ == "__main__":var_name = sys.argv[1]diff --git a/tools/defaults/bin/_write_env b/tools/registry/bin/_write_envsimilarity index 78%rename from tools/defaults/bin/_write_envrename to tools/registry/bin/_write_envindex 0fb7683e..b94352c3 100644--- a/tools/defaults/bin/_write_env+++ b/tools/registry/bin/_write_env@@ -2,7 +2,7 @@import sys-from default_utils import registry # type: ignore+from registry import registry # type: ignoreif __name__ == "__main__":var_name = sys.argv[1]diff --git a/tools/registry/config.yaml b/tools/registry/config.yamlnew file mode 100644index 00000000..a2fa2036--- /dev/null+++ b/tools/registry/config.yaml@@ -0,0 +1 @@+tools: {}\ No newline at end of filediff --git a/tools/registry/install.sh b/tools/registry/install.shnew file mode 100644index 00000000..8b7a1ce6--- /dev/null+++ b/tools/registry/install.sh@@ -0,0 +1,8 @@+#!/usr/bin/env bash++# script_dir=$(dirname "$(readlink -f "$0")")+bundle_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )++# source "$script_dir/lib/utils.sh"++export PYTHONPATH=$PYTHONPATH:"$bundle_dir/lib"\ No newline at end of filediff --git a/tools/registry/lib/__init__.py b/tools/registry/lib/__init__.pynew file mode 100644index 00000000..e69de29bdiff --git a/tools/registry/lib/registry.py b/tools/registry/lib/registry.pynew file mode 100644index 00000000..18764989--- /dev/null+++ b/tools/registry/lib/registry.py@@ -0,0 +1,46 @@+import json+import os+from pathlib import Path+from typing import Any, List, Optional, Tuple, Union+++class EnvRegistry:+ """Read and write variables into a file. This is used to persist state between tool+ calls without using environment variables (which are problematic because you cannot+ set them in a subprocess).++ The default file location is `/root/.swe-agent-env`, though this can be overridden+ by the `env_file` argument or the `SWE_AGENT_ENV_FILE` environment variable.+ """++ def __init__(self, env_file: Optional[Path] = None):+ self._env_file = env_file++ @property+ def env_file(self) -> Path:+ if self._env_file is None:+ env_file = Path(os.environ.get("SWE_AGENT_ENV_FILE", "/root/.swe-agent-env"))+ else:+ env_file = self._env_file+ if not env_file.exists():+ env_file.write_text("{}")+ return env_file++ def __getitem__(self, key: str) -> str:+ return json.loads(self.env_file.read_text())[key]++ def get(self, key: str, default_value: Any = None) -> Any:+ return json.loads(self.env_file.read_text()).get(key, default_value)++ def get_if_none(self, value: Any, key: str, default_value: Any = None) -> Any:+ if value is not None:+ return value+ return self.get(key, default_value)++ def __setitem__(self, key: str, value: Any):+ env = json.loads(self.env_file.read_text())+ env[key] = value+ self.env_file.write_text(json.dumps(env))+++registry = EnvRegistry()