Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions .cursor/rules/project-overview.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@ description:
globs:
alwaysApply: true
---
# SWE-agent overview
# PhoenixRepair

SWE-agent implements an AI software engineering agent that uses language models to
fix github issues.
Here's what you need to know about the project structure:

- The main entry points to running are in the `sweagent/run`, in particular `run_single.py` and `run_batch.py`, where the latter is used for benchmarking.
- The main class that governs agent behavior is `sweagent/agent/agents.py`
- The AI agent proposes actions that are executed in sandboxed docker containers
- At the beginning of an agent class, we initialize a `SWEEnv` class from `sweagent/environment/swe_env.py`. This class interfaces with the SWE-ReX project to interface with the sandboxed docker containers
- Part of the SWE-agent project are tools in `tools/`. They are organized in bundles. These bundles are copied to the sandboxed container and made available in the $PATH variable.
- In addition we provide two "inspectors" that allow to inspect trajectories (the output files of agents), `inspector_cli.py` provides a command line interface and `sweagent/inspector/server.py` a web interface.
Run PhoenixRepair with `./run.sh --model MODEL --instances MANIFEST`.
The CLI in `phoenix/cli.py` loads the model configuration. The pipeline in
`phoenix/pipeline.py` coordinates localization, candidate generation and the
final patch. The worker uses the agent implementation in `sweagent/agent/`
and runs the tool bundles in `tools/` inside Docker via SWE-ReX.
14 changes: 1 addition & 13 deletions .devcontainer/bashrc_epilog.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@

if [ -z "$(docker images -q sweagent/swe-agent 2> /dev/null)" ]; then
echo "⚠️ Please wait for the postCreateCommand to start and finish (a new window will appear shortly) ⚠️"
fi

echo "Here's an example SWE-agent command to try out:"

echo "sweagent run \\
--agent.model.name=claude-sonnet-4-20250514 \\
--agent.model.per_instance_cost_limit=2.00 \\
--env.repo.github_url=https://github.com/SWE-agent/test-repo \\
--problem_statement.github_url=https://github.com/SWE-agent/test-repo/issues/1 \\
"
echo "Run ./run.sh --help to see PhoenixRepair options."
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "SWE-Agent Codespace",
"name": "PhoenixRepair Codespace",
"image": "mcr.microsoft.com/vscode/devcontainers/miniconda:0-3",
"customizations":{
"vscode":{
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ body:
attributes:
value: >
#### Before submitting a bug, please make sure the issue hasn't been already
addressed by searching through [the past issues](https://github.com/SWE-agent/SWE-agent/issues).
addressed by searching through [the past issues](https://github.com/DeepSoftwareAnalytics/PhoenixRepair/issues).
- type: textarea
attributes:
label: Describe the bug
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
blank_issues_enabled: true
contact_links:
- name: Blank issue
url: https://github.com/SWE-agent/SWE-agent/issues/new
url: https://github.com/DeepSoftwareAnalytics/PhoenixRepair/issues/new
about: None of the above? Open a blank issue
- name: Slack server
url: https://join.slack.com/t/swe-bench/shared_invite/zt-36pj9bu5s-o3_yXPZbaH2wVnxnss1EkQ
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/question.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Question
description: Ask an open-ended question about SWE-agent (e.g., "How do I do ...?"). If you get an error message or think that something went wrong, please open a bug issue instead!
description: Ask an open-ended question about PhoenixRepair (e.g., "How do I do ...?"). If you get an error message or think that something went wrong, please open a bug issue instead!
labels: ['question']

body:
- type: textarea
attributes:
label: Describe the issue
description: >
Tell us about the confusion you have about SWE-agent *or*
Tell us about the confusion you have about PhoenixRepair *or*
the information that is missing in the documentation.
If you face error messages and more, please open a bug report
instead https://github.com/SWE-agent/SWE-agent/issues/new?template=bug_report.yml
instead https://github.com/DeepSoftwareAnalytics/PhoenixRepair/issues/new?template=bug_report.yml
validations:
required: true
- type: input
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
uses: codecov/codecov-action@v5.5.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: SWE-agent/SWE-agent
slug: DeepSoftwareAnalytics/PhoenixRepair
- name: Upload test results to Codecov
if: matrix.python-version == '3.11'
uses: codecov/test-results-action@v1
Expand Down
1 change: 1 addition & 0 deletions config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
agent:
templates:
system_template: |-
You are PhoenixRepair.
You are a helpful assistant that can interact with a computer to solve tasks.
instance_template: |-
<uploaded_files>
Expand Down
1 change: 1 addition & 0 deletions config/locate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ agent:
localization_workflow: true
templates:
system_template: |-
You are PhoenixRepair.
You investigate complete repair strategies using ONLY the issue and current checked-out source.
First enumerate the issue's required behaviors and compatibility constraints as shared requirements
with stable IDs R1, R2, ... . Include explicit interfaces, input/output contracts, error behavior and
Expand Down
3 changes: 1 addition & 2 deletions configs/our_method.yaml → configs/PhoenixRepair.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Current GLM PhoenixRepair: complete localization -> 200 shared generation calls, 32K output.
# No patch review, repair, P1 selection, or benchmark evaluation is run.
model: glm-5.2
instances: null
runtime: null
output: runs/our-method-repair
output: runs/PhoenixRepair
concurrency: 4
max_steps: 200
max_input_tokens: 131072
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Current GLM PhoenixRepair: complete localization -> 200 shared generation calls, 32K output.
# No patch review, repair, P1 selection, or benchmark evaluation is run.
model: glm-5.2
instances: null
runtime: null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Kimi PhoenixRepair is a new experiment; no historical PhoenixRepair score is claimed.
# The pre-review PhoenixRepair row: complete localization -> guided author generation.
# No patch review, repair, P1 selection, or benchmark evaluation is run.
model: kimi-k2.7-code
instances: null
runtime: null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# The pre-review PhoenixRepair row: complete localization -> guided author generation.
# No patch review, repair, P1 selection, or benchmark evaluation is run.
model: qwen3.7-plus
instances: null
runtime: null
Expand Down
11 changes: 2 additions & 9 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# SWE-agent
# PhoenixRepair documentation

<div style="text-align: center;">
<img src="assets/readme_assets/swe-agent-banner.png" alt="SWE-agent banner" style="height: 12em;">
</div>

🔗 Simply want to read the docs? Please head to [the web version of these docs](https://swe-agent.com/latest/)

This folder holds the source for the SWE-agent documentation.
Want to modify and build the website locally? See [here](https://swe-agent.com/latest/dev/contribute#mkdocs).
The current guide is built from the [repository README](../README.md). The other documentation in this directory includes historical SWE-agent reference material.
2 changes: 1 addition & 1 deletion evaluation/run_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def get_all_preds(self, instance_ids: list[str] | None = None):
with open(patch_path, 'r') as f:
dict1 = json.load(f)
for k, v in dict1.items():
preds.append({"instance_id": k, "model_name_or_path": "swe-agent", "model_patch": v['model_patch']})
preds.append({"instance_id": k, "model_name_or_path": "PhoenixRepair", "model_patch": v['model_patch']})
print(f"Collected {len(preds)} predictions")
with open(os.path.join(self.results_dir, "final_answer1.json"), "w") as f:
json.dump(preds, f)
Expand Down
25 changes: 14 additions & 11 deletions phoenix/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from phoenix.run_state import (bind, digest, find_worker, lock, owned_alive,
process_identity, read, reserve_retry, retry_reason,
stop_owned, verified_result)
from phoenix.settings import ROOT, fingerprint, model_config, write_json
from phoenix.settings import LEGACY_METHOD, REPAIR_METHODS, ROOT, fingerprint, model_config, write_json


class ControllerInterrupted(Exception):
Expand All @@ -39,6 +39,9 @@ def __init__(self, settings, key):
self.output = Path(settings["output"])
self.output.mkdir(parents=True, exist_ok=True)
self.base = prepare_tools(self.output)["agent"]
if settings["method"] == LEGACY_METHOD:
templates = self.base["templates"]
templates["system_template"] = templates["system_template"].removeprefix("You are PhoenixRepair.\n")
self.profile = recovery_profile(settings)
with lock(self.output / "run-state.lock"):
run = read(self.output / "run-state.json")
Expand Down Expand Up @@ -154,10 +157,10 @@ def _read_attempt(self, request, attempt, rc, timed_out):
steps = max(steps, read(attempt / "query-state.json").get("reserved_step", 0))
patch = None
submission = read(attempt / 'submission.json')
for name in (("PhoenixRepair.patch", "submitted.patch") if self.settings["method"] == "our_method"
for name in (("PhoenixRepair.patch", "submitted.patch") if self.settings["method"] in REPAIR_METHODS
else ("submitted.patch",)):
if (attempt / name).is_file() and ((attempt / name).read_bytes().strip()
or self.settings['method'] != 'our_method' and str(submission.get('exit_status')).startswith('submitted')):
or self.settings['method'] not in REPAIR_METHODS and str(submission.get('exit_status')).startswith('submitted')):
patch = attempt / name
break
if patch is None and info.get("submission"):
Expand All @@ -183,11 +186,11 @@ def _read_attempt(self, request, attempt, rc, timed_out):
model_started=(calls > request.get('prior_calls', 0)
or steps > request.get('prior_steps', 0)),
trajectory=data.get("trajectory", []), api_error=api_error)
if self.settings["method"] != "our_method" and reason == "container_start_timeout":
if self.settings["method"] not in REPAIR_METHODS and reason == "container_start_timeout":
limit = self.profile["environment_start_retries"]
if not patch and (timed_out or reason or rc != 0):
capture = capture_checkout(request, self.env, attempt,
official=self.settings["model"] != "kimi-k2.7-code" and self.settings["method"] != "our_method" and timed_out,
official=self.settings["model"] != "kimi-k2.7-code" and self.settings["method"] not in REPAIR_METHODS and timed_out,
timeout=request.get("capture_reserve", 60) or 60)
if capture["status"] == "captured":
patch = attempt / "captured.patch"
Expand All @@ -205,7 +208,7 @@ def _read_attempt(self, request, attempt, rc, timed_out):
def _finish(self, stage, state, observed, *, recovered=False):
patch = observed["patch"].read_bytes()
(stage / "final.patch").write_bytes(patch)
if self.settings["method"] == "our_method":
if self.settings["method"] in REPAIR_METHODS:
(stage / "PhoenixRepair.patch").write_bytes(patch)
write_json(stage / "submission.json", {"model_calls": state["calls"],
"mechanical_validation": observed["mechanical"], "review_calls": 0, "repair_calls": 0})
Expand All @@ -227,7 +230,7 @@ def generate(self, task, stage, *, allowance, final_stage, candidate=None, summa
stage.mkdir(parents=True, exist_ok=True)
identity = dict(task=task, method=self.settings["method"], model=self.settings["model"],
model_config=model_config(self.settings["model"], self.settings["api_base"],
shared_budget_mode=self.settings["method"] == "our_method", context_settings=self.settings),
shared_budget_mode=self.settings["method"] in REPAIR_METHODS, context_settings=self.settings),
max_steps=self.settings["max_steps"], task_timeout=self.settings["task_timeout"],
allowance=allowance, final_stage=final_stage, candidate=candidate, summary=summary,
num_candidates=num_candidates, base_agent=self.base)
Expand All @@ -246,7 +249,7 @@ def generate(self, task, stage, *, allowance, final_stage, candidate=None, summa
if not state.get("active"):
remaining = self.settings["task_timeout"] - state["spent_seconds"]
if mode != "submission" and (remaining <= 0 or state["steps"] >= self.settings["max_steps"]
or self.settings["method"] == "our_method" and state["calls"] >= allowance):
or self.settings["method"] in REPAIR_METHODS and state["calls"] >= allowance):
break
if mode == "submission":
if state["replay_attempts"] >= 2:
Expand Down Expand Up @@ -317,7 +320,7 @@ def generate(self, task, stage, *, allowance, final_stage, candidate=None, summa
if observed["exit_status"] == "exit_api":
state["last_api_error"] = observed["api_error"]
remaining = self.settings["task_timeout"] - state["spent_seconds"]
calls_left = self.settings["method"] != "our_method" or state["calls"] < allowance
calls_left = self.settings["method"] not in REPAIR_METHODS or state["calls"] < allowance
if (patch is not None and observed["trajectory"] and not observed["timed_out"]
and remaining > 0 and calls_left and state["steps"] < self.settings["max_steps"]
and reserve_retry(state, observed["reason"], observed["retry_limit"])):
Expand All @@ -335,10 +338,10 @@ def generate(self, task, stage, *, allowance, final_stage, candidate=None, summa
# halfway through applying it in a disposable checkout.
write_json(stage / "execution.json", state)
continue
if patch and self.settings["method"] != "our_method":
if patch and self.settings["method"] not in REPAIR_METHODS:
if (patch.stat().st_size and timed_out) or rc == 0 or str(observed["exit_status"]).startswith("submitted"):
return self._finish(stage, state, observed, recovered=timed_out)
if patch and self.settings["method"] == "our_method":
if patch and self.settings["method"] in REPAIR_METHODS:
if observed["mechanical"].get("valid"):
return self._finish(stage, state, observed, recovered=mode == "submission")
# First submission or a bounded terminal capture is repaired
Expand Down
16 changes: 9 additions & 7 deletions phoenix/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
import sys
import signal

from phoenix.settings import ROOT, PROFILES, fingerprint, load_instances, load_settings, write_json
from phoenix.settings import LEGACY_METHOD, METHOD_NAME, REPAIR_METHODS, ROOT, PROFILES, fingerprint, load_instances, load_settings, write_json


def main(argv=None):
parser = argparse.ArgumentParser(description=__doc__)
parser.set_defaults(method="our_method")
parser = argparse.ArgumentParser(prog=METHOD_NAME, description=__doc__)
parser.set_defaults(method=METHOD_NAME)
parser.add_argument("--config", type=Path)
parser.add_argument("--model", choices=tuple(PROFILES))
parser.add_argument("--instances", type=Path, help="JSON array or JSONL task manifest")
Expand Down Expand Up @@ -44,7 +44,7 @@ def main(argv=None):
help="Validate configuration and task inputs; no model or Docker calls")
args = parser.parse_args(argv)
try:
settings = load_settings(args.method, args.config or ROOT / "configs/models" / (args.model or "glm-5.2") / "our_method.yaml", {
settings = load_settings(args.method, args.config or ROOT / "configs/models" / (args.model or "glm-5.2") / "PhoenixRepair.yaml", {
k: getattr(args, k) for k in ("model", "instances", "output", "runtime", "api_base", "concurrency",
"max_steps", "task_timeout", "localization_max_steps", "localization_timeout",
"docker_host", "locations", "stage", "adaptive_io", "io_device",
Expand All @@ -55,9 +55,9 @@ def main(argv=None):
if args.limit < 0:
raise ValueError("limit cannot be negative")
instances = load_instances(Path(settings["instances"]), args.instance_id, args.limit)
if args.method == "our_method" and settings["max_steps"] <= 40:
if args.method in REPAIR_METHODS and settings["max_steps"] <= 40:
raise ValueError("This experiment requires max_steps > 40")
if args.method == "our_method" and settings["stage"] == "patch" and not settings.get("locations"):
if args.method in REPAIR_METHODS and settings["stage"] == "patch" and not settings.get("locations"):
raise ValueError("--stage patch requires --locations")
if settings["stage"] == "localization" and settings.get("locations"):
raise ValueError("--locations is for patch generation; omit it when generating new locations")
Expand All @@ -68,7 +68,7 @@ def main(argv=None):
plan = dict(recovery_format=1, settings=settings, tasks=len(instances), instance_ids=[x["instance_id"] for x in instances],
task_manifest_sha256=fingerprint(instances), model_profile=PROFILES[settings["model"]],
review_calls_enabled=False, repair_stage_enabled=False,
method_output="PhoenixRepair" if args.method == "our_method" else "final.patch",
method_output="PhoenixRepair" if args.method in REPAIR_METHODS else "final.patch",
old_patch_seed=False, evaluation_feedback_input=False)
if args.dry_run:
print(json.dumps(plan, ensure_ascii=False, indent=2))
Expand Down Expand Up @@ -97,6 +97,8 @@ def main(argv=None):
previous = json.loads((output / "plan.json").read_text())
if previous.get("recovery_format") != 1:
raise ValueError("This run predates durable recovery; use a new output directory")
if previous["settings"].get("method") == LEGACY_METHOD:
settings["method"] = LEGACY_METHOD
immutable = ("model", "method", "api_base", "max_steps", "task_timeout", "samples",
"localization_max_steps", "localization_timeout", "locations", "stage",
"runtime", "docker_host", "container_cpus", "container_memory", "pin_cpus",
Expand Down
Loading
Loading