Spaces:
Running
Running
sync: 190 file da Baida98/AI@12bc67f1 (2026-08-26 12:40 UTC) [deploy-all] (#119)
Browse files- sync: 190 file da Baida98/AI@12bc67f1 (2026-08-26 12:40 UTC) [deploy-all] (e5f1ba9d7ecb0c92ee27f6886b59f25c7c07e546)
- benchmark-extended.mjs +57 -20
benchmark-extended.mjs
CHANGED
|
@@ -77,12 +77,25 @@ const JUDGE_TELEMETRY = {
|
|
| 77 |
model: process.env.GROQ_API_KEY ? "openai/gpt-oss-120b" : process.env.CEREBRAS_API_KEY ? "llama-3.3-70b" : null,
|
| 78 |
lastFailure: null,
|
| 79 |
failureReasons: {},
|
|
|
|
|
|
|
|
|
|
| 80 |
};
|
| 81 |
const recordJudgeFailure = (reason) => {
|
| 82 |
JUDGE_TELEMETRY.failed++;
|
| 83 |
JUDGE_TELEMETRY.lastFailure = reason;
|
| 84 |
JUDGE_TELEMETRY.failureReasons[reason] = (JUDGE_TELEMETRY.failureReasons[reason] ?? 0) + 1;
|
| 85 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
const _categoriesArg = _A.find(a=>a.startsWith("--categories="));
|
| 87 |
const TARGET_CATEGORIES = _categoriesArg
|
| 88 |
? new Set(_categoriesArg.slice("--categories=".length).split(",").map(c=>c.trim()).filter(Boolean))
|
|
@@ -95,6 +108,9 @@ const G="\x1b[32m",R="\x1b[31m",Y="\x1b[33m",B="\x1b[34m",
|
|
| 95 |
// ββ Constants βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 96 |
const _baseUrlArg = _A.find(a=>a.startsWith("--base-url="));
|
| 97 |
const BASE_URL = (_baseUrlArg ? _baseUrlArg.slice("--base-url=".length) : (process.env.BENCHMARK_BASE_URL ?? process.env.BACKEND_URL ?? "https://baida07-terminal.hf.space")).replace(/\/+$/, "");
|
|
|
|
|
|
|
|
|
|
| 98 |
const TASK_DIR = "/tmp/bench-ext/tasks";
|
| 99 |
const RUNNER_DIR = dirname(fileURLToPath(import.meta.url));
|
| 100 |
let TSC_BIN = "";
|
|
@@ -836,25 +852,46 @@ async function judgeWithLLM(question, response, rubric) {
|
|
| 836 |
};
|
| 837 |
}
|
| 838 |
JUDGE_TELEMETRY.requested++;
|
| 839 |
-
|
| 840 |
-
|
| 841 |
-
|
| 842 |
-
|
| 843 |
-
|
| 844 |
-
|
| 845 |
-
|
| 846 |
-
|
| 847 |
-
|
|
|
|
|
|
|
|
|
|
| 848 |
return null;
|
| 849 |
}
|
| 850 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 851 |
const content = data.choices?.[0]?.message?.content ?? "";
|
| 852 |
const m = content.match(/\{[^}]+\}/);
|
| 853 |
if (!m) {
|
| 854 |
recordJudgeFailure("JUDGE_EMPTY_OR_NON_JSON");
|
| 855 |
return null;
|
| 856 |
}
|
| 857 |
-
|
|
|
|
|
|
|
| 858 |
for (const d of dims) {
|
| 859 |
if (typeof scores[d] !== "number") {
|
| 860 |
recordJudgeFailure("JUDGE_SCHEMA_MISMATCH");
|
|
@@ -862,14 +899,14 @@ async function judgeWithLLM(question, response, rubric) {
|
|
| 862 |
}
|
| 863 |
scores[d] = Math.max(0, Math.min(1, +scores[d].toFixed(2)));
|
| 864 |
}
|
| 865 |
-
JUDGE_TELEMETRY.succeeded++;
|
| 866 |
-
JUDGE_TELEMETRY.lastFailure = null;
|
| 867 |
-
_JUDGE_CACHE.set(cacheKey, scores);
|
| 868 |
return scores;
|
| 869 |
-
}
|
| 870 |
-
|
| 871 |
-
|
| 872 |
-
|
|
|
|
|
|
|
|
|
|
| 873 |
}
|
| 874 |
|
| 875 |
function tDir(id){
|
|
@@ -2485,7 +2522,7 @@ async function runOneSeed(seed,opts={}){
|
|
| 2485 |
const t0=Date.now();
|
| 2486 |
// Il target resta una metrica di punteggio; non Γ¨ un hard-stop di trasporto.
|
| 2487 |
// I fallback gratuiti possono richiedere piΓΉ tempo per il primo chunk su task coding.
|
| 2488 |
-
const transportTimeout = (task.category === "feature" || task.category === "research_synthesis") ? 150000 : Math.max(task.targetMs||65000,180000);
|
| 2489 |
let agent=await callAgentWithRetry(task,transportTimeout);
|
| 2490 |
const repair=await repairSecurityIfNeeded(task,agent,Math.min(transportTimeout,120000));
|
| 2491 |
agent=repair.agent;
|
|
@@ -2628,7 +2665,7 @@ async function runOneSeed(seed,opts={}){
|
|
| 2628 |
runtime_input:{profile:"fixed-realistic-chat-v1",persona:BENCHMARK_PERSONA,negative_constraints:true,context_messages:BENCHMARK_CONTEXT.length},
|
| 2629 |
runner_prerequisites:{typescript_required:requiresTypeScript,typescript_bin:requiresTypeScript?TSC_BIN:null},
|
| 2630 |
sse_recovery:{resume:"Last-Event-ID",deduplicate_replayed_event_ids:true,max_reconnects:1,status_endpoint:"/api/agent/tasks/{taskId}/status",cancel_on_nonterminal_incomplete:true},
|
| 2631 |
-
semantic_judge:{enabled:F_JUDGE,provider:JUDGE_TELEMETRY.provider,model:JUDGE_TELEMETRY.model,requested:JUDGE_TELEMETRY.requested,succeeded:JUDGE_TELEMETRY.succeeded,failed:JUDGE_TELEMETRY.failed,cache_hits:JUDGE_TELEMETRY.cacheHits,last_failure:JUDGE_TELEMETRY.lastFailure,failure_reasons:JUDGE_TELEMETRY.failureReasons,coverage_complete:JUDGE_TELEMETRY.requested===JUDGE_TELEMETRY.succeeded},
|
| 2632 |
canonical_seed:"1337 (stesse domande per tutti gli agenti β usa --rotate per seed diverso)",
|
| 2633 |
coding:"enterprise: Acc(35%)+Stab(20%)+Auto(15%)+Perf(10%)+Spd(10%)+Cost(5%)+Tool(5%)",
|
| 2634 |
nonCoding:"content: Acc(40%)+Struct(20%)+Comp(15%)+Prec(10%)+Auto(5%)+Spd(5%)+Cost(5%)",
|
|
|
|
| 77 |
model: process.env.GROQ_API_KEY ? "openai/gpt-oss-120b" : process.env.CEREBRAS_API_KEY ? "llama-3.3-70b" : null,
|
| 78 |
lastFailure: null,
|
| 79 |
failureReasons: {},
|
| 80 |
+
attempts: 0,
|
| 81 |
+
retries: 0,
|
| 82 |
+
recoveredRetries: 0,
|
| 83 |
};
|
| 84 |
const recordJudgeFailure = (reason) => {
|
| 85 |
JUDGE_TELEMETRY.failed++;
|
| 86 |
JUDGE_TELEMETRY.lastFailure = reason;
|
| 87 |
JUDGE_TELEMETRY.failureReasons[reason] = (JUDGE_TELEMETRY.failureReasons[reason] ?? 0) + 1;
|
| 88 |
};
|
| 89 |
+
const classifyJudgeHttpFailure = (status, raw, isGroq) => {
|
| 90 |
+
const text = String(raw || "").toLowerCase();
|
| 91 |
+
if (status === 401 || status === 403) return "JUDGE_AUTH_REJECTED";
|
| 92 |
+
if (status === 429 || /rate.?limit|too many requests/.test(text)) return "JUDGE_RATE_LIMIT";
|
| 93 |
+
if (status >= 500) return "JUDGE_PROVIDER_5XX";
|
| 94 |
+
if (isGroq && status === 400 && /json.?schema|response_format|strict/.test(text)) return "GROQ_SCHEMA_REJECTED";
|
| 95 |
+
if (isGroq && status === 400 && /reasoning_effort|include_reasoning|max_completion_tokens|parameter/.test(text)) return "GROQ_PARAMETER_REJECTED";
|
| 96 |
+
if (status >= 400 && status < 500) return "JUDGE_REQUEST_REJECTED";
|
| 97 |
+
return `HTTP_${status}`;
|
| 98 |
+
};
|
| 99 |
const _categoriesArg = _A.find(a=>a.startsWith("--categories="));
|
| 100 |
const TARGET_CATEGORIES = _categoriesArg
|
| 101 |
? new Set(_categoriesArg.slice("--categories=".length).split(",").map(c=>c.trim()).filter(Boolean))
|
|
|
|
| 108 |
// ββ Constants βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 109 |
const _baseUrlArg = _A.find(a=>a.startsWith("--base-url="));
|
| 110 |
const BASE_URL = (_baseUrlArg ? _baseUrlArg.slice("--base-url=".length) : (process.env.BENCHMARK_BASE_URL ?? process.env.BACKEND_URL ?? "https://baida07-terminal.hf.space")).replace(/\/+$/, "");
|
| 111 |
+
const TEST_TRANSPORT_TIMEOUT_MS = process.env.BENCHMARK_TEST_TRANSPORT_TIMEOUT_MS && process.env.NODE_ENV === "test"
|
| 112 |
+
? Math.max(50, Number(process.env.BENCHMARK_TEST_TRANSPORT_TIMEOUT_MS) || 0)
|
| 113 |
+
: null;
|
| 114 |
const TASK_DIR = "/tmp/bench-ext/tasks";
|
| 115 |
const RUNNER_DIR = dirname(fileURLToPath(import.meta.url));
|
| 116 |
let TSC_BIN = "";
|
|
|
|
| 852 |
};
|
| 853 |
}
|
| 854 |
JUDGE_TELEMETRY.requested++;
|
| 855 |
+
const executeJudge = async (payload, isFallback = false) => {
|
| 856 |
+
JUDGE_TELEMETRY.attempts++;
|
| 857 |
+
let r;
|
| 858 |
+
try {
|
| 859 |
+
r = await fetch(endpoint, {
|
| 860 |
+
method: "POST",
|
| 861 |
+
headers: { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json" },
|
| 862 |
+
body: JSON.stringify(payload),
|
| 863 |
+
signal: AbortSignal.timeout(12_000),
|
| 864 |
+
});
|
| 865 |
+
} catch (error) {
|
| 866 |
+
recordJudgeFailure(error?.name === "AbortError" ? "JUDGE_TIMEOUT" : "JUDGE_REQUEST_ERROR");
|
| 867 |
return null;
|
| 868 |
}
|
| 869 |
+
if (!r.ok) {
|
| 870 |
+
const raw = await r.text().catch(() => "");
|
| 871 |
+
const reason = classifyJudgeHttpFailure(r.status, raw, isGroq);
|
| 872 |
+
recordJudgeFailure(reason);
|
| 873 |
+
const recoverable = isGroq && !isFallback && (reason === "GROQ_SCHEMA_REJECTED" || reason === "GROQ_PARAMETER_REJECTED");
|
| 874 |
+
if (!recoverable) return null;
|
| 875 |
+
JUDGE_TELEMETRY.retries++;
|
| 876 |
+
const fallback = { ...payload, response_format: { type: "json_object" } };
|
| 877 |
+
delete fallback.reasoning_effort;
|
| 878 |
+
delete fallback.include_reasoning;
|
| 879 |
+
const recovered = await executeJudge(fallback, true);
|
| 880 |
+
if (recovered) JUDGE_TELEMETRY.recoveredRetries++;
|
| 881 |
+
return recovered;
|
| 882 |
+
}
|
| 883 |
+
let data;
|
| 884 |
+
try { data = await r.json(); }
|
| 885 |
+
catch { recordJudgeFailure("JUDGE_INVALID_JSON_RESPONSE"); return null; }
|
| 886 |
const content = data.choices?.[0]?.message?.content ?? "";
|
| 887 |
const m = content.match(/\{[^}]+\}/);
|
| 888 |
if (!m) {
|
| 889 |
recordJudgeFailure("JUDGE_EMPTY_OR_NON_JSON");
|
| 890 |
return null;
|
| 891 |
}
|
| 892 |
+
let scores;
|
| 893 |
+
try { scores = JSON.parse(m[0]); }
|
| 894 |
+
catch { recordJudgeFailure("JUDGE_INVALID_SCORE_JSON"); return null; }
|
| 895 |
for (const d of dims) {
|
| 896 |
if (typeof scores[d] !== "number") {
|
| 897 |
recordJudgeFailure("JUDGE_SCHEMA_MISMATCH");
|
|
|
|
| 899 |
}
|
| 900 |
scores[d] = Math.max(0, Math.min(1, +scores[d].toFixed(2)));
|
| 901 |
}
|
|
|
|
|
|
|
|
|
|
| 902 |
return scores;
|
| 903 |
+
};
|
| 904 |
+
const scores = await executeJudge(request);
|
| 905 |
+
if (!scores) return null;
|
| 906 |
+
JUDGE_TELEMETRY.succeeded++;
|
| 907 |
+
JUDGE_TELEMETRY.lastFailure = null;
|
| 908 |
+
_JUDGE_CACHE.set(cacheKey, scores);
|
| 909 |
+
return scores;
|
| 910 |
}
|
| 911 |
|
| 912 |
function tDir(id){
|
|
|
|
| 2522 |
const t0=Date.now();
|
| 2523 |
// Il target resta una metrica di punteggio; non Γ¨ un hard-stop di trasporto.
|
| 2524 |
// I fallback gratuiti possono richiedere piΓΉ tempo per il primo chunk su task coding.
|
| 2525 |
+
const transportTimeout = TEST_TRANSPORT_TIMEOUT_MS ?? ((task.category === "feature" || task.category === "research_synthesis") ? 150000 : Math.max(task.targetMs||65000,180000));
|
| 2526 |
let agent=await callAgentWithRetry(task,transportTimeout);
|
| 2527 |
const repair=await repairSecurityIfNeeded(task,agent,Math.min(transportTimeout,120000));
|
| 2528 |
agent=repair.agent;
|
|
|
|
| 2665 |
runtime_input:{profile:"fixed-realistic-chat-v1",persona:BENCHMARK_PERSONA,negative_constraints:true,context_messages:BENCHMARK_CONTEXT.length},
|
| 2666 |
runner_prerequisites:{typescript_required:requiresTypeScript,typescript_bin:requiresTypeScript?TSC_BIN:null},
|
| 2667 |
sse_recovery:{resume:"Last-Event-ID",deduplicate_replayed_event_ids:true,max_reconnects:1,status_endpoint:"/api/agent/tasks/{taskId}/status",cancel_on_nonterminal_incomplete:true},
|
| 2668 |
+
semantic_judge:{enabled:F_JUDGE,provider:JUDGE_TELEMETRY.provider,model:JUDGE_TELEMETRY.model,requested:JUDGE_TELEMETRY.requested,succeeded:JUDGE_TELEMETRY.succeeded,failed:JUDGE_TELEMETRY.failed,attempts:JUDGE_TELEMETRY.attempts,retries:JUDGE_TELEMETRY.retries,recovered_retries:JUDGE_TELEMETRY.recoveredRetries,cache_hits:JUDGE_TELEMETRY.cacheHits,last_failure:JUDGE_TELEMETRY.lastFailure,failure_reasons:JUDGE_TELEMETRY.failureReasons,coverage_complete:JUDGE_TELEMETRY.requested===JUDGE_TELEMETRY.succeeded},
|
| 2669 |
canonical_seed:"1337 (stesse domande per tutti gli agenti β usa --rotate per seed diverso)",
|
| 2670 |
coding:"enterprise: Acc(35%)+Stab(20%)+Auto(15%)+Perf(10%)+Spd(10%)+Cost(5%)+Tool(5%)",
|
| 2671 |
nonCoding:"content: Acc(40%)+Struct(20%)+Comp(15%)+Prec(10%)+Auto(5%)+Spd(5%)+Cost(5%)",
|