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]
added challenge information to all_preds
Talor Abramovichd2f521dff927
diff --git a/run.py b/run.pyindex da56d15e..572915df 100644--- a/run.py+++ b/run.py@@ -381,7 +381,7 @@ class Main:traj_dir=self.traj_dir,return_type="info_trajectory",)- self._save_predictions(instance_id, info)+ self._save_predictions(instance_id, info, challenge)for hook in self.hooks:hook.on_instance_completed(info=info, trajectory=trajectory)@@ -467,7 +467,7 @@ class Main:logger.info(f"⏭️ Skipping existing trajectory: {log_path}")return True- def _save_predictions(self, instance_id: str, info):+ def _save_predictions(self, instance_id: str, info, challenge: dict[str, str] | None):output_file = self.traj_dir / "all_preds.jsonl"model_patch = info["submission"] if "submission" in info else Nonedatum = {@@ -475,6 +475,13 @@ class Main:KEY_INSTANCE_ID: instance_id,KEY_PREDICTION: model_patch,}+ if challenge is not None:+ challenge_datum = {+ "challenge_name": challenge["name"],+ "challenge_category": challenge["category"],+ "challenge_path": challenge["file_path"],+ }+ datum.update(challenge_datum)with open(output_file, "a+") as fp:print(json.dumps(datum), file=fp, flush=True)logger.info(f"Saved predictions to {output_file}")diff --git a/sweagent/environment/utils.py b/sweagent/environment/utils.pyindex 0410d459..1f9eefc4 100644--- a/sweagent/environment/utils.py+++ b/sweagent/environment/utils.py@@ -629,6 +629,7 @@ class InstanceBuilder:self.args["challenge"]["docker_compose"] = (Path(file_path).parent / "docker-compose.yml")self.args["challenge"]["port"] = challenge.get("internal_port")self.args["challenge"]["server_name"] = challenge.get("box")+ self.args["challenge"]["file_path"] = file_pathself.set_server_description(self.args["challenge"]["server_name"], self.args["challenge"]["port"])self.set_problem_statement_from_text(f"{challenge['name']} {challenge['description']}")