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(models): delay calculation

Kilian Lieret6e9bfbb487f6
diff --git a/sweagent/agent/models.py b/sweagent/agent/models.py
index f361ce49..8ff7cdcb 100644
--- a/sweagent/agent/models.py
+++ b/sweagent/agent/models.py
@@ -589,11 +589,11 @@ class LiteLLMModel(AbstractModel):
raise InstanceCostLimitExceededError(msg)
def _sleep(self) -> None:
- with GLOBAL_STATS_LOCK:
- GLOBAL_STATS.last_query_timestamp = time.time()
elapsed_time = time.time() - GLOBAL_STATS.last_query_timestamp
if elapsed_time < self.config.delay:
time.sleep(self.config.delay - elapsed_time)
+ with GLOBAL_STATS_LOCK:
+ GLOBAL_STATS.last_query_timestamp = time.time()
def _single_query(
self, messages: list[dict[str, str]], n: int | None = None, temperature: float | None = None