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]
Add last message to history
Kilian Lieret44542b587d16
diff --git a/sweagent/agent/agents.py b/sweagent/agent/agents.pyindex 1da14489..e2999d90 100644--- a/sweagent/agent/agents.py+++ b/sweagent/agent/agents.py@@ -393,6 +393,8 @@ class Agent:"tool_calls": step.tool_calls,},)+ if step.done:+ returnif step.observation is None or step.observation.strip() == "":# Show no output template if observation content was empty@@ -769,11 +771,7 @@ class Agent:self._chook.on_step_start()step_output = self.forward_with_handling(self.local_history)- if not step_output.done:- # When we're done because of an error, the state might not be updated,- # and we might not be able to format the templates correctly. So let's just not- # add the history (because we stop anyway).- self.add_step_to_history(step_output)+ self.add_step_to_history(step_output)self.info["submission"] = step_output.submissionself.info["exit_status"] = step_output.exit_status # type: ignorediff --git a/tests/test_agent.py b/tests/test_agent.pyindex 48e14952..9666c36b 100644--- a/tests/test_agent.py+++ b/tests/test_agent.py@@ -177,7 +177,7 @@ def test_run_step_by_step_checking_history(dummy_env: SWEEnv, default_agent: Ageassert "Current directory: /root" in a.local_history[4]["content"]a.step()assert len(a.trajectory) == 3- assert len(a.local_history) == 5 # no message added if done==True+ assert len(a.local_history) == 6a.step()assert len(a.trajectory) == 4assert a.info["exit_status"] == "exit_cost" # type: ignore