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: Support for uparrow/downarrow in human models
Kilian Lieretef98aa7c4e9c
diff --git a/.gitignore b/.gitignoreindex ed7f2da8..4cd3b831 100644--- a/.gitignore+++ b/.gitignore@@ -1,3 +1,4 @@+.swe-agent-human-history.vscode/**cov.xmltrajectories/**diff --git a/sweagent/agent/models.py b/sweagent/agent/models.pyindex 633984d5..833bdb00 100644--- a/sweagent/agent/models.py+++ b/sweagent/agent/models.py@@ -20,10 +20,16 @@ from tenacity import (wait_random_exponential,)+from sweagent import REPO_ROOTfrom sweagent.tools.tools import ToolConfigfrom sweagent.types import History, HistoryItemfrom sweagent.utils.log import get_logger+try:+ import readline # noqa: F401+except ImportError:+ readline = None+logger = get_logger("swea-lm", emoji="🤖")@@ -173,10 +179,27 @@ class HumanModel(AbstractModel):self.multi_line_command_endings = {command.name: command.end_name for command in tools.commands if command.end_name is not None}+ self._readline_histfile = REPO_ROOT / ".swe-agent-human-history"+ self._load_readline_history()++ def _load_readline_history(self) -> None:+ """Load autocomplete history from file"""+ if readline is None:+ return+ if self._readline_histfile.is_file():+ logger.debug(f"Loading readline history from {self._readline_histfile}")+ readline.read_history_file(self._readline_histfile)++ def _save_readline_history(self) -> None:+ """Save autocomplete history to file"""+ if readline is None:+ return+ readline.write_history_file(self._readline_histfile)def _query(self, history: History, action_prompt: str = "> ") -> dict:"""Logic for handling user input to pass to SWEEnv"""action = input(action_prompt)+ self._save_readline_history()command_name = action.split()[0] if action.strip() else ""# Special handling for multi-line input actions (i.e. edit)