Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(bench): correct report generation for edge case with zero iterations

Steven Enamakelf25163ddedd1
diff --git a/bench/harnesses/report.mjs b/bench/harnesses/report.mjs
index e234870525..6ffc3b0a29 100644
--- a/bench/harnesses/report.mjs
+++ b/bench/harnesses/report.mjs
@@ -170,19 +170,21 @@ const f = (v, d = 0) => (v === null || v === undefined ? "-" : Number(v).toFixed
const money = (v) => (v === null || v === undefined ? "-" : usd(v));
/**
- * Mark the best and worst harness for one metric. `better` is "low" or "high"; values that
- * are not numbers are skipped, and nothing is marked when fewer than two harnesses have a
- * value or they all tie. Several harnesses can share a mark.
- * @returns {Array<"best"|"worst"|null>} one entry per input value
+ * Mark the harnesses for one metric. `better` is "low" or "high"; values that are not numbers
+ * are skipped, and nothing is marked when fewer than two harnesses have a value or they all
+ * tie. Ties share a mark: every harness on the top value is "best", every one on the next
+ * distinct value is "runner" (when that is not also the worst), and the bottom value is "worst".
+ * @returns {Array<"best"|"runner"|"worst"|null>} one entry per input value
*/
export function rankRow(values, better) {
const nums = values.filter((v) => typeof v === "number" && Number.isFinite(v));
if (!better || nums.length < 2) return values.map(() => null);
- const lo = Math.min(...nums);
- const hi = Math.max(...nums);
- if (lo === hi) return values.map(() => null);
- const [best, worst] = better === "low" ? [lo, hi] : [hi, lo];
- return values.map((v) => (v === best ? "best" : v === worst ? "worst" : null));
+ const distinct = [...new Set(nums)].sort((a, b) => (better === "low" ? a - b : b - a));
+ if (distinct.length < 2) return values.map(() => null);
+ const best = distinct[0];
+ const worst = distinct[distinct.length - 1];
+ const runner = distinct.length > 2 ? distinct[1] : null;
+ return values.map((v) => (v === best ? "best" : v === worst ? "worst" : v === runner ? "runner" : null));
}
const rate = (num, den) => (den ? num / den : null);
@@ -214,9 +216,10 @@ export function toMarkdown(meta, summary) {
["LLM calls (errors)", (s) => `${count(s.llm_calls)} (${count(s.llm_call_errors)})`],
["prompt / completion tokens", (s) => `${count(s.prompt_tokens)} / ${count(s.completion_tokens)}`],
];
- // Best is bold + 🟒, worst is bold + πŸ”΄: plain Markdown, so it reads in any renderer,
- // and the viewer turns the markers into green and red.
- const cell = (text, rank) => (rank === "best" ? `**${text}** 🟒` : rank === "worst" ? `**${text}** πŸ”΄` : text);
+ // Best is bold + 🟒, runner-up bold + 🟑, worst bold + πŸ”΄: plain Markdown, so it reads in any renderer,
+ // and the viewer turns the markers into green, yellow and red.
+ const MARK = { best: "🟒", runner: "🟑", worst: "πŸ”΄" };
+ const cell = (text, rank) => (rank ? `**${text}** ${MARK[rank]}` : text);
const head = `| metric | ${names.join(" | ")} |\n|---|${names.map(() => "---").join("|")}|`;
const body = rows
.map(([label, fn, raw, better]) => {
diff --git a/bench/harnesses/report.test.mjs b/bench/harnesses/report.test.mjs
index a82f1d645f..e398302b5b 100644
--- a/bench/harnesses/report.test.mjs
+++ b/bench/harnesses/report.test.mjs
@@ -109,8 +109,11 @@ test("a harness that solved nothing has null solved-task KPIs, not zeros", () =>
import { rankRow } from "./report.mjs";
test("rankRow marks best and worst per direction, skips ties and single values", () => {
- assert.deepEqual(rankRow([3, 1, 2], "low"), ["worst", "best", null]);
- assert.deepEqual(rankRow([3, 1, 2], "high"), ["best", "worst", null]);
+ assert.deepEqual(rankRow([3, 1, 2], "low"), ["worst", "best", "runner"]);
+ assert.deepEqual(rankRow([3, 1, 2], "high"), ["best", "worst", "runner"]);
+ assert.deepEqual(rankRow([4, 1, 2, 3], "low"), ["worst", "best", "runner", null]);
+ assert.deepEqual(rankRow([1, 2, 2, 3], "low"), ["best", "runner", "runner", "worst"]);
+ assert.deepEqual(rankRow([1, 2], "low"), ["best", "worst"]);
assert.deepEqual(rankRow([5, 5], "low"), [null, null]);
assert.deepEqual(rankRow([5, null], "low"), [null, null]);
assert.deepEqual(rankRow([1, 1, 9], "low"), ["best", "best", "worst"]);
diff --git a/bench/harnesses/viewer/index.html b/bench/harnesses/viewer/index.html
index 4b102427b8..6840d7b073 100644
--- a/bench/harnesses/viewer/index.html
+++ b/bench/harnesses/viewer/index.html
@@ -5,8 +5,8 @@
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Harness bench viewer</title>
<style>
-:root{--bg:#fff;--fg:#1a1a1a;--mut:#666;--line:#ddd;--card:#f6f6f6;--acc:#0a5fd6;--bad:#c0392b;--ok:#1e8449}
-@media (prefers-color-scheme:dark){:root{--bg:#141414;--fg:#e8e8e8;--mut:#999;--line:#333;--card:#1f1f1f;--acc:#6aa8ff;--bad:#ff7b6b;--ok:#5fd18a}}
+:root{--bg:#fff;--fg:#1a1a1a;--mut:#666;--line:#ddd;--card:#f6f6f6;--acc:#0a5fd6;--bad:#c0392b;--ok:#1e8449;--warn:#b7791f}
+@media (prefers-color-scheme:dark){:root{--bg:#141414;--fg:#e8e8e8;--mut:#999;--line:#333;--card:#1f1f1f;--acc:#6aa8ff;--bad:#ff7b6b;--ok:#5fd18a;--warn:#e6b84a}}
body{margin:0;background:var(--bg);color:var(--fg);font:14px/1.45 system-ui,sans-serif}
main{max-width:1200px;margin:0 auto;padding:16px}
a{color:var(--acc);text-decoration:none}a:hover{text-decoration:underline}
@@ -19,7 +19,7 @@ th{color:var(--mut);font-weight:500}
.wrap{overflow-x:auto}
pre{background:var(--card);border:1px solid var(--line);padding:10px;overflow:auto;max-height:560px;white-space:pre-wrap;word-break:break-word;margin:6px 0}
.tag{display:inline-block;padding:0 6px;border-radius:9px;background:var(--card);border:1px solid var(--line);font-size:12px;margin-right:4px}
-.bad{color:var(--bad)}td strong{font-weight:700}.ok{color:var(--ok)}.mut{color:var(--mut)}
+.bad{color:var(--bad)}td strong{font-weight:700}.ok{color:var(--ok)}.warn{color:var(--warn)}.mut{color:var(--mut)}
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:8px}
.card{background:var(--card);border:1px solid var(--line);padding:10px;border-radius:6px}
.md h1,.md h2,.md h3,.md h4{margin:16px 0 6px}.md h1{font-size:17px}.md h2{font-size:15px}.md h3{font-size:14px}.md h4{font-size:13px;color:var(--mut)}
@@ -67,10 +67,10 @@ async function runs() {
}
// Render summary.md's pipe tables as tables and everything else as text (still textContent only).
-// The report writes the best cell as `**x** 🟒` and the worst as `**x** πŸ”΄`; show them bold green / red.
+// The report writes the best cell as `**x** 🟒`, runners-up as 🟑 and the worst as πŸ”΄; show them bold green / yellow / red.
function mark(text) {
- const m = text.match(/^\*\*(.+)\*\* (🟒|πŸ”΄)$/);
- return m ? h("strong", { class: m[2] === "🟒" ? "ok" : "bad" }, m[1]) : text;
+ const m = text.match(/^\*\*(.+)\*\* (🟒|🟑|πŸ”΄)$/);
+ return m ? h("strong", { class: { "🟒": "ok", "🟑": "warn", "πŸ”΄": "bad" }[m[2]] }, m[1]) : text;
}
function mdView(md) {
const out = h("div", {});