Spaces:
Running
Running
sync: 190 file da Baida98/AI@977dd543 (2026-08-26 10:41 UTC) [deploy-all]
#115
by Baida07 - opened
- benchmark-extended.mjs +27 -11
benchmark-extended.mjs
CHANGED
|
@@ -76,6 +76,12 @@ const JUDGE_TELEMETRY = {
|
|
| 76 |
provider: process.env.GROQ_API_KEY ? "groq" : process.env.CEREBRAS_API_KEY ? "cerebras" : null,
|
| 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 |
};
|
| 80 |
const _categoriesArg = _A.find(a=>a.startsWith("--categories="));
|
| 81 |
const TARGET_CATEGORIES = _categoriesArg
|
|
@@ -810,23 +816,20 @@ async function judgeWithLLM(question, response, rubric) {
|
|
| 810 |
signal: AbortSignal.timeout(12_000),
|
| 811 |
});
|
| 812 |
if (!r.ok) {
|
| 813 |
-
|
| 814 |
-
JUDGE_TELEMETRY.lastFailure = `HTTP_${r.status}`;
|
| 815 |
return null;
|
| 816 |
}
|
| 817 |
const data = await r.json();
|
| 818 |
const content = data.choices?.[0]?.message?.content ?? "";
|
| 819 |
const m = content.match(/\{[^}]+\}/);
|
| 820 |
if (!m) {
|
| 821 |
-
|
| 822 |
-
JUDGE_TELEMETRY.lastFailure = "JUDGE_EMPTY_OR_NON_JSON";
|
| 823 |
return null;
|
| 824 |
}
|
| 825 |
const scores = JSON.parse(m[0]);
|
| 826 |
for (const d of dims) {
|
| 827 |
if (typeof scores[d] !== "number") {
|
| 828 |
-
|
| 829 |
-
JUDGE_TELEMETRY.lastFailure = "JUDGE_SCHEMA_MISMATCH";
|
| 830 |
return null;
|
| 831 |
}
|
| 832 |
scores[d] = Math.max(0, Math.min(1, +scores[d].toFixed(2)));
|
|
@@ -836,8 +839,7 @@ async function judgeWithLLM(question, response, rubric) {
|
|
| 836 |
_JUDGE_CACHE.set(cacheKey, scores);
|
| 837 |
return scores;
|
| 838 |
} catch (error) {
|
| 839 |
-
|
| 840 |
-
JUDGE_TELEMETRY.lastFailure = error?.name === "AbortError" ? "JUDGE_TIMEOUT" : "JUDGE_REQUEST_ERROR";
|
| 841 |
return null;
|
| 842 |
}
|
| 843 |
}
|
|
@@ -969,6 +971,17 @@ async function callAgent(goal,timeoutMs=90000,options={}){
|
|
| 969 |
terminalStatus=String(body.status||"UNKNOWN");
|
| 970 |
return terminalStatus;
|
| 971 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 972 |
try{
|
| 973 |
const created=await fetch(`${BASE_URL}/api/agent/tasks`,{
|
| 974 |
method:"POST",headers,
|
|
@@ -1073,10 +1086,13 @@ async function callAgent(goal,timeoutMs=90000,options={}){
|
|
| 1073 |
if(done&&!failed&&!sawText&&!out)return{ok:false,output:"",engine,...telemetry(),toolCalls,durationMs:Date.now()-t0,failed:true,failureReason:"NO_OUTPUT"};
|
| 1074 |
if(done&&options.earlyComplete)await cancelTask();
|
| 1075 |
}catch(e){
|
| 1076 |
-
|
|
|
|
|
|
|
| 1077 |
const partial=normalizeAgentOutput(out||"");
|
| 1078 |
const salvageFeature=options.earlyComplete === "typescript"&&partial.length>=120&&/(?:interface|type|class|function|const)\b/.test(partial)&&/(?:subscribe|getState|async|await|try|catch)/.test(partial);
|
| 1079 |
-
|
|
|
|
| 1080 |
}finally{clearTimeout(timer);}
|
| 1081 |
const finalOutput=normalizeAgentOutput(out);
|
| 1082 |
return{ok:finalOutput.length>30&&!failed,output:finalOutput,engine,...telemetry(),toolCalls,durationMs:Date.now()-t0,failed,failureReason};
|
|
@@ -2581,7 +2597,7 @@ async function runOneSeed(seed,opts={}){
|
|
| 2581 |
runtime_input:{profile:"fixed-realistic-chat-v1",persona:BENCHMARK_PERSONA,negative_constraints:true,context_messages:BENCHMARK_CONTEXT.length},
|
| 2582 |
runner_prerequisites:{typescript_required:requiresTypeScript,typescript_bin:requiresTypeScript?TSC_BIN:null},
|
| 2583 |
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},
|
| 2584 |
-
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},
|
| 2585 |
canonical_seed:"1337 (stesse domande per tutti gli agenti — usa --rotate per seed diverso)",
|
| 2586 |
coding:"enterprise: Acc(35%)+Stab(20%)+Auto(15%)+Perf(10%)+Spd(10%)+Cost(5%)+Tool(5%)",
|
| 2587 |
nonCoding:"content: Acc(40%)+Struct(20%)+Comp(15%)+Prec(10%)+Auto(5%)+Spd(5%)+Cost(5%)",
|
|
|
|
| 76 |
provider: process.env.GROQ_API_KEY ? "groq" : process.env.CEREBRAS_API_KEY ? "cerebras" : null,
|
| 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
|
|
|
|
| 816 |
signal: AbortSignal.timeout(12_000),
|
| 817 |
});
|
| 818 |
if (!r.ok) {
|
| 819 |
+
recordJudgeFailure(`HTTP_${r.status}`);
|
|
|
|
| 820 |
return null;
|
| 821 |
}
|
| 822 |
const data = await r.json();
|
| 823 |
const content = data.choices?.[0]?.message?.content ?? "";
|
| 824 |
const m = content.match(/\{[^}]+\}/);
|
| 825 |
if (!m) {
|
| 826 |
+
recordJudgeFailure("JUDGE_EMPTY_OR_NON_JSON");
|
|
|
|
| 827 |
return null;
|
| 828 |
}
|
| 829 |
const scores = JSON.parse(m[0]);
|
| 830 |
for (const d of dims) {
|
| 831 |
if (typeof scores[d] !== "number") {
|
| 832 |
+
recordJudgeFailure("JUDGE_SCHEMA_MISMATCH");
|
|
|
|
| 833 |
return null;
|
| 834 |
}
|
| 835 |
scores[d] = Math.max(0, Math.min(1, +scores[d].toFixed(2)));
|
|
|
|
| 839 |
_JUDGE_CACHE.set(cacheKey, scores);
|
| 840 |
return scores;
|
| 841 |
} catch (error) {
|
| 842 |
+
recordJudgeFailure(error?.name === "AbortError" ? "JUDGE_TIMEOUT" : "JUDGE_REQUEST_ERROR");
|
|
|
|
| 843 |
return null;
|
| 844 |
}
|
| 845 |
}
|
|
|
|
| 971 |
terminalStatus=String(body.status||"UNKNOWN");
|
| 972 |
return terminalStatus;
|
| 973 |
};
|
| 974 |
+
const readStatusAfterAbort=async()=>{
|
| 975 |
+
if(!taskId)return null;
|
| 976 |
+
statusChecks++;
|
| 977 |
+
try{
|
| 978 |
+
const response=await fetch(`${BASE_URL}/api/agent/tasks/${encodeURIComponent(taskId)}/status`,{method:"GET",headers:taskHeaders,signal:AbortSignal.timeout(5000)});
|
| 979 |
+
if(!response.ok)return null;
|
| 980 |
+
const body=await response.json();
|
| 981 |
+
terminalStatus=String(body.status||"UNKNOWN");
|
| 982 |
+
return terminalStatus;
|
| 983 |
+
}catch{return null;}
|
| 984 |
+
};
|
| 985 |
try{
|
| 986 |
const created=await fetch(`${BASE_URL}/api/agent/tasks`,{
|
| 987 |
method:"POST",headers,
|
|
|
|
| 1086 |
if(done&&!failed&&!sawText&&!out)return{ok:false,output:"",engine,...telemetry(),toolCalls,durationMs:Date.now()-t0,failed:true,failureReason:"NO_OUTPUT"};
|
| 1087 |
if(done&&options.earlyComplete)await cancelTask();
|
| 1088 |
}catch(e){
|
| 1089 |
+
const timedOut=e.name==="AbortError";
|
| 1090 |
+
if(timedOut)await readStatusAfterAbort();
|
| 1091 |
+
if(!["SUCCESS","ERROR","CANCELLED"].includes(String(terminalStatus)))await cancelTask();
|
| 1092 |
const partial=normalizeAgentOutput(out||"");
|
| 1093 |
const salvageFeature=options.earlyComplete === "typescript"&&partial.length>=120&&/(?:interface|type|class|function|const)\b/.test(partial)&&/(?:subscribe|getState|async|await|try|catch)/.test(partial);
|
| 1094 |
+
const timeoutReason=terminalStatus?`TIMEOUT_${terminalStatus}`:"TIMEOUT";
|
| 1095 |
+
return{ok:salvageFeature,output:partial,engine,...telemetry(),toolCalls,durationMs:Date.now()-t0,failed:!salvageFeature,failureReason:timedOut?(salvageFeature?`PARTIAL_${timeoutReason}`:timeoutReason):String(e.message||e),partial:salvageFeature};
|
| 1096 |
}finally{clearTimeout(timer);}
|
| 1097 |
const finalOutput=normalizeAgentOutput(out);
|
| 1098 |
return{ok:finalOutput.length>30&&!failed,output:finalOutput,engine,...telemetry(),toolCalls,durationMs:Date.now()-t0,failed,failureReason};
|
|
|
|
| 2597 |
runtime_input:{profile:"fixed-realistic-chat-v1",persona:BENCHMARK_PERSONA,negative_constraints:true,context_messages:BENCHMARK_CONTEXT.length},
|
| 2598 |
runner_prerequisites:{typescript_required:requiresTypeScript,typescript_bin:requiresTypeScript?TSC_BIN:null},
|
| 2599 |
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},
|
| 2600 |
+
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},
|
| 2601 |
canonical_seed:"1337 (stesse domande per tutti gli agenti — usa --rotate per seed diverso)",
|
| 2602 |
coding:"enterprise: Acc(35%)+Stab(20%)+Auto(15%)+Perf(10%)+Spd(10%)+Cost(5%)+Tool(5%)",
|
| 2603 |
nonCoding:"content: Acc(40%)+Struct(20%)+Comp(15%)+Prec(10%)+Auto(5%)+Spd(5%)+Cost(5%)",
|