Skip to content

Official Codebase of 3DCodeVerse

Python

preflight: probe every model a harness arm needs, not just the generator and judge

gaoypeng98e8ac1a5513
diff --git a/harness/bench/compare_backends.py b/harness/bench/compare_backends.py
index f43dfbf0..3934ba91 100644
--- a/harness/bench/compare_backends.py
+++ b/harness/bench/compare_backends.py
@@ -371,17 +371,32 @@ def run_matrix(battery_path: Path | str, out_dir: Path | str, arms: Sequence[Arm
# ----------------------------------------------------------------------------- CLI
-def _preflight(judge: str, arms: Sequence[Arm], *, wait_minutes: float = 0.0) -> bool:
+def _preflight(judge: str, arms: Sequence[Arm], opts: CompareOptions, *, wait_minutes: float = 0.0) -> bool:
"""Refuse to start a battery against a model that is not serving.
A dead provider does not fail fast on its own: every cell burns its full retry
budget first. On 2026-08-24 that cost ~9 hours of wall clock and a contaminated
battery. One 20-second probe per model is the whole cure.
+
+ Every model a HARNESS arm needs counts, not just the generator: the same outage
+ took down `harness:codex:gpt-5.6-sol` — whose generator is a local subscription
+ CLI and whose judge was healthy — because the default PLANNER is flash. A
+ harness arm is only as available as the weakest model in its loop.
"""
from codeverse.models.health import probe
- models = {judge, *(a.target for a in arms if a.target.startswith(("gemini:", "anthropic:", "openai:")))}
- models |= {a.target.split(":", 1)[1] for a in arms if a.target.startswith("api-agent:")}
+ def api_model(target: str) -> str:
+ """'api-agent:gemini:x' -> 'gemini:x'; a subscription CLI target -> ''."""
+ inner = target.split(":", 1)[1] if target.startswith("api-agent:") else target
+ return inner if inner.startswith(("gemini:", "anthropic:", "openai:")) else ""
+
+ models = {judge, *(api_model(a.target) for a in arms)}
+ if any(a.kind.startswith("harness") for a in arms):
+ # the harness loop runs a planner and its own in-loop judge on EVERY arm,
+ # whatever the generator is
+ backends = get_settings().backends(judge=opts.loop_judge, planner=opts.planner)
+ models |= {backends.planner, backends.judge}
+ models.discard("")
deadline = time.time() + wait_minutes * 60
while True:
sick = [h for h in (probe(m) for m in sorted(models)) if not h.ok]
@@ -436,7 +451,7 @@ def main(argv: Sequence[str] | None = None) -> int:
gen_timeout_s=ns.gen_timeout, repair_attempts=ns.repair_attempts, pairwise=not ns.no_pairwise,
redo_status=[x for x in ns.redo_status.split(",") if x])
arms = parse_arms(ns.arms)
- if not ns.no_preflight and not _preflight(opts.judge, arms, wait_minutes=ns.wait_for_provider):
+ if not ns.no_preflight and not _preflight(opts.judge, arms, opts, wait_minutes=ns.wait_for_provider):
return 2
deps = CompareDeps(FixedEvaluator(opts.judge, n_samples=opts.n_samples))
diff --git a/harness/tests/compare_bench/test_infra_failures.py b/harness/tests/compare_bench/test_infra_failures.py
index 19083838..6d38065f 100644
--- a/harness/tests/compare_bench/test_infra_failures.py
+++ b/harness/tests/compare_bench/test_infra_failures.py
@@ -104,3 +104,52 @@ def test_budget_and_outage_are_different_buckets():
outage = "ModelError: Gemini API error 503: This model is currently experiencing high demand."
assert is_budget_exhaustion(budget) and not is_infra_failure(budget)
assert is_infra_failure(outage) and not is_budget_exhaustion(outage)
+
+
+def test_preflight_probes_every_model_a_harness_arm_needs(monkeypatch):
+ """A harness arm is only as available as the weakest model in its loop.
+
+ Regression (2026-08-24): `harness:codex:gpt-5.6-sol` — a local subscription CLI
+ generator with a healthy judge — was stuck for hours because the default PLANNER
+ is gemini-3.7-flash, which was down. The first preflight only probed the judge
+ and the arm targets, so it would have waved those runs straight into the wall.
+ """
+ from bench import compare_backends as cb
+ from codeverse.models.health import Health
+
+ probed: list[str] = []
+
+ def fake_probe(model, **_):
+ probed.append(model)
+ return Health(model=model, n_ok=4, n_tried=4)
+
+ monkeypatch.setattr("codeverse.models.health.probe", fake_probe)
+ arms = cb.parse_arms("harness:codex:gpt-5.6-sol")
+ opts = cb.CompareOptions(judge="gemini:fixed-judge")
+ assert cb._preflight("gemini:fixed-judge", arms, opts) is True
+
+ assert "gemini:fixed-judge" in probed, "the fixed judge must always be probed"
+ planner = get_settings_planner()
+ assert planner in probed, f"the harness planner {planner!r} was not probed: {probed}"
+ # the subscription CLI is not an API model and has nothing to probe
+ assert not any("codex" in m for m in probed), probed
+
+
+def get_settings_planner() -> str:
+ from codeverse.config import get_settings
+
+ return get_settings().backends().planner
+
+
+def test_preflight_skips_loop_models_for_oneshot_only_batteries(monkeypatch):
+ """A one-shot battery runs no harness loop, so it must not be blocked by a
+ planner it will never call."""
+ from bench import compare_backends as cb
+ from codeverse.models.health import Health
+
+ probed: list[str] = []
+ monkeypatch.setattr("codeverse.models.health.probe",
+ lambda m, **_: (probed.append(m), Health(model=m, n_ok=4, n_tried=4))[1])
+ arms = cb.parse_arms("oneshot:claude-code,oneshot:codex")
+ assert cb._preflight("gemini:fixed-judge", arms, cb.CompareOptions(judge="gemini:fixed-judge")) is True
+ assert probed == ["gemini:fixed-judge"], probed