The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore(bench): add viewer benchmark harness
Steven Enamakelee31f6e3fb0a
diff --git a/bench/harnesses/viewer/index.html b/bench/harnesses/viewer/index.htmlindex ab4f2db4ae..76f7110bd2 100644--- a/bench/harnesses/viewer/index.html+++ b/bench/harnesses/viewer/index.html@@ -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)}.ok{color:var(--ok)}.mut{color:var(--mut)}+.bad{color:var(--bad)}td strong{font-weight:700}.ok{color:var(--ok)}.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)}@@ -31,7 +31,8 @@ details{margin:6px 0}summary{cursor:pointer}</style></head><body><main id="app"></main>-<script>+<script type="module">+import { count, mem, ms, pct as fpct, secs, usd } from "/format.mjs";// Everything from results/ is untrusted text (prompts, model output): it only ever// reaches the DOM through textContent, never innerHTML.const app = document.getElementById("app");@@ -47,7 +48,7 @@ const api = async (p) => { const r = await fetch(p); if (!r.ok) throw new Error(const e = encodeURIComponent;// Rough token count for a text of `chars` characters (about 3 per token); the tables' measured o200k counts stay as they are.const estTok = (chars) => (chars == null ? null : Math.round(chars / 3));-const pct = (a, b) => (a == null || !b ? "–" : `${((100 * a) / b).toFixed(1)}%`);+const ratio = (a, b) => (a == null || !b ? "–" : `${((100 * a) / b).toFixed(1)}%`);const fmt = (n, d = 0) => n == null ? "–" : Number(n).toLocaleString(undefined, { maximumFractionDigits: d });const link = (href, text) => h("a", { href }, text);const crumbs = (...parts) => h("div", { class: "crumbs" }, parts.flatMap((p, i) => i ? [" / ", p] : [p]));@@ -66,13 +67,18 @@ 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.+function mark(text) {+ const m = text.match(/^\*\*(.+)\*\* (🟢|🔴)$/);+ return m ? h("strong", { class: m[2] === "🟢" ? "ok" : "bad" }, m[1]) : text;+}function mdView(md) {const out = h("div", {});let rows = [];const flush = () => {if (!rows.length) return;const [head, , ...body] = rows;- out.append(table(head, body));+ out.append(table(head, body.map((row) => row.map(mark))));rows = [];};for (const line of md.split("\n")) {@@ -93,10 +99,10 @@ async function run(id) {kids.push(table(["harness", "tasks", "turns", "prompt tok", "completion tok", "cached %", "cost $", "system tok", "tool schema tok", "tools", "errors", "overridden", "system prompt"],d.harnesses.map((x) => [- x.harness, x.tasks, x.calls, fmt(x.prompt_tokens), fmt(x.completion_tokens), fmt(x.cache_pct, 1), fmt(x.cost_usd, 4),- fmt(x.system_prompt_tokens), fmt(x.tool_schema_tokens), fmt(x.tool_count),+ x.harness, x.tasks, count(x.calls), count(x.prompt_tokens), count(x.completion_tokens), fpct(x.cache_pct), usd(x.cost_usd),+ count(x.system_prompt_tokens), count(x.tool_schema_tokens), count(x.tool_count),x.errors ? h("span", { class: "bad" }, x.errors) : 0, x.overridden,- x.sample_task ? link(`#/call/${e(id)}/${e(x.harness)}/${e(x.sample_task)}/${x.sample_seq}`, `~${fmt(estTok(x.system_chars))} tokens`) : "–",+ x.sample_task ? link(`#/call/${e(id)}/${e(x.harness)}/${e(x.sample_task)}/${x.sample_seq}`, `~${count(estTok(x.system_chars))} tokens`) : "–",])));const withTasks = d.harnesses.filter((x) => x.sample_task);if (withTasks.length) {@@ -127,8 +133,8 @@ async function task(id, harness, t) {link(`#/call/${e(id)}/${e(harness)}/${e(t)}/${c.seq}`, i + 1), c.status ?? "–", c.messages,c.prefix_reused_messages == null ? "–" : `${c.prefix_reused_messages}/${c.prev_messages}`,flag(c.same_system_as_prev), flag(c.same_tools_as_prev), c.cache_control_markers,- fmt(c.usage?.prompt_tokens), fmt(c.usage?.cached_tokens), pct(c.usage?.cached_tokens, c.usage?.prompt_tokens), fmt(c.usage?.completion_tokens),- fmt(c.first_token_ms ?? c.ttfb_ms), fmt(c.total_ms), fmt(c.cost_usd, 5),+ count(c.usage?.prompt_tokens), count(c.usage?.cached_tokens), ratio(c.usage?.cached_tokens, c.usage?.prompt_tokens), count(c.usage?.completion_tokens),+ ms(c.first_token_ms ?? c.ttfb_ms), ms(c.total_ms), usd(c.cost_usd),])));}@@ -211,7 +217,7 @@ async function call(id, harness, t, seq) {["cache_control markers", c.cache_control_markers], ["prompt_cache_key", c.prompt_cache_key]].map(([k, v]) => h("span", { class: "tag" }, `${k}: ${v ?? "–"}`))),h("h2", {}, "Raw transcript (Markdown)"),transcriptBox(`/api/runs/${e(id)}/transcript/${e(harness)}/${e(t)}/${seq}`),- h("h2", {}, `System prompt (~${fmt(estTok(c.system_chars))} tokens)`), pre(c.system || "(no system prompt)"),+ h("h2", {}, `System prompt (~${count(estTok(c.system_chars))} tokens)`), pre(c.system || "(no system prompt)"),h("h2", {}, "Sampling & provider params"), pre(c.params),h("h2", {}, "Request headers"), pre(c.headers),h("h2", {}, `Tools (${c.tool_count})`),diff --git a/bench/harnesses/viewer/server.mjs b/bench/harnesses/viewer/server.mjsindex 85546e9632..ed7e19fa0b 100644--- a/bench/harnesses/viewer/server.mjs+++ b/bench/harnesses/viewer/server.mjs@@ -167,6 +167,9 @@ const server = http.createServer(async (req, res) => {};try {if (req.method !== "GET") return send(405, { error: "read-only" });+ if (url.pathname === "/format.mjs") {+ return send(200, fs.readFileSync(path.join(here, "..", "format.mjs"), "utf8"), "text/javascript; charset=utf-8");+ }if (url.pathname === "/favicon.ico") return send(204, "", "image/x-icon");if (url.pathname === "/" || url.pathname === "/index.html") {return send(200, fs.readFileSync(path.join(here, "index.html"), "utf8"), "text/html; charset=utf-8");