From d1f6aa19bb1cc2bfad3fb4282d77d8e9b95c65dc Mon Sep 17 00:00:00 2001 From: jty1128 Date: Tue, 24 Nov 2026 15:18:59 +0800 Subject: [PATCH] Align model inference profiles across repair stages and remove README scores --- README.md | 34 ++++--- config/locate.yaml | 4 - configs/PhoenixRepair.yaml | 4 - .../models/deepseek-v3.1/PhoenixRepair.yaml | 2 + .../models/deepseek-v3.2/PhoenixRepair.yaml | 2 + .../deepseek-v4.1-flash/PhoenixRepair.yaml | 2 +- configs/models/glm-4.7/PhoenixRepair.yaml | 2 + configs/models/glm-5.2/PhoenixRepair.yaml | 4 - .../models/minimax-m2.5/PhoenixRepair.yaml | 2 + .../models/qwen-3.8-max/PhoenixRepair.yaml | 2 + .../qwen3-coder-plus/PhoenixRepair.yaml | 2 + .../qwen3.7-plus-thinking/PhoenixRepair.yaml | 2 + phoenix/cli.py | 4 +- phoenix/localization.py | 7 +- phoenix/recovery_profiles.py | 38 ++------ phoenix/settings.py | 90 +++++++++++++------ phoenix/summary.py | 9 +- tests/test_repair.py | 47 ++++++++-- 18 files changed, 149 insertions(+), 108 deletions(-) create mode 100644 configs/models/deepseek-v3.1/PhoenixRepair.yaml create mode 100644 configs/models/deepseek-v3.2/PhoenixRepair.yaml create mode 100644 configs/models/glm-4.7/PhoenixRepair.yaml create mode 100644 configs/models/minimax-m2.5/PhoenixRepair.yaml create mode 100644 configs/models/qwen-3.8-max/PhoenixRepair.yaml create mode 100644 configs/models/qwen3-coder-plus/PhoenixRepair.yaml create mode 100644 configs/models/qwen3.7-plus-thinking/PhoenixRepair.yaml diff --git a/README.md b/README.md index c67f344..bae19d9 100644 --- a/README.md +++ b/README.md @@ -21,26 +21,22 @@ Supply `PHOENIX_API_KEY` through your environment. Set `API_BASE` for a custom O ./run.sh --model glm-5.2 --instances /path/to/tasks.jsonl --output runs/glm-repair ``` -Each completed task writes `PhoenixRepair.patch` under `///`. Use `--resume` with the same inputs to continue an interrupted run. The GLM-5.2 and Qwen3.7-Plus generation profiles disable thinking and use a 32,768-token output limit. Model request defaults live in `phoenix/settings.py` and per-model run budgets in `configs/models/`. +Each completed task writes `PhoenixRepair.patch` under `///`. Use `--resume` with the same inputs to continue an interrupted run. Model request defaults live in `phoenix/settings.py` and per-model run budgets in `configs/models/`. -## Published results for the original method +## Inference profiles -### Pass@1 on SWE-bench Verified +Use the profile name with `--model`. The settings below apply to localization, patch generation and candidate comparison. Output limits are per response. -| Method | LLM | Resolved (%) | -|--------|-----|--------------| -| Mini-SWE-agent | DeepSeek-V3.2 | 61.0% | -| Live-SWE-agent | DeepSeek-V3.2 | 63.8% | -| SWE-Search | DeepSeek-V3.2 | 65.4% | -| Agentless | DeepSeek-V3.2 | 67.0% | -| Trae-agent | DeepSeek-V3.2 | 67.8% | -| SWE-agent | DeepSeek-V3.2 | 69.4% | -| Moatless-tools | Claude-4-Sonnet | 70.8% | -| **PhoenixRepair** | **DeepSeek-V3.2** | **74.4%** (+5.0%) | +| Profile | Thinking | Temperature | Top-p | Context tokens | Output tokens | +| --- | --- | ---: | ---: | ---: | ---: | +| `deepseek-v3.1` | Off | 0.6 | 0.95 | 131,072 | API default | +| `deepseek-v3.2` | Off | 1.0 | 0.95 | 131,072 | API default | +| `qwen3-coder-plus` | Off | 0.7 | 0.80 | 1,000,000 | 65,536 | +| `glm-4.7` | On | 0.7 | 1.00 | 202,752 | 131,072 | +| `minimax-m2.5` | On (native) | 1.0 | 0.95 | 204,800 | 32,768 | +| `glm-5.2` | Off | 1.0 | 1.00 | 1,048,576 | 131,072 | +| `qwen3.7-plus` | Off | 1.0 | 0.95 | 1,000,000 | 131,072 | +| `qwen3.7-plus-thinking` | On | 1.0 | 0.95 | 1,000,000 | 131,072 | +| `qwen-3.8-max` | Off | 1.0 | 0.95 | 1,000,000 | 131,072 | -### Fault Localization Accuracy - -| Method | LLM | File Acc@1 | Module Acc@1 | Function Acc@1 | -|--------|-----|------------|--------------|----------------| -| SWE-agent | DeepSeek-V3.2 | 83.04% | 74.22% | 63.42% | -| **PhoenixRepair** | **DeepSeek-V3.2** | **85.64%** (+2.60%) | **76.82%** (+2.60%) | **66.64%** (+3.22%) | +Both DeepSeek profiles send `deepseek-chat` and omit the output-length parameter. To reproduce V3.1 (2025-08-21) or V3.2 (2025-12-01), set `API_BASE` to a deployment serving that release. The shared API identifier alone cannot pin a snapshot. Both Qwen-3.7 Plus profiles send `qwen3.7-plus` with the selected thinking flag. diff --git a/config/locate.yaml b/config/locate.yaml index 54df39c..5a13432 100644 --- a/config/locate.yaml +++ b/config/locate.yaml @@ -131,9 +131,5 @@ agent: history_processors: - type: cache_control last_n_messages: 2 - model: - temperature: 1 - completion_kwargs: - reasoning_effort: high localization_independent_hypotheses: true localization_complete_strategies: true diff --git a/configs/PhoenixRepair.yaml b/configs/PhoenixRepair.yaml index 0f797c8..4b11ff4 100644 --- a/configs/PhoenixRepair.yaml +++ b/configs/PhoenixRepair.yaml @@ -1,13 +1,9 @@ -# Current GLM PhoenixRepair: complete localization -> 200 shared generation calls, 32K output. model: glm-5.2 instances: null runtime: null output: runs/PhoenixRepair concurrency: 4 max_steps: 200 -max_input_tokens: 131072 -context_compaction_threshold: 120000 -context_compaction_target: 110000 localization_max_steps: 150 localization_timeout: null task_timeout: 7200 diff --git a/configs/models/deepseek-v3.1/PhoenixRepair.yaml b/configs/models/deepseek-v3.1/PhoenixRepair.yaml new file mode 100644 index 0000000..bfb64ec --- /dev/null +++ b/configs/models/deepseek-v3.1/PhoenixRepair.yaml @@ -0,0 +1,2 @@ +model: deepseek-v3.1 +output: runs/deepseek-v3.1-repair diff --git a/configs/models/deepseek-v3.2/PhoenixRepair.yaml b/configs/models/deepseek-v3.2/PhoenixRepair.yaml new file mode 100644 index 0000000..720ec78 --- /dev/null +++ b/configs/models/deepseek-v3.2/PhoenixRepair.yaml @@ -0,0 +1,2 @@ +model: deepseek-v3.2 +output: runs/deepseek-v3.2-repair diff --git a/configs/models/deepseek-v4.1-flash/PhoenixRepair.yaml b/configs/models/deepseek-v4.1-flash/PhoenixRepair.yaml index 530a041..ba6498a 100644 --- a/configs/models/deepseek-v4.1-flash/PhoenixRepair.yaml +++ b/configs/models/deepseek-v4.1-flash/PhoenixRepair.yaml @@ -1,4 +1,4 @@ -# Same settings as the current GLM 200-call/32K PhoenixRepair experiment; only model/output differ. +# Historical DeepSeek Flash profile with a 200-call budget and 32K output limit. model: deepseek-v4.1-flash instances: null runtime: null diff --git a/configs/models/glm-4.7/PhoenixRepair.yaml b/configs/models/glm-4.7/PhoenixRepair.yaml new file mode 100644 index 0000000..5d4f2ca --- /dev/null +++ b/configs/models/glm-4.7/PhoenixRepair.yaml @@ -0,0 +1,2 @@ +model: glm-4.7 +output: runs/glm-4.7-repair diff --git a/configs/models/glm-5.2/PhoenixRepair.yaml b/configs/models/glm-5.2/PhoenixRepair.yaml index 585215a..6b49757 100644 --- a/configs/models/glm-5.2/PhoenixRepair.yaml +++ b/configs/models/glm-5.2/PhoenixRepair.yaml @@ -1,13 +1,9 @@ -# Current GLM PhoenixRepair: complete localization -> 200 shared generation calls, 32K output. model: glm-5.2 instances: null runtime: null output: runs/glm-5.2-repair concurrency: 4 max_steps: 200 -max_input_tokens: 131072 -context_compaction_threshold: 120000 -context_compaction_target: 110000 localization_max_steps: 150 localization_timeout: null task_timeout: 7200 diff --git a/configs/models/minimax-m2.5/PhoenixRepair.yaml b/configs/models/minimax-m2.5/PhoenixRepair.yaml new file mode 100644 index 0000000..d816651 --- /dev/null +++ b/configs/models/minimax-m2.5/PhoenixRepair.yaml @@ -0,0 +1,2 @@ +model: minimax-m2.5 +output: runs/minimax-m2.5-repair diff --git a/configs/models/qwen-3.8-max/PhoenixRepair.yaml b/configs/models/qwen-3.8-max/PhoenixRepair.yaml new file mode 100644 index 0000000..0621cb0 --- /dev/null +++ b/configs/models/qwen-3.8-max/PhoenixRepair.yaml @@ -0,0 +1,2 @@ +model: qwen-3.8-max +output: runs/qwen-3.8-max-repair diff --git a/configs/models/qwen3-coder-plus/PhoenixRepair.yaml b/configs/models/qwen3-coder-plus/PhoenixRepair.yaml new file mode 100644 index 0000000..d02ea0f --- /dev/null +++ b/configs/models/qwen3-coder-plus/PhoenixRepair.yaml @@ -0,0 +1,2 @@ +model: qwen3-coder-plus +output: runs/qwen3-coder-plus-repair diff --git a/configs/models/qwen3.7-plus-thinking/PhoenixRepair.yaml b/configs/models/qwen3.7-plus-thinking/PhoenixRepair.yaml new file mode 100644 index 0000000..e450108 --- /dev/null +++ b/configs/models/qwen3.7-plus-thinking/PhoenixRepair.yaml @@ -0,0 +1,2 @@ +model: qwen3.7-plus-thinking +output: runs/qwen3.7-plus-thinking-repair diff --git a/phoenix/cli.py b/phoenix/cli.py index ec20c06..9bb522e 100644 --- a/phoenix/cli.py +++ b/phoenix/cli.py @@ -27,7 +27,7 @@ def main(argv=None): parser.add_argument("--concurrency", type=int) parser.add_argument("--max-steps", type=int) parser.add_argument("--no-truncation", action="store_true", default=None, help="Keep full context and observations; reject length-truncated responses") - parser.add_argument("--max-input-tokens", type=int, help="Generation context limit; historical default 131072") + parser.add_argument("--max-input-tokens", type=int, help="Generation context limit (defaults to the model profile)") parser.add_argument("--context-compaction-threshold", type=int, help="Generation input threshold; 0 disables compaction") parser.add_argument("--context-compaction-target", type=int, help="Target input size after generation context compaction") parser.add_argument("--task-timeout", type=int) @@ -95,6 +95,8 @@ def main(argv=None): fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB) if args.resume: previous = json.loads((output / "plan.json").read_text()) + if previous.get("model_profile") != plan["model_profile"]: + raise ValueError("Saved inference profile differs; resume with the original code or start a new run") 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: diff --git a/phoenix/localization.py b/phoenix/localization.py index ae2ef1d..910bdba 100644 --- a/phoenix/localization.py +++ b/phoenix/localization.py @@ -339,12 +339,9 @@ def tokens(ms): raise RuntimeError('Context budget exceeded after preserving actions/requirements; drafts retained') choice = ({'type': 'function', 'function': {'name': 'location_checkpoint'}} if control['checkpoint_required'] else runtime['tool_choice']) - payload = dict(model=profile['model'], messages=request_messages, + payload = dict(runtime['inference'], messages=request_messages, tools=definitions(config, control['allowed_tools']), tool_choice=choice, - parallel_tool_calls=False, temperature=0.0, top_p=1.0, - max_tokens=runtime['max_tokens'], enable_thinking=runtime['enable_thinking']) - if runtime.get('preserve_thinking'): - payload['preserve_thinking'] = True + parallel_tool_calls=False) if runtime.get('no_truncation') and tokens(request_messages) > runtime['max_compacted_tokens']: raise RuntimeError('NO_TRUNCATION: localization input limit reached; full history retained') request_dir = task / 'requests' / f'{step:03d}' diff --git a/phoenix/recovery_profiles.py b/phoenix/recovery_profiles.py index 693bf14..c34609a 100644 --- a/phoenix/recovery_profiles.py +++ b/phoenix/recovery_profiles.py @@ -1,43 +1,21 @@ """Explicit historical model/method recovery profiles; never switch models.""" -from phoenix.settings import REPAIR_METHODS +from phoenix.settings import PROFILES, REPAIR_METHODS # Generation sampling parameters remain in settings.PROFILES. These values # describe transport/lifecycle recovery, not another repair or review prompt. -MODEL_RECOVERY = { - "glm-5.2": { - "api_timeout_seconds": 240, "wall_time_seconds": 7200, - "thinking": False, "summary_timeout_seconds": 120, - "summary_transport_attempts": 5, "summary_format_rounds": 3, - "generation_supported": True, - }, - "qwen3.7-plus": { - "api_timeout_seconds": 600, "wall_time_seconds": 7200, - "thinking": False, "summary_timeout_seconds": 120, - "summary_transport_attempts": 5, "summary_format_rounds": 3, - "generation_supported": True, - }, - "kimi-k2.7-code": { - "api_timeout_seconds": 240, "wall_time_seconds": 3000, - "thinking": True, "preserve_thinking": True, - "summary_timeout_seconds": 240, "summary_transport_attempts": 3, - "summary_format_rounds": 3, - "generation_supported": True, - }, -} -MODEL_RECOVERY["deepseek-v4.1-flash"] = dict(MODEL_RECOVERY["glm-5.2"]) - - 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, + spec = PROFILES[model] + result = dict(model=model, method=settings["method"], api_timeout_seconds=spec["timeout"], + wall_time_seconds=settings.get("task_timeout", spec["task_timeout"]), thinking=spec["thinking"], + summary_timeout_seconds=120, summary_transport_attempts=5, summary_format_rounds=3, + generation_supported=True, same_model_only=True, budget_reset=False, review_calls=0, 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 spec["thinking"]: + result["preserve_thinking"] = True 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"]), summary_transport_attempts=1, summary_format_rounds=1, summary_request_interval_seconds=2, diff --git a/phoenix/settings.py b/phoenix/settings.py index 60714e7..e91253c 100644 --- a/phoenix/settings.py +++ b/phoenix/settings.py @@ -17,15 +17,46 @@ 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) +CONTEXT_FIELDS = ("max_input_tokens", "context_compaction_threshold", "context_compaction_target") + + +def profile(api_model, temperature, top_p, context, output, thinking, *, extra=None, + timeout=240, tool_choice="auto", task_timeout=7200, release=None): + return dict(api_model=api_model, temperature=temperature, top_p=top_p, + max_input_tokens=context, max_tokens=output, thinking=thinking, + extra_body=extra if extra is not None else {"enable_thinking": thinking}, + timeout=timeout, tool_choice=tool_choice, task_timeout=task_timeout, release=release) + + PROFILES = { - "glm-5.2": dict(max_tokens=32768, timeout=240, tool_choice="required", thinking=False, task_timeout=7200), - "qwen3.7-plus": dict(max_tokens=32768, timeout=600, tool_choice="auto", thinking=False, task_timeout=7200), - "kimi-k2.7-code": dict(max_tokens=32768, timeout=240, tool_choice="auto", thinking=True, task_timeout=3000), + "deepseek-v3.1": profile("deepseek-chat", 0.6, 0.95, 131072, None, False, extra={}, release="2025-08-21"), + "deepseek-v3.2": profile("deepseek-chat", 1.0, 0.95, 131072, None, False, extra={}, release="2025-12-01"), + "qwen3-coder-plus": profile("qwen3-coder-plus", 0.7, 0.8, 1000000, 65536, False, extra={}), + "glm-4.7": profile("glm-4.7", 0.7, 1.0, 202752, 131072, True, extra={"thinking": {"type": "enabled"}}), + "minimax-m2.5": profile("MiniMax-M2.5", 1.0, 0.95, 204800, 32768, True, extra={}), + "glm-5.2": profile("glm-5.2", 1.0, 1.0, 1048576, 131072, False, tool_choice="required"), + "qwen3.7-plus": profile("qwen3.7-plus", 1.0, 0.95, 1000000, 131072, False, timeout=600), + "qwen3.7-plus-thinking": profile("qwen3.7-plus", 1.0, 0.95, 1000000, 131072, True, timeout=600), + "qwen-3.8-max": profile("qwen-3.8-max", 1.0, 0.95, 1000000, 131072, False, timeout=600), + # Additional supported models outside the reported experiments. + "kimi-k2.7-code": profile("kimi-k2.7-code", 0.0, 1.0, 131072, 32768, True, task_timeout=3000, + extra={"enable_thinking": True, "preserve_thinking": True}), + "deepseek-v4.1-flash": profile("deepseek-v4.1-flash", 0.0, 1.0, 131072, 32768, False, tool_choice="required"), } -# New-model comparison: inherit the current GLM settings, not model defaults. -PROFILES["deepseek-v4.1-flash"] = dict(PROFILES["glm-5.2"]) + + +def inference_fields(model): + spec = PROFILES[model] + fields = {k: spec[k] for k in ("temperature", "top_p")} + if spec["max_tokens"] is not None: + fields["max_tokens"] = spec["max_tokens"] + return dict(model=spec["api_model"], **fields, **spec["extra_body"]) + + +def context_defaults(limit): + """Scale the existing compression watermarks with the configured context window.""" + return dict(max_input_tokens=limit, context_compaction_threshold=limit * 120000 // 131072, + context_compaction_target=limit * 110000 // 131072) def write_json(path: Path, value): @@ -70,24 +101,24 @@ def load_instances(path: Path, selected=(), limit=0): def model_config(model, api_base, *, shared_budget_mode=False, context_settings=None): profile = PROFILES[model] data = { - "name": "openai/" + model, "api_base": api_base, "api_key": "$PHOENIX_API_KEY", - "temperature": 0.0, "top_p": 1.0, "per_instance_cost_limit": 0, - "total_cost_limit": 0, "per_instance_call_limit": 0, "max_input_tokens": 131072, - "context_compaction_threshold": 120000, "context_compaction_target": 110000, + "name": "openai/" + profile["api_model"], "api_base": api_base, "api_key": "$PHOENIX_API_KEY", + "temperature": profile["temperature"], "top_p": profile["top_p"], "per_instance_cost_limit": 0, + "total_cost_limit": 0, "per_instance_call_limit": 0, **context_defaults(profile["max_input_tokens"]), "context_keep_first_rounds": 5, "context_keep_last_rounds": 5, "retry": {"retries": 8 if shared_budget_mode else 20, "min_wait": 10, "max_wait": 120}, "completion_kwargs": { - "extra_body": {"enable_thinking": profile["thinking"]}, - "max_tokens": profile["max_tokens"], "timeout": profile["timeout"], + "extra_body": copy.deepcopy(profile["extra_body"]), + "timeout": profile["timeout"], "tool_choice": profile["tool_choice"], "num_retries": 0, }, } + if profile["max_tokens"] is not None: + data["completion_kwargs"]["max_tokens"] = profile["max_tokens"] if profile["thinking"]: data["preserve_thinking"] = True - data["completion_kwargs"]["extra_body"]["preserve_thinking"] = True if shared_budget_mode: data["request_min_interval"] = (context_settings or {}).get("api_request_interval", 2) - data.update({k: context_settings[k] for k in CONTEXT_DEFAULTS + data.update({k: context_settings[k] for k in CONTEXT_FIELDS if context_settings and k in context_settings}) if context_settings and context_settings.get("no_truncation"): data.update(reject_truncation=True, context_compaction_threshold=0) @@ -104,7 +135,7 @@ def load_settings(mode, config_path, overrides): "task_timeout", "locations", "stage", "docker_host", "container_cpus", "container_memory", "localization_max_steps", "localization_timeout", "adaptive_io", "io_device", "environment_start_concurrency", "local_command_concurrency", "pin_cpus", - "submission_recovery_timeout", "no_truncation", "exclude_rate_limit_from_budget", "api_request_interval", *CONTEXT_DEFAULTS} + "submission_recovery_timeout", "no_truncation", "exclude_rate_limit_from_budget", "api_request_interval", *CONTEXT_FIELDS} if set(data) - allowed: raise ValueError("Unknown configuration fields: " + ", ".join(sorted(set(data) - allowed))) data.update({k: v for k, v in overrides.items() if v is not None}) @@ -142,7 +173,12 @@ def load_settings(mode, config_path, overrides): data.setdefault("local_command_concurrency", 4) data.setdefault("submission_recovery_timeout", 600) data["task_timeout"] = data.get("task_timeout") or PROFILES[data["model"]]["task_timeout"] - context = {k: data.get(k, v) for k, v in CONTEXT_DEFAULTS.items()} + limit = data.get("max_input_tokens", PROFILES[data["model"]]["max_input_tokens"]) + if type(limit) is not int or limit < 1: + raise ValueError("max_input_tokens must be a positive integer") + for k, v in context_defaults(limit).items(): + data.setdefault(k, v) + context = {k: data[k] for k in CONTEXT_FIELDS} for key, value in context.items(): minimum = 0 if key == "context_compaction_threshold" else 1 if type(value) is not int or value < minimum: @@ -195,17 +231,17 @@ def localization_config(settings): templates = data["agent"]["templates"] templates["system_template"] = templates["system_template"].removeprefix("You are PhoenixRepair.\n") data["agent"]["max_steps"] = settings["localization_max_steps"] + model = settings["model"] + limit = settings.get("max_input_tokens", PROFILES[model]["max_input_tokens"]) data["localization_runtime"] = { - "max_tokens": 32768, "api_timeout": 600, - "tool_choice": "auto", "enable_thinking": False, - "task_timeout": settings.get("localization_timeout"), "action_repeat_limit": 10, - "max_compacted_tokens": 110000, "context_compaction_threshold": 100000, - "context_compaction_target": 90000, "preserve_thinking": False, + "inference": inference_fields(model), + "api_timeout": 240 if model == "kimi-k2.7-code" else 600, + "tool_choice": "auto", "task_timeout": settings.get("localization_timeout"), + "action_repeat_limit": 10, "max_compacted_tokens": limit * 110000 // 131072, + "context_compaction_threshold": limit * 100000 // 131072, + "context_compaction_target": limit * 90000 // 131072, } - runtime = data["localization_runtime"] - if settings["model"] == "kimi-k2.7-code": - runtime.update(enable_thinking=True, preserve_thinking=True, api_timeout=240) if settings.get("no_truncation"): - runtime.update(no_truncation=True, context_compaction_threshold=0, - max_compacted_tokens=settings.get("max_input_tokens", 131072)) + data["localization_runtime"].update(no_truncation=True, context_compaction_threshold=0, + max_compacted_tokens=limit) return data diff --git a/phoenix/summary.py b/phoenix/summary.py index 45ceb19..1883b51 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 LEGACY_METHOD, REPAIR_METHODS, PROFILES, write_json +from phoenix.settings import LEGACY_METHOD, REPAIR_METHODS, PROFILES, inference_fields, write_json from phoenix.run_state import bind, read, digest def sha(path): @@ -69,12 +69,7 @@ def summarize(task, candidates, settings, directory, key, *, shared_budget=False (directory / "prompt.txt").write_text(prompt) write_json(directory / "inputs.json", [{k: v for k, v in row.items() if k != "submission"} for row in inputs]) kimi = settings["model"] == "kimi-k2.7-code" - payload = dict(model=settings["model"], messages=[{"role": "user", "content": prompt}], temperature=0.7, - top_p=1.0, max_tokens=32768 if kimi else 8192, enable_thinking=kimi) - if kimi: - payload["preserve_thinking"] = True - if shared_budget_mode: - payload.update(temperature=0.0, max_tokens=PROFILES[settings["model"]]["max_tokens"]) + payload = dict(inference_fields(settings["model"]), messages=[{"role": "user", "content": prompt}]) timeout = (30, PROFILES[settings["model"]]["timeout"]) if shared_budget_mode else (240 if kimi else 120) bind(directory / "identity.json", {"payload": payload, "api_base": settings["api_base"], "shared_budget": shared_budget}) diff --git a/tests/test_repair.py b/tests/test_repair.py index 750d9d1..9fccc4c 100644 --- a/tests/test_repair.py +++ b/tests/test_repair.py @@ -78,12 +78,47 @@ def test_frozen_location_identity_and_complete_coverage(tmp_path, task, candidat load_location(tmp_path, task, model) -@pytest.mark.parametrize("model", ["glm-5.2", "qwen3.7-plus"]) +@pytest.mark.parametrize("model,api_model,temp,top_p,context,output,thinking", [ + ("deepseek-v3.1", "deepseek-chat", 0.6, 0.95, 131072, None, False), + ("deepseek-v3.2", "deepseek-chat", 1.0, 0.95, 131072, None, False), + ("qwen3-coder-plus", "qwen3-coder-plus", 0.7, 0.80, 1000000, 65536, False), + ("glm-4.7", "glm-4.7", 0.7, 1.00, 202752, 131072, True), + ("minimax-m2.5", "MiniMax-M2.5", 1.0, 0.95, 204800, 32768, True), + ("glm-5.2", "glm-5.2", 1.0, 1.0, 1048576, 131072, False), + ("qwen3.7-plus", "qwen3.7-plus", 1.0, 0.95, 1000000, 131072, False), + ("qwen3.7-plus-thinking", "qwen3.7-plus", 1.0, 0.95, 1000000, 131072, True), + ("qwen-3.8-max", "qwen-3.8-max", 1.0, 0.95, 1000000, 131072, False), +]) @pytest.mark.parametrize("candidate_count", [1, 2]) -def test_complete_localization_to_final_patch(monkeypatch, tmp_path, task, candidate, settings, model, candidate_count): +def test_complete_localization_to_final_patch(monkeypatch, tmp_path, task, candidate, settings, model, candidate_count, + api_model, temp, top_p, context, output, thinking): """Exercise real localization tools and handoff; only API/Docker are faked.""" from phoenix import pipeline, localization, summary - settings.update(model=model, stage="all", concurrency=1) + from phoenix.settings import ROOT, load_settings, model_config + settings = load_settings("PhoenixRepair", ROOT / "configs/models" / model / "PhoenixRepair.yaml", { + "output": settings["output"], "runtime": settings["runtime"], "concurrency": 1, + }) + assert settings["max_input_tokens"] == context + gen = model_config(model, settings["api_base"], shared_budget_mode=True, context_settings=settings) + assert gen["name"] == "openai/" + api_model + assert (gen["temperature"], gen["top_p"], gen["max_input_tokens"]) == (temp, top_p, context) + assert gen.get("preserve_thinking", False) == thinking + + def check_request(payload): + assert (payload["model"], payload["temperature"], payload["top_p"]) == (api_model, temp, top_p) + if output is None: + assert "max_tokens" not in payload + else: + assert payload["max_tokens"] == output + if model in {"glm-5.2", "qwen3.7-plus", "qwen3.7-plus-thinking", "qwen-3.8-max"}: + assert payload["enable_thinking"] is thinking + elif model == "glm-4.7": + assert payload["thinking"] == {"type": "enabled"} + else: + assert "enable_thinking" not in payload + + check_request(dict(model=api_model, temperature=gen["temperature"], top_p=gen["top_p"], + **gen["completion_kwargs"], **gen["completion_kwargs"]["extra_body"])) source = tmp_path / "source" (source / "repo").mkdir(parents=True) (source / "repo/app.py").write_text("value = 1\n") @@ -105,8 +140,8 @@ def test_complete_localization_to_final_patch(monkeypatch, tmp_path, task, candi 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 + check_request(payload) + assert kwargs["timeout"] == 600 name, arguments = next(pending) events.append(name) return dict(choices=[dict(message=dict(role="assistant", content="", tool_calls=[dict( @@ -115,7 +150,7 @@ def api(session, endpoint, key, payload, directory, **kwargs): monkeypatch.setattr(localization, "export_source", lambda *a, **kw: source) class FakeSession: def post(self, url, **kwargs): - assert kwargs["json"]["model"] == model and kwargs["json"]["temperature"] == 0 + check_request(kwargs["json"]) assert kwargs["json"]["messages"][0]["content"].startswith("You are PhoenixRepair.") events.append("summary") class Response: