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]

Exit after 3 exit_cost

Kilian Lieretad00aabfbe70
diff --git a/config/default_retry_5_2_0_choo2.yaml b/config/default_retry_5_2_0_choo3.yaml
similarity index 99%
rename from config/default_retry_5_2_0_choo2.yaml
rename to config/default_retry_5_2_0_choo3.yaml
index 388fb63c..91ce6d8d 100644
--- a/config/default_retry_5_2_0_choo2.yaml
+++ b/config/default_retry_5_2_0_choo3.yaml
@@ -279,3 +279,4 @@ review_loop_config:
max_samples: 5
min_draws: 2
max_accepted_draws: 0
+ max_n_consec_exit_cost: 3
diff --git a/sweagent/agent/reviewer.py b/sweagent/agent/reviewer.py
index 04f687c2..5dad8472 100644
--- a/sweagent/agent/reviewer.py
+++ b/sweagent/agent/reviewer.py
@@ -175,6 +175,9 @@ class ReviewLoopConfig(FrozenSerializable):
#: not reached the `min_draws`, we will stop if we have accepted
#: `max_accepted_draws` submissions.
max_accepted_draws: int = 0
+ #: If set > 0 and there are more than this number of consecutive attempts
+ #: with an 'exit cost' exit stats, the review loop will quit.
+ max_n_consec_exit_cost: int = 0
def validate(self):
"""Checks config. Raises `ValueError` in case of misconfiguration"""
@@ -423,6 +426,8 @@ class ReviewLoop(AbstractReviewLoop):
# top through k calls to the binary reviewer. Here, we store the
# corresponding index
self._best_idx: int = 0
+ #: Number of consecutive exit cost submissions
+ self._n_consec_exit_cost: int = 0
@property
def reviews(self) -> list[ReviewerResult]:
@@ -452,6 +457,10 @@ class ReviewLoop(AbstractReviewLoop):
def _review(self) -> bool:
review = self._reviewer.review(self._instance, self._submissions[-1])
self._reviews.append(review)
+ if "exit_cost" in self._submissions[-1].info.get("exit_status", "").lower():
+ self._n_consec_exit_cost += 1
+ else:
+ self._n_consec_exit_cost = 0
return review.accept
def _compare(self) -> None:
@@ -500,6 +509,13 @@ class ReviewLoop(AbstractReviewLoop):
logger.info(f"{self.LOG_PREFIX}Exiting retry loop ({stat_str}): `max_accepted_draws` reached")
return False
+ max_n_exit_cost = self._loop_config.max_n_consec_exit_cost
+ if self._n_consec_exit_cost >= max_n_exit_cost > 0:
+ logger.info(
+ f"{self.LOG_PREFIX}Exiting retry loop ({stat_str}): {max_n_exit_cost} exit cost attempts reached"
+ )
+ return False
+
return True
def get_best(self) -> int: