Skip to content

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(run_batch): handle JSON parsing errors in trajectory check (#1043)

Lucas6a83f2ee3da4
diff --git a/sweagent/run/run_batch.py b/sweagent/run/run_batch.py
index a1161535..5b1575e1 100644
--- a/sweagent/run/run_batch.py
+++ b/sweagent/run/run_batch.py
@@ -385,14 +385,20 @@ class RunBatch:
log_path.unlink()
return False
- data = json.loads(content)
- # If the trajectory has no exit status, it's incomplete and we will redo it
- exit_status = data["info"].get("exit_status", None)
- if exit_status == "early_exit" or exit_status is None:
- self.logger.warning(f"Found existing trajectory with no exit status: {log_path}. Removing.")
+ try:
+ data = json.loads(content)
+ # If the trajectory has no exit status, it's incomplete and we will redo it
+ exit_status = data["info"].get("exit_status", None)
+ if exit_status == "early_exit" or exit_status is None:
+ self.logger.warning(f"Found existing trajectory with no exit status: {log_path}. Removing.")
+ log_path.unlink()
+ return False
+ except Exception as e:
+ self.logger.error(f"Failed to check existing trajectory: {log_path}: {e}. Removing.")
+ # If we can't check the trajectory, we will redo it
log_path.unlink()
return False
-
+ # otherwise, we will skip it
self.logger.info(f"⏭️ Skipping existing trajectory: {log_path}")
return True