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]

Doc: Document keywords of run.py (#443)

Kilian Lieret7032986cb4b1
diff --git a/run.py b/run.py
index 22622428..6fc1f601 100644
--- a/run.py
+++ b/run.py
@@ -57,6 +57,8 @@ python run.py --model_name "gpt4" --data_path "https://github.com/pvlib/pvlib-py
# Apply a patch in a local repository to an issue specified as Markdown file and run a custom installer script in the container
python run.py --model_name "gpt4" --data_path "/path/to/my_issue.md" --repo_path "/path/to/my/local/repo" --environment_setup "/path/to/setup.sh" --config_file "config/default_from_url.yaml" --apply_patch_locally
```
+
+**For more information**: https://princeton-nlp.github.io/SWE-agent/usage/cl_tutorial/
"""
handler = RichHandler(show_time=False, show_path=False)
@@ -96,8 +98,11 @@ class ScriptArguments(FlattenedAccess, FrozenSerializable):
environment: EnvironmentArguments
agent: AgentArguments
actions: ActionsArguments
- instance_filter: str = ".*" # Only run instances that completely match this regex
- skip_existing: bool = True # Skip instances with existing trajectories
+ # Only run instances that completely match this regex
+ instance_filter: str = ".*"
+ # Skip instances with existing trajectories
+ skip_existing: bool = True
+ # Suffix for the run name (used for example in trajectory directory naming)
suffix: str = ""
# Raise unhandled exceptions during the run (useful for debugging)
raise_exceptions: bool = False
diff --git a/sweagent/agent/models.py b/sweagent/agent/models.py
index fd67c500..61c8637d 100644
--- a/sweagent/agent/models.py
+++ b/sweagent/agent/models.py
@@ -32,12 +32,19 @@ logger.propagate = False
class ModelArguments(FrozenSerializable):
"""Arguments configuring the model and its behavior."""
+ # Name of the model to use
model_name: str
+ # Cost limit for every instance (task)
per_instance_cost_limit: float = 0.0
+ # Total cost limit
total_cost_limit: float = 0.0
+ # Sampling temperature
temperature: float = 1.0
+ # Sampling top-p
top_p: float = 1.0
+ # Path to replay file when using the replay model
replay_path: str = None
+ # Host URL when using Ollama model
host_url: str = "localhost:11434"
diff --git a/sweagent/environment/swe_env.py b/sweagent/environment/swe_env.py
index c87564b2..1f72c7c1 100644
--- a/sweagent/environment/swe_env.py
+++ b/sweagent/environment/swe_env.py
@@ -59,16 +59,27 @@ class EnvironmentArguments(FrozenSerializable):
# (`json`, `jsonl`) or directory. To run over single issue: github issue url or path to markdown file
# with problem statement or problem statement as text prefixed with `text://`.
data_path: str
- image_name: str
+ # Name of the docker image to use for the environment. Defaults to sweagent/swe-agent:latest
+ image_name: str = "sweagent/swe-agent:latest"
+ # When running over SWE-bench issues: Specify the split to use.
split: str = "dev"
# Specify a branch name or a commit hash to checkout before running the task.
# Only used when running over a single problem statement/issue.
base_commit: str | None = None
+ # Use a persistent container with this name
container_name: str | None = None
+ # Try to install the environment before running the task.
install_environment: bool = True
- timeout: int = 35
+ # No effect, kept for backwards compatibility.
+ timeout: int | None = None
+ # Enable environment logger.
verbose: bool = False
+ # Do not use attempt to use a repository mirror from https://github.com/swe-bench.
no_mirror: bool = False
+ # Cache task images to speed up task initialization. This means that the environment will be saved as a
+ # docker image for every repository and base commit combination. This uses quite a bit of disk space
+ # but speeds up task initialization significantly when running over multiple issues from the same repository
+ # (or using different models for the same issues).
cache_task_images: bool = False
# Custom environment setup. Currently only used when data_path points to a single issue.
# This needs to be either a string pointing to a yaml file (with yaml, yml file extension)
@@ -78,6 +89,10 @@ class EnvironmentArguments(FrozenSerializable):
# Only used when running on single issue. Path to local repository or github repository.
repo_path: str = ""
+ def __post_init__(self):
+ if self.timeout is not None:
+ logger.warning("The 'timeout' argument is deprecated and has no effect.")
+
class EnvHook:
def on_init(self): ...
@@ -137,8 +152,6 @@ class SWEEnv(gym.Env):
self.image_name = args.image_name
self._reset_container()
- # Set timeout
- self.timeout = self.args.timeout
self.idx = 0
self.clean_multi_line_functions = lambda x: x
self.hooks = []