fix(benchmark): retry the SAME hard prompt after a pause before reaching for a fresh one

Difficulty is judged in the background: the first-ever occurrence of a hard
prompt routes by prior (often low/medium), the oracle's judgement lands in
the cache a couple of seconds later. The route-judged retry fired instantly
with a FRESH template — which has the same first-encounter fate — so the
test could go red exactly when the system was working as designed. The retry
now re-asks the same prompt after 4s (steady-state answer from the cache),
and only then tries a fresh template.
This commit is contained in:
infosave2007
2026-08-08 09:23:53 +03:00
parent 115b04f20e
commit 179c414a0e
+27 -17
View File
@@ -216,24 +216,34 @@ export async function renderBenchmark() {
let ev;
if (test.judge === "route") {
// the test asserts the ROUTER's decision: did it rate this high?
// One retry with a FRESH template: the router deliberately scores
// familiar text lower (novelty), so a single burnt wording must
// not fail the whole assertion.
// Two honest retries. (1) The SAME prompt after a pause: the
// router judges difficulty in the background — the first-ever
// occurrence routes by prior, the judgement lands in the cache a
// couple of seconds later, so the second occurrence is the real
// steady-state answer. (2) A fresh template, in case this one's
// wording clustered into a burnt region.
if (info.tier !== "high" && test.gen) {
const p2 = hardPrompt(test.gen);
try {
const second = await testStream(
{ model, messages: [{ role: "user", content: p2 }], temperature: 0, max_tokens: (test.max || 128) + 256 },
() => {}
);
if (second.tier === "high") {
info.tier = second.tier;
info.selected_model = second.selected_model;
info.task_label = second.task_label;
info.route_source = second.route_source;
info.cost_usd = (info.cost_usd || 0) + (second.cost_usd || 0);
}
} catch { /* keep first attempt */ }
const attempts = [
{ prompt, delayMs: 4000 },
{ prompt: hardPrompt(test.gen), delayMs: 0 },
];
for (const a of attempts) {
if (info.tier === "high") break;
if (a.delayMs) await new Promise((r) => setTimeout(r, a.delayMs));
try {
const again = await testStream(
{ model, messages: [{ role: "user", content: a.prompt }], temperature: 0, max_tokens: (test.max || 128) + 256 },
() => {}
);
info.cost_usd = (info.cost_usd || 0) + (again.cost_usd || 0);
if (again.tier === "high") {
info.tier = again.tier;
info.selected_model = again.selected_model;
info.task_label = again.task_label;
info.route_source = again.route_source;
}
} catch { /* keep previous attempt */ }
}
}
ev = info.tier === "high"
? { status: "pass", score: 1, note: "high ✓" }