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]

Critical fix(retry-a): Avoid corruption of cost data

Kilian Lieretf2a913619b35
diff --git a/sweagent/agent/agents.py b/sweagent/agent/agents.py
index 9142f3e0..dd374001 100644
--- a/sweagent/agent/agents.py
+++ b/sweagent/agent/agents.py
@@ -311,9 +311,11 @@ class RetryAgent(AbstractAgent):
if best_attempt_idx is None:
data = {"info": {}}
else:
+ # Very important to deepcopy the best attempt data, because we will overwrite
+ # the stats with the total stats below.
data = {
"attempts": self._attempt_data,
- **self._attempt_data[best_attempt_idx],
+ **copy.deepcopy(self._attempt_data[best_attempt_idx]),
}
data["info"]["best_attempt_idx"] = best_attempt_idx
data["info"]["rloop_model_stats"] = self._rloop._model.stats.model_dump()