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]

Enh: Warn about LM retries

Kilian Lieretc8a390fe7458
diff --git a/sweagent/__init__.py b/sweagent/__init__.py
index 9e1cb4f7..af2b4fde 100644
--- a/sweagent/__init__.py
+++ b/sweagent/__init__.py
@@ -6,7 +6,7 @@ from git import Repo
__version__ = "0.7.0"
-from logging import WARNING, getLogger
+from logging import CRITICAL, WARNING, getLogger
from pathlib import Path
import swerex.utils.log as log_swerex
@@ -19,6 +19,7 @@ log_swerex.get_logger = partial(get_logger, emoji="🦖")
# See https://github.com/princeton-nlp/SWE-agent/issues/585
getLogger("datasets").setLevel(WARNING)
getLogger("numexpr.utils").setLevel(WARNING)
+getLogger("LiteLLM").setLevel(CRITICAL)
PACKAGE_DIR = Path(__file__).resolve().parent
assert PACKAGE_DIR.is_dir()
diff --git a/sweagent/agent/models.py b/sweagent/agent/models.py
index 7aab426d..435aac38 100644
--- a/sweagent/agent/models.py
+++ b/sweagent/agent/models.py
@@ -549,6 +549,8 @@ class LiteLLMModel(AbstractModel):
),
):
with attempt:
+ if attempt.retry_state.attempt_number > 1:
+ logger.warning(f"Retrying LM query: {attempt.retry_state}")
messages = self._history_to_messages(history)
result = self._query(messages)
return result