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]

Fix: Repo cloned to wrong folder (#515)

Kilian Lieret4b51fe12fbb4
diff --git a/sweagent/environment/swe_env.py b/sweagent/environment/swe_env.py
index 8343f030..6a97e358 100644
--- a/sweagent/environment/swe_env.py
+++ b/sweagent/environment/swe_env.py
@@ -234,7 +234,7 @@ class SWEEnv(gym.Env):
clone_url = f"https://{token_prefix}github.com/{self.record['repo']}.git"
if not keys_config.get("SWE_AGENT_EXPERIMENTAL_CLONE"):
self.communicate_with_handling(
- input=f"git clone {clone_url}",
+ input=f"git clone {clone_url} {self._repo_name}",
error_msg="Failed to clone repository from conservative method",
timeout_duration=LONG_TIMEOUT,
)
diff --git a/tests/test_env.py b/tests/test_env.py
index c354969e..3236dbdb 100644
--- a/tests/test_env.py
+++ b/tests/test_env.py
@@ -1,11 +1,11 @@
from __future__ import annotations
import dataclasses
-import os
import subprocess
import time
from contextlib import contextmanager
from pathlib import Path
+from unittest import mock
import pytest
import yaml
@@ -55,6 +55,13 @@ def test_init_swe_env(test_env_args):
env.reset()
+def test_init_swe_env_conservative_clone(test_env_args):
+ with mock.patch.dict("os.environ", {"SWE_AGENT_EXPERIMENTAL_CLONE": ""}):
+ with swe_env_context(test_env_args) as env:
+ env.reset()
+
+
@pytest.mark.slow()
def test_init_swe_env_non_persistent(test_env_args):
test_env_args = dataclasses.replace(test_env_args, container_name=None)
@@ -135,14 +142,9 @@ def test_interrupt_close(test_env_args):
@pytest.mark.slow()
def test_communicate_old(test_env_args):
- del os.environ["SWE_AGENT_EXPERIMENTAL_COMMUNICATE"]
- try:
+ with mock.patch.dict("os.environ", {"SWE_AGENT_EXPERIMENTAL_COMMUNICATE": ""}):
with swe_env_context(test_env_args) as env:
env.reset()
- except:
- raise
- finally:
- os.environ["SWE_AGENT_EXPERIMENTAL_COMMUNICATE"] = "1"
@pytest.mark.slow()