From 4f623486fec4d10441ce3b088ba107b7f6687012 Mon Sep 17 00:00:00 2001 From: jty1128 Date: Tue, 24 Nov 2026 15:11:36 +0800 Subject: [PATCH] Identify the repair method as PhoenixRepair in prompts and run artifacts --- .cursor/rules/project-overview.mdc | 17 +++++-------- .devcontainer/bashrc_epilog.sh | 14 +---------- .devcontainer/devcontainer.json | 2 +- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- .github/ISSUE_TEMPLATE/config.yml | 2 +- .github/ISSUE_TEMPLATE/question.yml | 6 ++--- .github/workflows/pytest.yaml | 2 +- config/default.yaml | 1 + config/locate.yaml | 1 + .../{our_method.yaml => PhoenixRepair.yaml} | 3 +-- .../{our_method.yaml => PhoenixRepair.yaml} | 0 .../{our_method.yaml => PhoenixRepair.yaml} | 1 - .../{our_method.yaml => PhoenixRepair.yaml} | 1 - .../{our_method.yaml => PhoenixRepair.yaml} | 1 - docs/README.md | 11 ++------ evaluation/run_evaluation.py | 2 +- phoenix/backend.py | 25 +++++++++++-------- phoenix/cli.py | 16 ++++++------ phoenix/pipeline.py | 18 ++++++------- phoenix/prompts.py | 2 +- phoenix/recovery_profiles.py | 6 +++-- phoenix/settings.py | 15 +++++++++-- phoenix/summary.py | 6 +++-- phoenix/worker.py | 12 ++++----- pyproject.toml | 2 +- sweagent/__init__.py | 6 ++--- sweagent/run/hooks/apply_patch.py | 2 +- sweagent/run/hooks/open_pr.py | 10 ++++---- tackle_pred.py | 4 +-- tests/conftest.py | 2 +- tests/test_repair.py | 3 +++ 31 files changed, 96 insertions(+), 99 deletions(-) rename configs/{our_method.yaml => PhoenixRepair.yaml} (80%) rename configs/models/deepseek-v4.1-flash/{our_method.yaml => PhoenixRepair.yaml} (100%) rename configs/models/glm-5.2/{our_method.yaml => PhoenixRepair.yaml} (86%) rename configs/models/kimi-k2.7-code/{our_method.yaml => PhoenixRepair.yaml} (86%) rename configs/models/qwen3.7-plus/{our_method.yaml => PhoenixRepair.yaml} (83%) diff --git a/.cursor/rules/project-overview.mdc b/.cursor/rules/project-overview.mdc index 45a8925..c01dffe 100644 --- a/.cursor/rules/project-overview.mdc +++ b/.cursor/rules/project-overview.mdc @@ -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. \ No newline at end of file +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. diff --git a/.devcontainer/bashrc_epilog.sh b/.devcontainer/bashrc_epilog.sh index 1e67b0d..880c2e6 100644 --- a/.devcontainer/bashrc_epilog.sh +++ b/.devcontainer/bashrc_epilog.sh @@ -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." diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a18db7e..75cb073 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,5 +1,5 @@ { - "name": "SWE-Agent Codespace", + "name": "PhoenixRepair Codespace", "image": "mcr.microsoft.com/vscode/devcontainers/miniconda:0-3", "customizations":{ "vscode":{ diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 6735bdc..55d7875 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -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 diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index ce3b096..2ae3bc5 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -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 diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml index 2bd4a5c..fc082ec 100644 --- a/.github/ISSUE_TEMPLATE/question.yml +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -1,5 +1,5 @@ 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: @@ -7,10 +7,10 @@ body: 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 diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 19fc54c..90483b7 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -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 diff --git a/config/default.yaml b/config/default.yaml index 9f436cf..5f93368 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -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: |- diff --git a/config/locate.yaml b/config/locate.yaml index acb7586..54df39c 100644 --- a/config/locate.yaml +++ b/config/locate.yaml @@ -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 diff --git a/configs/our_method.yaml b/configs/PhoenixRepair.yaml similarity index 80% rename from configs/our_method.yaml rename to configs/PhoenixRepair.yaml index 56c1a2b..0f797c8 100644 --- a/configs/our_method.yaml +++ b/configs/PhoenixRepair.yaml @@ -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 diff --git a/configs/models/deepseek-v4.1-flash/our_method.yaml b/configs/models/deepseek-v4.1-flash/PhoenixRepair.yaml similarity index 100% rename from configs/models/deepseek-v4.1-flash/our_method.yaml rename to configs/models/deepseek-v4.1-flash/PhoenixRepair.yaml diff --git a/configs/models/glm-5.2/our_method.yaml b/configs/models/glm-5.2/PhoenixRepair.yaml similarity index 86% rename from configs/models/glm-5.2/our_method.yaml rename to configs/models/glm-5.2/PhoenixRepair.yaml index 9ecadae..585215a 100644 --- a/configs/models/glm-5.2/our_method.yaml +++ b/configs/models/glm-5.2/PhoenixRepair.yaml @@ -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 diff --git a/configs/models/kimi-k2.7-code/our_method.yaml b/configs/models/kimi-k2.7-code/PhoenixRepair.yaml similarity index 86% rename from configs/models/kimi-k2.7-code/our_method.yaml rename to configs/models/kimi-k2.7-code/PhoenixRepair.yaml index bead443..95cbc12 100644 --- a/configs/models/kimi-k2.7-code/our_method.yaml +++ b/configs/models/kimi-k2.7-code/PhoenixRepair.yaml @@ -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 diff --git a/configs/models/qwen3.7-plus/our_method.yaml b/configs/models/qwen3.7-plus/PhoenixRepair.yaml similarity index 83% rename from configs/models/qwen3.7-plus/our_method.yaml rename to configs/models/qwen3.7-plus/PhoenixRepair.yaml index 1b02865..234260c 100644 --- a/configs/models/qwen3.7-plus/our_method.yaml +++ b/configs/models/qwen3.7-plus/PhoenixRepair.yaml @@ -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 diff --git a/docs/README.md b/docs/README.md index f508460..021ff5e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,10 +1,3 @@ -# SWE-agent +# PhoenixRepair documentation -
- SWE-agent banner -
- -๐Ÿ”— 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. diff --git a/evaluation/run_evaluation.py b/evaluation/run_evaluation.py index d977288..260958b 100644 --- a/evaluation/run_evaluation.py +++ b/evaluation/run_evaluation.py @@ -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) diff --git a/phoenix/backend.py b/phoenix/backend.py index 6984640..8cec88e 100644 --- a/phoenix/backend.py +++ b/phoenix/backend.py @@ -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): @@ -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") @@ -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"): @@ -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" @@ -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}) @@ -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) @@ -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: @@ -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"])): @@ -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 diff --git a/phoenix/cli.py b/phoenix/cli.py index d045912..ec20c06 100644 --- a/phoenix/cli.py +++ b/phoenix/cli.py @@ -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") @@ -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", @@ -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") @@ -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)) @@ -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", diff --git a/phoenix/pipeline.py b/phoenix/pipeline.py index 54b90d6..9379bce 100644 --- a/phoenix/pipeline.py +++ b/phoenix/pipeline.py @@ -8,7 +8,7 @@ import threading import time -from phoenix.settings import localization_config, write_json +from phoenix.settings import REPAIR_METHODS, localization_config, write_json from phoenix.summary import summarize from phoenix.run_state import bind, digest from phoenix.backend import DockerBackend, ControllerInterrupted @@ -77,13 +77,13 @@ def run_task(task, settings, backend, key, candidates=None, summary_fn=summarize for job in jobs: stage = directory / job["stage"] if job["kind"] == "summary": - summary = summary_fn(task, results, settings, stage, key, shared_budget=method == "our_method") - if method == "our_method": + summary = summary_fn(task, results, settings, stage, key, shared_budget=method in REPAIR_METHODS) + if method in REPAIR_METHODS: used += 1 continue candidate = candidates[len(results)] if job["kind"] == "candidate" else None allowance = job["allowance"] - if method == "our_method" and job["kind"] == "final": + if method in REPAIR_METHODS and job["kind"] == "final": allowance = settings["max_steps"] - used if allowance < 1: raise RuntimeError("No generation budget remains for final PhoenixRepair") @@ -100,11 +100,11 @@ def run_task(task, settings, backend, key, candidates=None, summary_fn=summarize final = results[-1] patch = Path(final["patch"]).read_bytes() (directory / "final.patch").write_bytes(patch) - if method == "our_method": + if method in REPAIR_METHODS: (directory / "PhoenixRepair.patch").write_bytes(patch) report = dict(status="completed", model=settings["model"], instance_id=task["instance_id"], method=method, patch=str(directory / "final.patch"), model_calls=used, - review_calls=0, repair_calls=0, output_stage="PhoenixRepair" if method == "our_method" else "final", + review_calls=0, repair_calls=0, output_stage="PhoenixRepair" if method in REPAIR_METHODS else "final", benchmark_evaluated=False, stages=results) except ControllerInterrupted as exc: report = dict(status="interrupted", model=settings["model"], instance_id=task["instance_id"], @@ -171,7 +171,7 @@ def run(instances, settings, key): os.environ["DOCKER_HOST"] = settings["docker_host"] ready = instances failures = [] - if settings["method"] == "our_method" and settings["stage"] != "patch" and not locations: + if settings["method"] in REPAIR_METHODS and settings["stage"] != "patch" and not locations: from phoenix import localization locations = str(output / "localization") write_json(Path(locations) / "instances.json", instances) @@ -195,14 +195,14 @@ def locate(task): ready = [x for x in instances if x["instance_id"] in succeeded] if settings["stage"] == "localization": return localized - if settings["method"] == "our_method" and not locations: + if settings["method"] in REPAIR_METHODS and not locations: raise ValueError("Patch-only mode requires --locations") backend = DockerBackend(settings, key) if ready else None def solve(task): try: candidates = None - if settings["method"] == "our_method": + if settings["method"] in REPAIR_METHODS: artifact = load_location(locations, task, settings["model"]) write_json(output / settings["model"] / task["instance_id"] / "localization.json", artifact) candidates = artifact["candidates"] diff --git a/phoenix/prompts.py b/phoenix/prompts.py index bb2cb2c..a30a61b 100644 --- a/phoenix/prompts.py +++ b/phoenix/prompts.py @@ -100,7 +100,7 @@ def _build_comparison_prompt(self, problem_statement: str, samples: list[dict], Keep response under 600 words. Focus on concrete technical differences and actionable insights. """ - return prompt + return "You are PhoenixRepair.\n" + prompt def _generate_location_insights_from_patch(self, patch_data: dict, previous_round_info: dict = None) -> str: """ไปŽ patch data ็”Ÿๆˆ location insights๏ผŒๅŒ…ๅซๅ‰ไธ€่ฝฎ็š„ๅๆ€""" diff --git a/phoenix/recovery_profiles.py b/phoenix/recovery_profiles.py index 8c7b700..693bf14 100644 --- a/phoenix/recovery_profiles.py +++ b/phoenix/recovery_profiles.py @@ -1,5 +1,7 @@ """Explicit historical model/method recovery profiles; never switch models.""" +from phoenix.settings import REPAIR_METHODS + # Generation sampling parameters remain in settings.PROFILES. These values # describe transport/lifecycle recovery, not another repair or review prompt. MODEL_RECOVERY = { @@ -30,10 +32,10 @@ def recovery_profile(settings): model = settings["model"] result = dict(MODEL_RECOVERY[model], model=model, method=settings["method"], same_model_only=True, budget_reset=False, review_calls=0, - environment_start_retries=3 if settings["method"] == "our_method" else 1, + environment_start_retries=3 if settings["method"] in REPAIR_METHODS else 1, terminal_session_retries=1, submission_replay_attempts=2) result["wall_time_seconds"] = settings.get("task_timeout", result["wall_time_seconds"]) - if settings["method"] == "our_method": + if settings["method"] in REPAIR_METHODS: if not result["generation_supported"]: raise ValueError("No historically scored Kimi PhoenixRepair profile is available") result.update(summary_timeout_seconds=(30, result["api_timeout_seconds"]), diff --git a/phoenix/settings.py b/phoenix/settings.py index 07c89eb..60714e7 100644 --- a/phoenix/settings.py +++ b/phoenix/settings.py @@ -13,6 +13,10 @@ ROOT = Path(__file__).resolve().parents[1] API_BASE = "https://dashscope.aliyuncs.com/compatible-mode/v1" FIELDS = ("instance_id", "problem_statement", "base_commit", "repo_name", "image_name") +METHOD_NAME = "PhoenixRepair" +LEGACY_METHOD = "our_method" +REPAIR_METHODS = (METHOD_NAME, LEGACY_METHOD) + CONTEXT_DEFAULTS = dict(max_input_tokens=131072, context_compaction_threshold=120000, context_compaction_target=110000) PROFILES = { @@ -91,6 +95,10 @@ def model_config(model, api_base, *, shared_budget_mode=False, context_settings= def load_settings(mode, config_path, overrides): + if not config_path.exists() and config_path.name == LEGACY_METHOD + ".yaml": + replacement = config_path.resolve().with_name(METHOD_NAME + ".yaml") + if replacement.is_relative_to(ROOT / "configs") and replacement.is_file(): + config_path = replacement data = yaml.safe_load(config_path.read_text()) or {} allowed = {"model", "instances", "output", "runtime", "api_base", "concurrency", "max_steps", "task_timeout", "locations", "stage", "docker_host", "container_cpus", "container_memory", @@ -167,8 +175,8 @@ def load_settings(mode, config_path, overrides): raise ValueError(key + " must be a positive integer") if data["stage"] not in ("all", "localization", "patch"): raise ValueError("stage must be all, localization, or patch") - if mode != "our_method" and (data.get("locations") or data["stage"] != "all"): - raise ValueError("locations/stage only apply to our_method") + if mode not in REPAIR_METHODS and (data.get("locations") or data["stage"] != "all"): + raise ValueError("locations/stage only apply to PhoenixRepair") for key in ("instances", "output", "runtime", "locations"): if data.get(key): data[key] = str(Path(data[key]).expanduser().resolve()) @@ -183,6 +191,9 @@ def localization_config(settings): profile here changes the experiment, especially GLM's output allowance. """ data = copy.deepcopy(yaml.safe_load((ROOT / "config/locate.yaml").read_text())) + if settings.get("method") == LEGACY_METHOD: + templates = data["agent"]["templates"] + templates["system_template"] = templates["system_template"].removeprefix("You are PhoenixRepair.\n") data["agent"]["max_steps"] = settings["localization_max_steps"] data["localization_runtime"] = { "max_tokens": 32768, "api_timeout": 600, diff --git a/phoenix/summary.py b/phoenix/summary.py index 4cae440..45ceb19 100644 --- a/phoenix/summary.py +++ b/phoenix/summary.py @@ -9,7 +9,7 @@ from phoenix.prompts import PromptBuilder from phoenix.repair_guidance import SUMMARY_GUIDANCE -from phoenix.settings import PROFILES, write_json +from phoenix.settings import LEGACY_METHOD, REPAIR_METHODS, PROFILES, write_json from phoenix.run_state import bind, read, digest def sha(path): @@ -46,7 +46,7 @@ def patch_for_prompt(path, limit=180_000): def summarize(task, candidates, settings, directory, key, *, shared_budget=False): directory.mkdir(parents=True, exist_ok=True) - shared_budget_mode = settings["method"] == "our_method" + shared_budget_mode = settings["method"] in REPAIR_METHODS if shared_budget_mode and not shared_budget: raise ValueError("PhoenixRepair summary must use the shared one-call budget") inputs = [] @@ -62,6 +62,8 @@ def summarize(task, candidates, settings, directory, key, *, shared_budget=False inputs.append(dict(index=index, trajectory=[None] * row["steps"], submission=preview, exit_status="submitted" if shared_budget_mode else row["exit_status"], patch_sha256=sha(patch), preview=metadata)) prompt = PromptBuilder()._build_comparison_prompt(task["problem_statement"], inputs, len(inputs)) + if settings["method"] == LEGACY_METHOD: + prompt = prompt.removeprefix("You are PhoenixRepair.\n") if shared_budget_mode: prompt += SUMMARY_GUIDANCE (directory / "prompt.txt").write_text(prompt) diff --git a/phoenix/worker.py b/phoenix/worker.py index 01d2fd8..d2299e5 100644 --- a/phoenix/worker.py +++ b/phoenix/worker.py @@ -17,7 +17,7 @@ from phoenix.repair_guidance import IMPLEMENTATION_GUIDANCE from phoenix.prompts import PromptBuilder -from phoenix.settings import ROOT, model_config, write_json +from phoenix.settings import REPAIR_METHODS, ROOT, model_config, write_json from phoenix.run_state import read, digest, process_identity, lock from phoenix.resources import io_slot @@ -52,7 +52,7 @@ def build_config(request): data.update(type="default", max_steps=settings["max_steps"], action_repeat_limit=0, limit_submission_mode="official_v2_staged_diff", localization_workflow=False, localization_independent_hypotheses=False, localization_complete_strategies=False) - shared_budget_mode = settings["method"] == "our_method" + shared_budget_mode = settings["method"] in REPAIR_METHODS data["model"] = model_config(settings["model"], settings["api_base"], shared_budget_mode=shared_budget_mode, context_settings=settings) data["tools"].update(git_execution_timeout=180, max_consecutive_execution_timeouts=0) if settings.get("no_truncation"): @@ -228,7 +228,7 @@ def replay_patch(env, request, stage): env.write_file("/root/phoenix_preserved.patch", patch.read_text()) args = dict(operation="replay_submission", root="/" + env.repo.repo_name, patch_path="/root/phoenix_preserved.patch", - clean_tests=request["settings"]["method"] == "our_method" and recovery["mode"] == "submission", + clean_tests=request["settings"]["method"] in REPAIR_METHODS and recovery["mode"] == "submission", expected_tree=recovery.get("patched_tree")) output = env.communicate(RUNTIME_PYTHON + " /root/phoenix_submission_probe.py " + shlex.quote(json.dumps(args)), check="ignore", timeout=180) @@ -377,7 +377,7 @@ def gated_start(): return original_start() runner.env.start = gated_start hook = None - if request["settings"]["method"] == "our_method": + if request["settings"]["method"] in REPAIR_METHODS: hook = install_generation_budget(runner.agent, request["generation_allowance"], request["final_stage"], stage, request.get("prior_calls", 0), exclude_rate_limits=request["settings"].get("exclude_rate_limit_from_budget", False)) @@ -391,7 +391,7 @@ def gated_start(): replay = replay_patch(runner.env, request, stage) patch = (stage / "replayed.patch").read_text() (stage / "submitted.patch").write_text(patch) - if request["settings"]["method"] == "our_method": + if request["settings"]["method"] in REPAIR_METHODS: (stage / "PhoenixRepair.patch").write_text(patch) write_json(stage / "submission.json", {"model_calls": request.get("prior_calls", 0), "mechanical_validation": replay["mechanical_validation"], "review_calls": 0, "repair_calls": 0}) @@ -444,7 +444,7 @@ def watchdog(): from phoenix.capture import capture_checkout try: capture_checkout(request, os.environ.copy(), stage, - official=request["settings"]["method"] != "our_method" + official=request["settings"]["method"] not in REPAIR_METHODS and request["settings"]["model"] != "kimi-k2.7-code", timeout=request.get("capture_reserve", 60)) finally: diff --git a/pyproject.toml b/pyproject.toml index f17cb68..01400c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=68"] build-backend = "setuptools.build_meta" [project] -name = "phoenixrepair" +name = "PhoenixRepair" version = "0.1.0" description = "Complete-localization-guided PhoenixRepair patch generation" requires-python = ">=3.11" diff --git a/sweagent/__init__.py b/sweagent/__init__.py index 5ca2f16..2d9e99b 100644 --- a/sweagent/__init__.py +++ b/sweagent/__init__.py @@ -79,7 +79,7 @@ def get_agent_version_info() -> str: hash = get_agent_commit_hash() rex_hash = get_rex_commit_hash() rex_version = get_rex_version() - return f"This is SWE-agent version {__version__} ({hash=}) with SWE-ReX version {rex_version} ({rex_hash=})." + return f"PhoenixRepair using SWE-agent {__version__} ({hash=}) with SWE-ReX version {rex_version} ({rex_hash=})." def impose_rex_lower_bound() -> None: @@ -98,11 +98,11 @@ def impose_rex_lower_bound() -> None: "running `pip install --upgrade swe-rex`." "You can also rerun `pip install -e .` in this repository to install the latest version." ) - get_logger("swe-agent", emoji="๐Ÿ‘‹").warning(msg) + get_logger("PhoenixRepair", emoji="๐Ÿ‘‹").warning(msg) impose_rex_lower_bound() -get_logger("swe-agent", emoji="๐Ÿ‘‹").info(get_agent_version_info()) +get_logger("PhoenixRepair", emoji="๐Ÿ‘‹").info(get_agent_version_info()) __all__ = [ diff --git a/sweagent/run/hooks/apply_patch.py b/sweagent/run/hooks/apply_patch.py index 9991a9e..77c8d49 100644 --- a/sweagent/run/hooks/apply_patch.py +++ b/sweagent/run/hooks/apply_patch.py @@ -50,7 +50,7 @@ def on_instance_completed(self, *, result: AgentRunResult): def _print_patch_message(patch_output_file: Path): console = rich.console.Console() msg = [ - "SWE-agent has produced a patch that it believes will solve the issue you submitted!", + "PhoenixRepair has produced a patch that it believes will solve the issue you submitted!", "Use the code snippet below to inspect or apply it!", ] panel = rich.panel.Panel.fit( diff --git a/sweagent/run/hooks/open_pr.py b/sweagent/run/hooks/open_pr.py index 918db2b..a5b622f 100644 --- a/sweagent/run/hooks/open_pr.py +++ b/sweagent/run/hooks/open_pr.py @@ -36,9 +36,9 @@ def open_pr(*, logger, token, env: SWEEnv, github_url, trajectory, _dry_run: boo except InvalidGithubURL as e: msg = "Data path must be a github issue URL if open_pr is set to True." raise ValueError(msg) from e - branch_name = f"swe-agent-fix-#{issue.number}-" + str(random.random())[2:10] + branch_name = f"phoenixrepair-fix-#{issue.number}-" + str(random.random())[2:10] env.communicate( - input="git config user.email 'noemail@swe-agent.com' && git config user.name 'SWE-agent'", + input="git config user.email 'phoenixrepair@users.noreply.github.com' && git config user.name 'PhoenixRepair'", error_msg="Failed to set git user", timeout=10, check="raise", @@ -92,7 +92,7 @@ def open_pr(*, logger, token, env: SWEEnv, github_url, trajectory, _dry_run: boo ) logger.debug(f"Pushed commit to {remote=} {branch_name=}: {out}") body = ( - f"This is a PR opened by AI tool [SWE Agent](https://github.com/SWE-agent/SWE-agent/) " + f"This is a PR opened by AI tool [PhoenixRepair](https://github.com/DeepSoftwareAnalytics/PhoenixRepair) " f"to close [#{issue.number}]({issue_url}) ({issue.title}).\n\nCloses #{issue.number}." ) body += "\n\n" + format_trajectory_markdown(trajectory, char_limit=60_000) @@ -102,7 +102,7 @@ def open_pr(*, logger, token, env: SWEEnv, github_url, trajectory, _dry_run: boo args = dict( owner=owner, repo=repo, - title=f"SWE-agent[bot] PR to fix: {issue.title}", + title=f"PhoenixRepair[bot] PR to fix: {issue.title}", head=head, base=default_branch, body=body, @@ -198,7 +198,7 @@ def format_trajectory_markdown(trajectory: list[dict[str, str]], char_limit: int """ prefix = [ "
", - "Thought process ('trajectory') of SWE-agent (click to expand)", + "Thought process ('trajectory') of PhoenixRepair (click to expand)", "", "", ] diff --git a/tackle_pred.py b/tackle_pred.py index 825f470..85942cd 100644 --- a/tackle_pred.py +++ b/tackle_pred.py @@ -19,7 +19,7 @@ def find_patch_files_in_final_folders(root_path): patch_content = f.read() original_id = folder.name.replace('-sample-final', '') result[original_id] = { - "model_name_or_path": "default__openai--GLM-4.7__t-0.70__p-1.00__c-0.00___swe_bench_verified_test", + "model_name_or_path": "PhoenixRepair", "instance_id": original_id, "model_patch": patch_content } @@ -32,7 +32,7 @@ def find_patch_files_in_final_folders(root_path): def main(): root_directory = "" # Please Enter The absolute path obtained in Phase 2 - patches_data_final = find_patch_files_in_final_folders(root_directory) + patches_data = find_patch_files_in_final_folders(root_directory) if patches_data: output_file = os.path.join(root_directory, "answer_final.json") with open(output_file, 'w', encoding='utf-8') as f: diff --git a/tests/conftest.py b/tests/conftest.py index c300638..b14f252 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -34,6 +34,6 @@ def candidate(): def settings(tmp_path): from phoenix.settings import ROOT, load_settings # Synthetic PhoenixRepair fixtures are independent of the checked-out model branch. - result = load_settings("our_method", ROOT / "configs/our_method.yaml", {"model": "glm-5.2"}) + result = load_settings("PhoenixRepair", ROOT / "configs/PhoenixRepair.yaml", {"model": "glm-5.2"}) result.update(output=str(tmp_path / "output"), runtime=str(tmp_path / "runtime")) return result diff --git a/tests/test_repair.py b/tests/test_repair.py index 8f4ac42..750d9d1 100644 --- a/tests/test_repair.py +++ b/tests/test_repair.py @@ -104,6 +104,7 @@ def test_complete_localization_to_final_patch(monkeypatch, tmp_path, task, candi pending = iter(actions) events = [] def api(session, endpoint, key, payload, directory, **kwargs): + assert payload["messages"][0]["content"].startswith("You are PhoenixRepair.") assert payload["model"] == model assert payload["max_tokens"] == 32768 and kwargs["timeout"] == 600 name, arguments = next(pending) @@ -115,6 +116,7 @@ def api(session, endpoint, key, payload, directory, **kwargs): class FakeSession: def post(self, url, **kwargs): assert kwargs["json"]["model"] == model and kwargs["json"]["temperature"] == 0 + assert kwargs["json"]["messages"][0]["content"].startswith("You are PhoenixRepair.") events.append("summary") class Response: ok = True @@ -134,6 +136,7 @@ def generate(*args, **kwargs): monkeypatch.setattr(pipeline, "DockerBackend", lambda *args: backend) reports = pipeline.run([task], settings, "synthetic-key") assert len(reports) == 1 and reports[0]["status"] == "completed", reports + assert reports[0]["method"] == "PhoenixRepair" assert reports[0]["output_stage"] == "PhoenixRepair" and reports[0]["review_calls"] == reports[0]["repair_calls"] == 0 assert events[:len(actions)] == [a[0] for a in actions] assert events[len(actions):] == (["generate"] if candidate_count == 1 else ["generate", "generate", "summary", "generate"])