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]
Add proper _state command to anthropic tools
Kilian Lieretd4c2d6daa333
diff --git a/config/function_calling_anthropic_openhands.yaml b/config/function_calling_anthropic_openhands.yamlindex ea8a05e3..7bbfbaf3 100644--- a/config/function_calling_anthropic_openhands.yaml+++ b/config/function_calling_anthropic_openhands.yaml@@ -63,33 +63,20 @@ agent:5. Think about edgecases and make sure your fix handles them as wellYour thinking should be thorough and so it's fine if it's very long.- (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/function_calling_simple.trajput_demos_in_history: truetools:- env_variables:- WINDOW: 100- OVERLAP: 2bundles:- path: tools/edit_anthropic- path: tools/submitdiff --git a/tools/edit_anthropic/bin/_state_anthropic b/tools/edit_anthropic/bin/_state_anthropicnew file mode 100644index 00000000..ac0f2eca--- /dev/null+++ b/tools/edit_anthropic/bin/_state_anthropic@@ -0,0 +1,3 @@+#!/usr/bin/env bash++echo "{\"working_dir\": \"$(pwd)\"}"diff --git a/tools/edit_anthropic/bin/str_replace_editor b/tools/edit_anthropic/bin/str_replace_editorindex e6c900c9..3cd12d2a 100644--- a/tools/edit_anthropic/bin/str_replace_editor+++ b/tools/edit_anthropic/bin/str_replace_editor@@ -2,17 +2,17 @@"""This is an adaptation of the Anthropic Text Editor tool fromhttps://github.com/anthropics/anthropic-quickstarts/blob/main/computer-use-demo/computer_use_demo/tools/edit.py-However, we made it python 3.6 compatible.+However, we made it python 3.6 compatible and stateless (all state is saved in a json file)"""import argparse+import json+import osimport subprocessimport sysfrom collections import defaultdictfrom pathlib import Path-from typing import List, Optional, Any-import json-import os+from typing import Any, List, OptionalTRUNCATED_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 = 16000diff --git a/tools/edit_anthropic/config.yaml b/tools/edit_anthropic/config.yamlindex 2d91f712..d68fa98c 100644--- a/tools/edit_anthropic/config.yaml+++ b/tools/edit_anthropic/config.yaml@@ -40,3 +40,4 @@ tools:description: "Required for `insert`: Line number to insert text after."required: falseargument_format: "--insert_line {value}"+state_command: "_state_anthropic"\ No newline at end of file