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: Handling of 'exit' in human mode
Kilian Lieret39afec2443ee
diff --git a/sweagent/agent/agents.py b/sweagent/agent/agents.pyindex 8b7937d1..b030da51 100644--- a/sweagent/agent/agents.py+++ b/sweagent/agent/agents.py@@ -494,6 +494,9 @@ class Agent:"""Handles special actions like `skip`, `exit_cost`, etc."""assert self._env is not Noneassert self.tools is not None+ if action == "exit":+ self.logger.info("Exit command found. Stopping.")+ return "Exited", True, infoif action == "skip":observation = "Skipped"info["exit_status"] = "skipped"diff --git a/sweagent/environment/swe_env.py b/sweagent/environment/swe_env.pyindex 23802f26..4a70116b 100644--- a/sweagent/environment/swe_env.py+++ b/sweagent/environment/swe_env.py@@ -163,8 +163,12 @@ class SWEEnv:output: output from container"""if input.strip() == "exit":- asyncio.run(self.deployment.stop())- return ""+ self.close()+ # we shouldn't actually get here because `exit` should be handled by the agent,+ # So we need to make sure to quit here, because else we will have already closed the environment+ # and the agent will continue to run.+ msg = "Exit command found. This should usually be handled by the agent."+ raise RuntimeError(msg)self.logger.log(logging.TRACE, "Input:\n%s", input) # type: ignorer = asyncio.run(self.deployment.runtime.run_in_session(BashAction(command=input, timeout=timeout)))