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): update viewer benchmark harness
Steven Enamakel9bd1a033789d
diff --git a/bench/harnesses/viewer/index.html b/bench/harnesses/viewer/index.htmlindex 76f7110bd2..4b102427b8 100644--- a/bench/harnesses/viewer/index.html+++ b/bench/harnesses/viewer/index.html@@ -97,9 +97,9 @@ async function run(id) {const d = await api(`/api/runs/${e(id)}`);const kids = [h("h1", {}, id), crumbs(link("#/", "runs"), id), h("h2", {}, "Harnesses (from the meter proxy, on the wire)")];kids.push(table(- ["harness", "tasks", "turns", "prompt tok", "completion tok", "cached %", "cost $", "system tok", "tool schema tok", "tools", "errors", "overridden", "system prompt"],+ ["harness", "tasks", "turns", "side 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, count(x.calls), count(x.prompt_tokens), count(x.completion_tokens), fpct(x.cache_pct), usd(x.cost_usd),+ x.harness, x.tasks, count(x.calls), count(x.side_turns), 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}`, `~${count(estTok(x.system_chars))} tokens`) : "–",@@ -127,10 +127,10 @@ async function task(id, harness, t) {crumbs(link("#/", "runs"), link(`#/run/${e(id)}`, id), harness, t),h("h2", {}, "Full task transcript (Markdown)"),transcriptBox(`/api/runs/${e(id)}/transcript/${e(harness)}/${e(t)}/last`),- h("p", { class: "mut" }, "A turn is one request to the model and its response; a task is made of several. ‘prefix reused’ is how many of the previous call’s messages this call re-sent byte-for-byte; below the previous count, history was rewritten and provider prefix caching is lost from there."),- table(["turn", "status", "messages", "prefix reused", "system", "tools", "cache ctl", "prompt tok", "cached tok", "cached %", "completion", "first token ms", "total ms", "cost $"],+ h("p", { class: "mut" }, "A turn is one request to the model and its response; a task is made of several. ‘agent’ separates the main agent from side requests (titles, summaries) and sub-agents, which carry their own system prompt and tools. ‘prefix reused’ is how many of the previous call’s messages this call re-sent byte-for-byte; below the previous count, history was rewritten and provider prefix caching is lost from there."),+ table(["turn", "agent", "status", "messages", "prefix reused", "system", "tools", "cache ctl", "prompt tok", "cached tok", "cached %", "completion", "first token ms", "total ms", "cost $"],calls.map((c, i) => [- link(`#/call/${e(id)}/${e(harness)}/${e(t)}/${c.seq}`, i + 1), c.status ?? "–", c.messages,+ link(`#/call/${e(id)}/${e(harness)}/${e(t)}/${c.seq}`, i + 1), h("span", { class: c.agent === "main" ? "" : "tag" }, c.agent ?? "main"), 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,count(c.usage?.prompt_tokens), count(c.usage?.cached_tokens), ratio(c.usage?.cached_tokens, c.usage?.prompt_tokens), count(c.usage?.completion_tokens),diff --git a/bench/harnesses/viewer/server.mjs b/bench/harnesses/viewer/server.mjsindex 4a64902673..4bc9cf5817 100644--- a/bench/harnesses/viewer/server.mjs+++ b/bench/harnesses/viewer/server.mjs@@ -14,6 +14,7 @@ import http from "node:http";import path from "node:path";import readline from "node:readline";import { fileURLToPath } from "node:url";+import { classify } from "../contexts.mjs";import { orderHarnesses } from "../format.mjs";import { toMarkdown } from "./transcript.mjs";@@ -55,6 +56,18 @@ async function meterRecords(run) {const sum = (xs, f) => xs.reduce((a, x) => a + (f(x) ?? 0), 0);+/** Calls that are not the main agent (side requests, sub-agents), classified per task. */+function sideTurns(records) {+ const tasks = new Map();+ for (const r of records) (tasks.get(r.task) ?? tasks.set(r.task, []).get(r.task)).push(r);+ let n = 0;+ for (const calls of tasks.values()) {+ const { main, contexts } = classify(calls);+ for (const c of contexts.values()) if (c.id !== main) n += c.calls.length;+ }+ return n;+}+function aggregate(records) {const by = {};for (const r of records) {@@ -78,6 +91,7 @@ function aggregate(records) {system_prompt_tokens: first?.system_prompt_tokens ?? null,tool_schema_tokens: first?.tool_schema_tokens ?? null,tool_count: first?.tool_count ?? null,+ side_turns: sideTurns(h.records),errors: h.records.filter((r) => r.error || (r.status && r.status >= 400)).length,overridden: h.records.filter((r) => r.overridden && Object.keys(r.overridden).length).length,};@@ -144,11 +158,17 @@ const routes = [[/^\/api\/runs\/([^/]+)\/calls\/([^/]+)\/([^/]+)$/, ([run, harness, task]) => {const d = capDir(run, harness, task);- return fs.readdirSync(d).sort().map((f) => {- const c = readJson(path.join(d, f));+ const full = fs.readdirSync(d).sort().map((f) => readJson(path.join(d, f)));+ // Label each turn main / side N from its system prompt + tool list (tools dominate the size tie-break).+ const { contexts } = classify(full.map((c) => ({+ context: `${c.system_sha}.${c.tools_sha}`,+ system_prompt_tokens: (c.system_chars ?? 0) / 3,+ tool_schema_tokens: (c.tool_count ?? 0) * 1000,+ })));+ return full.map((c) => {// Per-call summary only; the heavy fields stay on disk until a call is opened.const { response, params, headers, message_shas, ...rest } = c;- return { ...rest, messages: message_shas.length };+ return { ...rest, messages: message_shas.length, agent: contexts.get(`${c.system_sha}.${c.tools_sha}`)?.label ?? "main" };});}],