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: Show attempt number in batch status
Kilian Lieret2143606f789e
diff --git a/sweagent/agent/agents.py b/sweagent/agent/agents.pyindex 83d63227..e8a8f806 100644--- a/sweagent/agent/agents.py+++ b/sweagent/agent/agents.py@@ -316,6 +316,7 @@ class Agent:def setup_attempt(self, hard_reset: bool = False) -> None:"""Setup the agent for a new attempt."""+ self._chook.on_setup_attempt()self._i_attempt += 1self.info = AgentInfo()self.info["swe_agent_hash"] = get_agent_commit_hash()diff --git a/sweagent/agent/hooks/abstract.py b/sweagent/agent/hooks/abstract.pyindex 5b238987..fa4b127c 100644--- a/sweagent/agent/hooks/abstract.py+++ b/sweagent/agent/hooks/abstract.py@@ -29,6 +29,8 @@ class AbstractAgentHook:def on_run_done(self, *, trajectory: Trajectory, info: AgentInfo): ...+ def on_setup_attempt(self): ...+def on_model_query(self, *, messages: list[dict[str, str]], agent: str):"""Actually query the model with the complete history."""@@ -94,6 +96,10 @@ class CombinedAgentHook(AbstractAgentHook):for hook in self.hooks:hook.on_run_done(trajectory=trajectory, info=info)+ def on_setup_attempt(self):+ for hook in self.hooks:+ hook.on_setup_attempt()+def on_model_query(self, *, messages: list[dict[str, str]], agent: str):for hook in self.hooks:hook.on_model_query(messages=messages, agent=agent)diff --git a/sweagent/agent/hooks/status.py b/sweagent/agent/hooks/status.pyindex 9ebd785b..d49eb6af 100644--- a/sweagent/agent/hooks/status.py+++ b/sweagent/agent/hooks/status.py@@ -12,8 +12,9 @@ class SetStatusAgentHook(AbstractAgentHook):self._cost = 0.0self._i_attempt = 0- def on_setup_done(self):+ def on_setup_attempt(self):self._i_attempt += 1+ self._i_step = 0def _update(self, message: str):self._callable(self._id, message)