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]
Run batch: Show running cost per instance
Kilian Lieretc2ff831c97f7
diff --git a/sweagent/agent/agents.py b/sweagent/agent/agents.pyindex afb4af32..3a7d1fb7 100644--- a/sweagent/agent/agents.py+++ b/sweagent/agent/agents.py@@ -689,7 +689,7 @@ class Agent:self.add_step_to_trajectory(step_output)- self._chook.on_step_done(step=step_output)+ self._chook.on_step_done(step=step_output, info=self.info)return step_outputdef run(diff --git a/sweagent/agent/hooks/abstract.py b/sweagent/agent/hooks/abstract.pyindex 8b1f9f13..3cc59164 100644--- a/sweagent/agent/hooks/abstract.py+++ b/sweagent/agent/hooks/abstract.py@@ -25,7 +25,7 @@ class AbstractAgentHook:def on_action_executed(self, *, step: StepOutput): ...- def on_step_done(self, *, step: StepOutput): ...+ def on_step_done(self, *, step: StepOutput, info: AgentInfo): ...def on_run_done(self, *, trajectory: Trajectory, info: AgentInfo): ...@@ -81,9 +81,9 @@ class CombinedAgentHook(AbstractAgentHook):for hook in self.hooks:hook.on_action_executed(step=step)- def on_step_done(self, *, step: StepOutput):+ def on_step_done(self, *, step: StepOutput, info: AgentInfo):for hook in self.hooks:- hook.on_step_done(step=step)+ hook.on_step_done(step=step, info=info)def on_run_done(self, *, trajectory: Trajectory, info: AgentInfo):for hook in self.hooks:diff --git a/sweagent/agent/hooks/status.py b/sweagent/agent/hooks/status.pyindex 3cc3d456..f7781935 100644--- a/sweagent/agent/hooks/status.py+++ b/sweagent/agent/hooks/status.py@@ -1,6 +1,7 @@from collections.abc import Callablefrom sweagent.agent.hooks.abstract import AbstractAgentHook+from sweagent.types import AgentInfo, StepOutputclass SetStatusAgentHook(AbstractAgentHook):@@ -8,10 +9,14 @@ class SetStatusAgentHook(AbstractAgentHook):self._callable = callableself._id = idself._i_step = 0+ self._cost = 0.0def _update(self, message: str):self._callable(self._id, message)def on_step_start(self):self._i_step += 1- self._update(f"Step {self._i_step}")+ self._update(f"Step {self._i_step} ({self._cost:.2f}$)")++ def on_step_done(self, *, step: StepOutput, info: AgentInfo):+ self._cost = info.get("cost", 0.0)diff --git a/sweagent/run/_progress.py b/sweagent/run/_progress.pyindex 61a472cc..3ce521ef 100644--- a/sweagent/run/_progress.py+++ b/sweagent/run/_progress.py@@ -62,13 +62,14 @@ class RunBatchProgressManager:t = Table()t.add_column("Exit Status")t.add_column("Count")- t.add_column("Most recent")+ t.add_column("Most recent instances")t.show_header = Falsewith self._lock:t.show_header = True# self._exit_status_table.rows.clear()for status, instances in self._instances_by_exit_status.items():- t.add_row(status, str(len(instances)), instances[-1])+ instances_str = ", ".join(reversed(instances))[:40]+ t.add_row(status, str(len(instances)), instances_str)assert self.render_group is not Noneself.render_group.renderables[0] = t