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]

Enh(agent): Remove set_last_action

Kilian Lieretab8348e6fe7c
diff --git a/sweagent/agent/agents.py b/sweagent/agent/agents.py
index 02f646e1..713242ee 100644
--- a/sweagent/agent/agents.py
+++ b/sweagent/agent/agents.py
@@ -700,7 +700,6 @@ class Agent:
step.observation = self._env.communicate(
input=run_action,
timeout=self.tools.config.execution_timeout,
- set_last_action=True,
check="raise" if self._always_require_zero_exit_code else "ignore",
)
except CommandTimeoutError:
diff --git a/sweagent/environment/swe_env.py b/sweagent/environment/swe_env.py
index eabeedaa..bc780a51 100644
--- a/sweagent/environment/swe_env.py
+++ b/sweagent/environment/swe_env.py
@@ -176,7 +176,6 @@ class SWEEnv:
input: str,
timeout: int | float = 25,
*,
- set_last_action: bool = False,
check: Literal["warn", "ignore", "raise"] = "ignore",
error_msg: str = "Command failed",
) -> str:
@@ -186,7 +185,6 @@ class SWEEnv:
Args:
input: input to send to container
timeout_duration: duration to wait for output
- set_last_action: whether to set the LAST_ACTION environment variable
check: `ignore`: do not extract exit code (more stable), `warn`: extract exit code and log error if
exit code is non-zero, `raise`: raise error if exit code is non-zero
error_msg: error message to raise if the command fails
@@ -208,15 +206,6 @@ class SWEEnv:
if check == "raise":
self.close()
raise RuntimeError(msg)
- # todo: What do we do with this?
- if set_last_action:
- # Cannot merge this with last command, because of multiline command
- # handling.
- last_action_string = shlex.quote(input.strip())
- input = f"export LAST_ACTION={last_action_string}"
- r = asyncio.run(
- self.deployment.runtime.run_in_session(BashAction(command=input, timeout=1, check="ignore"))
- )
return output
def read_file(self, path: str | PurePath) -> str: