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]
Interrupt running processes when attempting autosubmit
Kilian Lieret3fb48af49fa6
diff --git a/sweagent/agent/agents.py b/sweagent/agent/agents.pyindex 4eefad1c..30fb3fab 100644--- a/sweagent/agent/agents.py+++ b/sweagent/agent/agents.py@@ -464,6 +464,10 @@ class Agent:step = step.model_copy()step.done = Trueassert self._env is not None+ try:+ self._env.interrupt_session()+ except Exception as e:+ self.logger.debug("Failed to interrupt session before autosubmit: %s. Ignoring.", e)try:observation = self._env.communicate(input="submit")except Exception as e:diff --git a/sweagent/environment/swe_env.py b/sweagent/environment/swe_env.pyindex edcc6932..bebac81e 100644--- a/sweagent/environment/swe_env.py+++ b/sweagent/environment/swe_env.py@@ -7,7 +7,7 @@ from typing import Selffrom pydantic import BaseModel, ConfigDict, Fieldfrom swerex.deployment.abstract import AbstractDeploymentfrom swerex.deployment.config import DeploymentConfig, DockerDeploymentConfig, get_deployment-from swerex.runtime.abstract import BashAction, CreateBashSessionRequest+from swerex.runtime.abstract import BashAction, BashInterruptAction, CreateBashSessionRequestfrom sweagent.environment.config.repo import Repo, RepoConfigfrom sweagent.environment.hooks.abstract import CombinedEnvHooks, EnvHook@@ -163,6 +163,9 @@ class SWEEnv:asyncio.run(self.deployment.runtime.create_session(CreateBashSessionRequest(startup_source=["/root/.bashrc"])))self.logger.info("Environment Initialized")+ def interrupt_session(self):+ asyncio.run(self.deployment.runtime.run_in_session(BashInterruptAction()))+def communicate(self,input: str,