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]
Add aliases for many command line options
Kilian Lieret8faa43011a39
diff --git a/sweagent/agent/agents.py b/sweagent/agent/agents.pyindex 2acc6921..f64818ba 100644--- a/sweagent/agent/agents.py+++ b/sweagent/agent/agents.py@@ -81,7 +81,7 @@ class AgentConfig(BaseModel):templates: TemplateConfig = Field(default_factory=TemplateConfig)tools: ToolConfig = Field(default_factory=ToolConfig)history_processor: HistoryProcessor = Field(default_factory=DefaultHistoryProcessor)- model: ModelConfig+ model: ModelConfig = Field(alias="m", description="Model options. Alias: `m` or `model`.")max_requeries: int = 3"""Maximum number of times to requery the model after an error, such as adiff --git a/sweagent/agent/models.py b/sweagent/agent/models.pyindex d12dca0e..0ccc5905 100644--- a/sweagent/agent/models.py+++ b/sweagent/agent/models.py@@ -37,12 +37,16 @@ class RetryConfig(PydanticBaseModel):class GenericAPIModelConfig(PydanticBaseModel):- name: str+ name: str = Field(alias="n", description="Model name. Alias: `n` or `name`.")"""Arguments configuring the model and its behavior."""- per_instance_cost_limit: float = 3.0- """Cost limit for every instance (task)"""- total_cost_limit: float = 0.0- """Total cost limit"""+ per_instance_cost_limit: float = Field(+ default=3.0,+ alias="ic",+ description="Cost limit for every instance (task). Alias: `ic` or `per_instance_cost_limit`.",+ )+ total_cost_limit: float = Field(+ default=0.0, alias="tc", description="Total cost limit. Alias: `tc` or `total_cost_limit`."+ )temperature: float = 1.0"""Sampling temperature"""top_p: float = 1.0@@ -71,11 +75,11 @@ class GenericAPIModelConfig(PydanticBaseModel):class ReplayModelConfig(GenericAPIModelConfig):- replay_path: Path- """Path to replay file when using the replay model"""+ replay_path: Path = Field(+ alias="p", description="Path to replay file when using the replay model. Alias: `p` or `replay_path`."+ )- name: Literal["replay"] = "replay"- """Do not change. Used for (de)serialization."""+ name: Literal["replay"] = Field(default="replay", alias="n", description="Model name. Alias: `n` or `name`.")model_config = ConfigDict(extra="forbid")@@ -83,8 +87,9 @@ class ReplayModelConfig(GenericAPIModelConfig):class InstantEmptySubmitModelConfig(GenericAPIModelConfig):"""Model that immediately submits an empty patch"""- name: Literal["instant_empty_submit"] = "instant_empty_submit"- """Do not change. Used for (de)serialization."""+ name: Literal["instant_empty_submit"] = Field(+ default="instant_empty_submit", alias="n", description="Model name. Alias: `n` or `name`."+ )delay: float = 0.0"""Delay before answering"""@@ -93,25 +98,25 @@ class InstantEmptySubmitModelConfig(GenericAPIModelConfig):class HumanModelConfig(GenericAPIModelConfig):- name: Literal["human"] = "human"- """Do not change. Used for (de)serialization."""+ name: Literal["human"] = Field(default="human", alias="n", description="Model name. Alias: `n` or `name`.")model_config = ConfigDict(extra="forbid")class HumanThoughtModelConfig(HumanModelConfig):- name: Literal["human_thought"] = "human_thought"- """Do not change. Used for (de)serialization."""+ name: Literal["human_thought"] = Field(+ default="human_thought", alias="n", description="Model name. Alias: `n` or `name`."+ )model_config = ConfigDict(extra="forbid")ModelConfig = Annotated[- ReplayModelConfig+ GenericAPIModelConfig+ | ReplayModelConfig| InstantEmptySubmitModelConfig| HumanModelConfig- | HumanThoughtModelConfig- | GenericAPIModelConfig,+ | HumanThoughtModelConfig,Field(union_mode="left_to_right"),]diff --git a/sweagent/environment/swe_env.py b/sweagent/environment/swe_env.pyindex d36b17d8..9102c97a 100644--- a/sweagent/environment/swe_env.py+++ b/sweagent/environment/swe_env.py@@ -18,9 +18,15 @@ class EnvironmentConfig(BaseModel):"""Configure data sources and setup instructions for the environment in which we solve the tasks."""deployment: DeploymentConfig = Field(- default_factory=lambda: DockerDeploymentConfig(image="sweagent/swe-agent:latest")+ default_factory=lambda: DockerDeploymentConfig(image="sweagent/swe-agent:latest"),+ validation_alias="d",+ description="Deployment options (alias: `d` or `deployment`).",+ )+ repo: RepoConfig | None = Field(+ default=None,+ validation_alias="r",+ description="Repository options (alias: `r` or `repo`).",)- repo: RepoConfig | None = None# fixme: Actually run thesestartup_commands: list[str] = []"""Execute these commands before starting to run the agent. They will be executed in the samediff --git a/sweagent/run/batch_instances.py b/sweagent/run/batch_instances.pyindex 67c434ea..985ad2cf 100644--- a/sweagent/run/batch_instances.py+++ b/sweagent/run/batch_instances.py@@ -169,7 +169,9 @@ class InstancesFromFile(BaseModel, AbstractInstanceSource):"""Shuffle the instances (before filtering and slicing)."""deployment: DeploymentConfig = Field(- default_factory=lambda: DockerDeploymentConfig(image="sweagent/swe-agent:latest")+ default_factory=lambda: DockerDeploymentConfig(image="sweagent/swe-agent:latest"),+ alias="d",+ description="Deployment options. Alias: `d` or `deployment`.",)"""Note that the image_name option is overwritten by the images specified in the task instances."""@@ -206,7 +208,9 @@ class InstancesFromHuggingFace(BaseModel, AbstractInstanceSource):"""Shuffle the instances (before filtering and slicing)."""deployment: DeploymentConfig = Field(- default_factory=lambda: DockerDeploymentConfig(image="sweagent/swe-agent:latest")+ default_factory=lambda: DockerDeploymentConfig(image="sweagent/swe-agent:latest"),+ alias="d",+ description="Deployment options. Alias: `d` or `deployment`.",)"""Deployment configuration. Note that the image_name option is overwritten by the images specified in the task instances."""@@ -234,7 +238,9 @@ class SWEBenchInstances(BaseModel, AbstractInstanceSource):split: Literal["dev", "test"] = "dev"deployment: DeploymentConfig = Field(- default_factory=lambda: DockerDeploymentConfig(image="sweagent/swe-agent:latest")+ default_factory=lambda: DockerDeploymentConfig(image="sweagent/swe-agent:latest"),+ alias="d",+ description="Deployment options. Alias: `d` or `deployment`.",)"""Deployment configuration. Note that the image_name option is overwritten by the images specified in the task instances."""diff --git a/sweagent/run/run_batch.py b/sweagent/run/run_batch.pyindex 50ca9ff8..02b7cade 100644--- a/sweagent/run/run_batch.py+++ b/sweagent/run/run_batch.py@@ -13,6 +13,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completedfrom pathlib import Pathfrom typing import Self+from pydantic import Fieldfrom pydantic_settings import BaseSettingsfrom rich.live import Livefrom swerex.deployment.hooks.status import SetStatusDeploymentHook@@ -39,15 +40,18 @@ from sweagent.utils.log import (class RunBatchConfig(BaseSettings, cli_implicit_flags=True):- instances: BatchInstanceSourceConfig- agent: AgentConfig- output_dir: Path = Path("DEFAULT")+ instances: BatchInstanceSourceConfig = Field(alias="i", description="Instances to run. Alias: `i` or `instances`.")+ agent: AgentConfig = Field(alias="a", description="Agent options. Alias: `a` or `agent`.")+ output_dir: Path = Field(+ default=Path("DEFAULT"), validation_alias="o", description="Output directory. Alias: `o` or `output_dir`."+ )raise_exceptions: bool = Falseredo_existing: bool = Falseenv_var_path: Path | None = None"""Path to a .env file to load environment variables from."""- num_workers: int = 1- """Number of parallel workers to use. Default is 1 (sequential execution)."""+ num_workers: int = Field(+ default=1, alias="nw", description="Number of parallel workers to use. Alias: `nw` or `num_workers`."+ )random_delay_multiplier: float = 0.3"""We will wait for a random amount of time between 0 and `random_delay_multiplier`times the number of workers at the start of each instance. This is to avoid anydiff --git a/sweagent/run/run_single.py b/sweagent/run/run_single.pyindex b061d5a8..4d870734 100644--- a/sweagent/run/run_single.py+++ b/sweagent/run/run_single.py@@ -35,13 +35,18 @@ class RunSingleActionConfig(BaseModel, cli_implicit_flags=True):class RunSingleConfig(BaseSettings, cli_implicit_flags=True):- env: EnvironmentConfig = Field(default_factory=EnvironmentConfig)- agent: AgentConfig- problem_statement: ProblemStatementConfig = Field(default_factory=EmptyProblemStatement)- output_dir: Path = Path("DEFAULT")- """Directory to save the trajectory and similar output files to. If None, a default location- based on user ID, problem statement ID and model is used.- """+ env: EnvironmentConfig = Field(+ default_factory=EnvironmentConfig, validation_alias="e", description="Environment options."+ )+ agent: AgentConfig = Field(validation_alias="a", description="Agent options. Alias: `a` or `agent`.")+ problem_statement: ProblemStatementConfig = Field(+ default_factory=EmptyProblemStatement,+ validation_alias="ps",+ description="Problem statement options. Alias: `ps` or `problem_statement`.",+ )+ output_dir: Path = Field(+ default=Path("DEFAULT"), validation_alias="o", description="Output directory. Alias: `o` or `output_dir`."+ )actions: RunSingleActionConfig = Field(default_factory=RunSingleActionConfig)