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: Improve litellm retry warnings
Kilian Lieretbae96798926f
diff --git a/sweagent/__init__.py b/sweagent/__init__.pyindex af2b4fde..d2e3225a 100644--- a/sweagent/__init__.py+++ b/sweagent/__init__.py@@ -6,7 +6,7 @@ from git import Repo__version__ = "0.7.0"-from logging import CRITICAL, WARNING, getLogger+from logging import WARNING, getLoggerfrom pathlib import Pathimport swerex.utils.log as log_swerex@@ -19,7 +19,7 @@ log_swerex.get_logger = partial(get_logger, emoji="🦖")# See https://github.com/princeton-nlp/SWE-agent/issues/585getLogger("datasets").setLevel(WARNING)getLogger("numexpr.utils").setLevel(WARNING)-getLogger("LiteLLM").setLevel(CRITICAL)+getLogger("LiteLLM").setLevel(WARNING)PACKAGE_DIR = Path(__file__).resolve().parentassert PACKAGE_DIR.is_dir()diff --git a/sweagent/agent/models.py b/sweagent/agent/models.pyindex 435aac38..ed871242 100644--- a/sweagent/agent/models.py+++ b/sweagent/agent/models.py@@ -35,6 +35,9 @@ except ImportError:logger = get_logger("swea-lm", emoji="🤖")+litellm.suppress_debug_info = True++class RetryConfig(PydanticBaseModel):"""This configuration object specifies how many times to retry a failed LM API call."""@@ -550,7 +553,16 @@ class LiteLLMModel(AbstractModel):):with attempt:if attempt.retry_state.attempt_number > 1:- logger.warning(f"Retrying LM query: {attempt.retry_state}")+ exception_info = ""+ if attempt.retry_state.outcome is not None and attempt.retry_state.outcome.exception() is not None:+ exception = attempt.retry_state.outcome.exception()+ exception_info = f" due to {exception.__class__.__name__}: {str(exception)}"++ logger.warning(+ f"Retrying LM query: attempt {attempt.retry_state.attempt_number} "+ f"(slept for {attempt.retry_state.idle_for:.2f}s)"+ f"{exception_info}"+ )messages = self._history_to_messages(history)result = self._query(messages)return result