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]

Merge remote-tracking branch 'refs/remotes/origin/swerex-integration' into swerex-integration

carlosejimenez6774ef030042
diff --cc sweagent/run/run_replay.py
index 9a0f8b5f,8ebce732..0d7d9804
--- a/sweagent/run/run_replay.py
+++ b/sweagent/run/run_replay.py
@@@ -7,21 -7,17 +7,18 @@@ from getpass import getuse
from pathlib import Path
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 swerex.deployment.config import DeploymentConfig, get_deployment
from typing_extensions import Self
- from sweagent import CONFIG_DIR
- from sweagent.agent.agents import Agent, AgentConfig
+ from sweagent.agent.agents import Agent
from sweagent.agent.models import ReplayModelConfig
from sweagent.environment.config.problem_statement import EmptyProblemStatement
- from sweagent.environment.config.repo import RepoConfig
from sweagent.environment.swe_env import SWEEnv
from sweagent.run.common import BasicCLI
- from sweagent.run.run_single import RunSingle
+ from sweagent.run.run_single import RunSingle, RunSingleConfig
from sweagent.utils.config import load_environment_variables
from sweagent.utils.log import get_logger
@@@ -66,6 -54,23 +55,26 @@@ class RunReplay
self._catch_errors = _catch_errors
self._require_zero_exit_code = _require_zero_exit_code
- self._traj_data = json.loads(traj_path.read_text())
++ if traj_path.suffix == ".yaml":
++ self._traj_data = yaml.safe_load(traj_path.read_text())
++ else:
++ self._traj_data = json.loads(traj_path.read_text())
+ self.config = self._get_config_from_agent(self._traj_data)
+
+ if deployment is None:
+ self.deployment = get_deployment(self.config.env.deployment)
+ else:
+ self.deployment = deployment
+
+ def _get_config_from_agent(self, traj_data):
+ try:
+ config = RunSingleConfig.model_validate(self._traj_data["replay_config"])
+ except KeyError:
+ msg = "Replay config not found in trajectory. Are you running on an old trajectory?"
+ raise ValueError(msg)
+ config.agent.model = ReplayModelConfig(replay_path=self._replay_action_trajs_path)
+ return config
+
@property
def instance_id(self) -> str:
return Path(self.traj_path).stem