Skip to content

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.py
index 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 = True
assert 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.py
index edcc6932..bebac81e 100644
--- a/sweagent/environment/swe_env.py
+++ b/sweagent/environment/swe_env.py
@@ -7,7 +7,7 @@ from typing import Self
from pydantic import BaseModel, ConfigDict, Field
from swerex.deployment.abstract import AbstractDeployment
from swerex.deployment.config import DeploymentConfig, DockerDeploymentConfig, get_deployment
-from swerex.runtime.abstract import BashAction, CreateBashSessionRequest
+from swerex.runtime.abstract import BashAction, BashInterruptAction, CreateBashSessionRequest
from sweagent.environment.config.repo import Repo, RepoConfig
from 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,