"""Сравнение агентных eval-отчётов (money-gate) — кандидат-провайдер против baseline (Claude). Читает agent_eval_.json и agent_eval_.json (вывод model_eval_agent.py), выносит блокирующий вердикт: - REJECT, если кандидат провалил кейс, который baseline прошёл (жёсткий регресс), ИЛИ baseline сам провалил всё (сравнение недействительно — сеть/ключ/провайдер). - OK иначе. Печатает построчную таблицу + список регрессов, чтобы было видно, ЧТО именно поедет при выкате. Запуск: python3 model_eval_agent_compare.py agent_eval_anthropic.json agent_eval_deepseek.json """ from __future__ import annotations import json import sys from pathlib import Path def _load(p: str) -> dict | None: fp = Path(p) return json.loads(fp.read_text(encoding="utf-8")) if fp.exists() else None def compare(baseline: dict, candidate: dict) -> dict: b = {r["id"]: r for r in baseline["results"]} c = {r["id"]: r for r in candidate["results"]} rows, hard_reg, new_errors = [], [], [] for cid, br in b.items(): cr = c.get(cid, {}) bo, co = br["ok"], cr.get("ok", False) reg = bo and not co # baseline прошёл, кандидат — нет if reg: hard_reg.append(cid) if cr.get("errored") and not br.get("errored"): new_errors.append(cid) rows.append({ "id": cid, "baseline_ok": bo, "candidate_ok": co, "regression": reg, "cand_tools": cr.get("tools_called", []), "cand_missing": cr.get("missing_markers", []), "cand_errored": cr.get("errored"), }) invalid = baseline.get("passed", 0) == 0 verdict = "REJECT" if (invalid or hard_reg) else "OK" reasons = [] if invalid: reasons.append("baseline (Claude) не прошёл НИ ОДНОГО кейса — сравнение недействительно " "(проверь сеть/подписку), promote не открывается") if hard_reg: reasons.append(f"кандидат провалил кейсы, которые Claude прошёл: {', '.join(hard_reg)} (регресс)") if new_errors: reasons.append(f"кандидат дал ошибку/пусто там, где Claude отвечал: {', '.join(new_errors)}") return { "baseline": baseline["provider"], "baseline_model": baseline.get("model"), "candidate": candidate["provider"], "candidate_model": candidate.get("model"), "baseline_passed": f"{baseline['passed']}/{baseline['total']}", "candidate_passed": f"{candidate['passed']}/{candidate['total']}", "verdict": verdict, "hard_regressions": hard_reg, "reasons": reasons, "rows": rows, } def main(argv=None) -> int: argv = argv or sys.argv[1:] if len(argv) < 2: print("usage: model_eval_agent_compare.py ") return 2 baseline, candidate = _load(argv[0]), _load(argv[1]) if not baseline or not candidate: print(f"нет отчёта: baseline={bool(baseline)} candidate={bool(candidate)}") return 2 rep = compare(baseline, candidate) print(f"BASELINE {rep['baseline']} ({rep['baseline_model']}) {rep['baseline_passed']} vs " f"CANDIDATE {rep['candidate']} ({rep['candidate_model']}) {rep['candidate_passed']}") print(f"{'кейс':24} {'Claude':7} {'кандидат':9} регресс") for r in rep["rows"]: flag = "⚠РЕГРЕСС" if r["regression"] else "" print(f" {r['id']:22} {'OK' if r['baseline_ok'] else 'FAIL':7} " f"{'OK' if r['candidate_ok'] else 'FAIL':9} {flag}" + (f" miss={r['cand_missing']}" if r['cand_missing'] else "")) print(f"\nВЕРДИКТ: {rep['verdict']}" + (f" — {'; '.join(rep['reasons'])}" if rep['reasons'] else " (кандидат не хуже Claude)")) return 0 if rep["verdict"] == "OK" else 1 if __name__ == "__main__": raise SystemExit(main())