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]
Fix: Handling of long problem statements
Kilian Lieret663a00e82c83
diff --git a/sweagent/environment/utils.py b/sweagent/environment/utils.pyindex 8f1149b2..8cd361c5 100644--- a/sweagent/environment/utils.py+++ b/sweagent/environment/utils.py@@ -31,10 +31,12 @@ GITHUB_REPO_URL_PATTERN = re.compile(r'.*[/@]?github\.com\/([^/]+)\/([^/]+)')logger = logging.getLogger(LOGGER_NAME)-def get_data_path_name(data_path: str):+def get_data_path_name(data_path: str) -> str:""" if data_path is a file, return the file stemelif it's a github url, return the owner__repo_name"""+ if data_path.startswith("text://"):+ return hashlib.sha256(data_path.removeprefix("text://").encode()).hexdigest()[:6]match = GITHUB_ISSUE_URL_PATTERN.search(data_path)if match:owner, repo, _ = match.groups()@@ -588,7 +590,7 @@ def get_instances(pass# The next if statement is very brittle logic to determine if we're processing a single instance- if (Path(file_path).is_file() and Path(file_path).suffix in ['.md', '.txt']) or is_github_issue_url(file_path) or file_path.startswith("text://"):+ if file_path.startswith("text://") or (Path(file_path).is_file() and Path(file_path).suffix in ['.md', '.txt']):ib = InstanceBuilder(token=token)ib.set_problem_statement(file_path)if repo_path:diff --git a/sweagent/frontend/src/components/controls/LRunControl.js b/sweagent/frontend/src/components/controls/LRunControl.jsindex 01ab87c7..d7e66e31 100644--- a/sweagent/frontend/src/components/controls/LRunControl.js+++ b/sweagent/frontend/src/components/controls/LRunControl.js@@ -28,7 +28,9 @@ function LRunControl({const defaultInstallCommand = "pip install --editable .";const defaultPS =- "https://github.com/marshmallow-code/marshmallow/issues/1359";+ "https://github.com/marshmallow-code/marshmallow/issues/1357";++ const defaultRepo = "https://github.com/swe-agent-demo/marshmallow";const handlePsTypeChange = (event) => {const selectedType = event.target.value;@@ -45,8 +47,9 @@ function LRunControl({<inputtype="text"className="form-control"- onChange={(e) => setDataPath(e.target.value || defaultPS)}- placeholder={defaultPS}+ onChange={(e) => setDataPath(e.target.value)}+ placeholder={"Example: " + defaultPS}+ defaultValue=""/></div>);@@ -62,6 +65,7 @@ function LRunControl({className="form-control"onChange={(e) => setDataPath(e.target.value)}placeholder="/path/to/your/local/file.md"+ defaultValue=""/></div>);@@ -239,8 +243,9 @@ function LRunControl({<inputtype="text"className="form-control"- placeholder="Optional when using GitHub issue as problem source"+ placeholder="Optional when using GitHub issue as problem source."onChange={(e) => setRepoPath(e.target.value)}+ defaultValue=""/></div></div>