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: fix Windows path error, replace Path with PurePosixPath or string (#1052)
alwaysgoodtime3a07a665b739
diff --git a/sweagent/agent/agents.py b/sweagent/agent/agents.pyindex 2de9d202..f8b4f1b9 100644--- a/sweagent/agent/agents.py+++ b/sweagent/agent/agents.py@@ -5,7 +5,7 @@ import copyimport jsonimport loggingimport time-from pathlib import Path+from pathlib import Path, PurePosixPathfrom typing import Annotated, Any, Literalimport yaml@@ -867,7 +867,9 @@ class DefaultAgent(AbstractAgent):pf = (PatchFormatter(patch,- read_method=lambda path: self._env.read_file(Path("/") / self._env.repo.repo_name / path), # type: ignore[attr-defined]+ read_method=lambda path: self._env.read_file(+ PurePosixPath("/") / self._env.repo.repo_name / path+ ), # type: ignore[attr-defined])if patchelse Nonediff --git a/sweagent/tools/tools.py b/sweagent/tools/tools.pyindex 7bcd534d..cfc66705 100644--- a/sweagent/tools/tools.py+++ b/sweagent/tools/tools.py@@ -263,7 +263,7 @@ class ToolHandler:def _get_state(self, env: SWEEnv) -> dict[str, str]:"""Retrieve the state from the environment"""try:- state_str = env.read_file(Path("/root/state.json"))+ state_str = env.read_file("/root/state.json")except FileNotFoundError:self.logger.warning("State file not found, returning empty state")return {}