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: fix Windows path error, replace Path with PurePosixPath or string (#1052)

alwaysgoodtime3a07a665b739
diff --git a/sweagent/agent/agents.py b/sweagent/agent/agents.py
index 2de9d202..f8b4f1b9 100644
--- a/sweagent/agent/agents.py
+++ b/sweagent/agent/agents.py
@@ -5,7 +5,7 @@ import copy
import json
import logging
import time
-from pathlib import Path
+from pathlib import Path, PurePosixPath
from typing import Annotated, Any, Literal
import 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 patch
else None
diff --git a/sweagent/tools/tools.py b/sweagent/tools/tools.py
index 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 {}