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]
Remove debug messages; print PR URL; open PR as draft
Kilian Lieretc61f0c9b8cd2
diff --git a/sweagent/environment/swe_env.py b/sweagent/environment/swe_env.pyindex cffbda96..5a9f1654 100644--- a/sweagent/environment/swe_env.py+++ b/sweagent/environment/swe_env.py@@ -682,32 +682,32 @@ class SWEEnv(gym.Env):branch_name = "swe-agent-patch-branch-" + str(random.random())[2:10]issue_url = self.args.data_path- logger.debug(self.communicate_with_handling(+ self.communicate_with_handling(input=f"rm model.patch",error_msg="Failed to remove model patch",timeout_duration=10,- ))- logger.debug(self.communicate_with_handling(+ )+ self.communicate_with_handling(input=f"git checkout -b {branch_name}",error_msg="Failed to switch to new branch",timeout_duration=10,- ))- logger.debug(self.communicate_with_handling(+ )+ self.communicate_with_handling(input=f"git add .",error_msg="Failed to add commits",timeout_duration=10,- ))+ )issue = get_gh_issue_data(issue_url, token=self.token)- logger.debug(self.communicate_with_handling(+ self.communicate_with_handling(input=f"git commit -m 'Fix: {issue.title}' -m 'Closes #{issue.number}' ",error_msg="Failed to commit changes",timeout_duration=10,- ))- logger.debug(self.communicate_with_handling(+ )+ self.communicate_with_handling(input=f"git push origin {branch_name}",- error_msg="Failed to clone repository from mirror",+ error_msg="Failed to push branch to origin",timeout_duration=10,- ))+ )# todo: add representation of trajectory to PR bodybody = (@@ -716,11 +716,13 @@ class SWEEnv(gym.Env):)api = GhApi(token=self.token)owner, repo, _ = parse_gh_issue_url(issue_url)- api.pulls.create(+ pr_info = api.pulls.create(owner=owner,repo=repo,title=f"SWE-agent[bot] PR to fix: {issue.title}",head=branch_name,base="main",body=body,- )\ No newline at end of file+ draft=True,+ )+ logger.info(f"PR created as a draft at {pr_info.html_url}")\ No newline at end of file