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: Import "Self" compatible with < py3.11

Kilian Lieret2b31a45a3dc6
diff --git a/sweagent/agent/agents.py b/sweagent/agent/agents.py
index 3a7d1fb7..8e69fa84 100644
--- a/sweagent/agent/agents.py
+++ b/sweagent/agent/agents.py
@@ -5,12 +5,13 @@ import json
import time
from collections import defaultdict
from pathlib import Path
-from typing import Any, Self
+from typing import Any
from pydantic import BaseModel, ConfigDict, Field
from simple_parsing.helpers.fields import field
from swerex.exceptions import BashIncorrectSyntaxError, SweRexception
from tenacity import RetryError
+from typing_extensions import Self
from sweagent import __version__, get_agent_commit_hash
from sweagent.agent.history_processors import DefaultHistoryProcessor, HistoryProcessor
diff --git a/sweagent/agent/hooks/status.py b/sweagent/agent/hooks/status.py
index f7781935..340d9ac2 100644
--- a/sweagent/agent/hooks/status.py
+++ b/sweagent/agent/hooks/status.py
@@ -16,7 +16,7 @@ class SetStatusAgentHook(AbstractAgentHook):
def on_step_start(self):
self._i_step += 1
- self._update(f"Step {self._i_step} ({self._cost:.2f}$)")
+ self._update(f"Step {self._i_step} (${self._cost:.2f})")
def on_step_done(self, *, step: StepOutput, info: AgentInfo):
self._cost = info.get("cost", 0.0)
diff --git a/sweagent/environment/config/repo.py b/sweagent/environment/config/repo.py
index a1e6a6eb..7a1779b3 100644
--- a/sweagent/environment/config/repo.py
+++ b/sweagent/environment/config/repo.py
@@ -1,7 +1,7 @@
import asyncio
import os
from pathlib import Path
-from typing import Literal, Protocol, Self
+from typing import Literal, Protocol
import pydantic
from git import InvalidGitRepositoryError
@@ -9,6 +9,7 @@ from git import Repo as GitRepo
from pydantic import BaseModel
from swerex.deployment.abstract import AbstractDeployment
from swerex.runtime.abstract import Command, UploadRequest
+from typing_extensions import Self
from sweagent.utils.log import get_logger
diff --git a/sweagent/run/batch_instances.py b/sweagent/run/batch_instances.py
index 5752c934..90a31004 100644
--- a/sweagent/run/batch_instances.py
+++ b/sweagent/run/batch_instances.py
@@ -2,7 +2,7 @@ import json
import re
from abc import ABC, abstractmethod
from pathlib import Path
-from typing import Any, Literal, Self
+from typing import Any, Literal
import yaml
from pydantic import BaseModel, Field
@@ -12,6 +12,7 @@ from swerex.deployment.config import (
DummyDeploymentConfig,
LocalDeploymentConfig,
)
+from typing_extensions import Self
from sweagent.environment.config.problem_statement import ProblemStatementConfig, TextProblemStatement
from sweagent.environment.config.repo import PreExistingRepo
diff --git a/sweagent/run/run_replay.py b/sweagent/run/run_replay.py
index eba0d574..82f32eaf 100644
--- a/sweagent/run/run_replay.py
+++ b/sweagent/run/run_replay.py
@@ -5,13 +5,14 @@ import sys
import tempfile
from getpass import getpass
from pathlib import Path
-from typing import Any, Self
+from typing import Any
import yaml
from pydantic import Field
from pydantic_settings import BaseSettings
from swerex.deployment.abstract import AbstractDeployment
from swerex.deployment.config import DeploymentConfig, DockerDeploymentConfig, get_deployment
+from typing_extensions import Self
from sweagent import CONFIG_DIR
from sweagent.agent.agents import Agent, AgentConfig
diff --git a/sweagent/tools/tools.py b/sweagent/tools/tools.py
index 29e3606a..fe940912 100644
--- a/sweagent/tools/tools.py
+++ b/sweagent/tools/tools.py
@@ -3,12 +3,13 @@ import json
import re
from functools import cached_property
from pathlib import Path
-from typing import Any, Self
+from typing import Any
import yaml
from pydantic import BaseModel, Field
from swerex.runtime.abstract import Command as RexCommand
from swerex.runtime.abstract import UploadRequest
+from typing_extensions import Self
from sweagent.environment.swe_env import SWEEnv
from sweagent.tools.commands import Command, ParseCommand, ParseCommandBash