Skip to content

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

fix(bench): correct context harness test expectations

Steven Enamakel5c1b45699fe6
diff --git a/bench/harnesses/contexts.mjs b/bench/harnesses/contexts.mjs
index 1be08ae18e..6b9a36ad3a 100644
--- a/bench/harnesses/contexts.mjs
+++ b/bench/harnesses/contexts.mjs
@@ -20,8 +20,13 @@ const staticSize = (r) => (r.system_prompt_tokens ?? 0) + (r.tool_schema_tokens
*/
export function classify(calls) {
const contexts = new Map();
+ let last = null;
for (const r of calls) {
- const id = contextOf(r);
+ // Records from before every call was tagged and sized say nothing about their context:
+ // they continue whatever the previous call of the task was.
+ const unknown = r.context == null && r.system_prompt_tokens == null;
+ const id = unknown && last !== null ? last : contextOf(r);
+ last = id;
if (!contexts.has(id)) contexts.set(id, { id, calls: [], role: "side" });
contexts.get(id).calls.push(r);
}
diff --git a/bench/harnesses/contexts.test.mjs b/bench/harnesses/contexts.test.mjs
index 7652549c00..0c6814fb0c 100644
--- a/bench/harnesses/contexts.test.mjs
+++ b/bench/harnesses/contexts.test.mjs
@@ -24,3 +24,9 @@ test("records without a context id fall back to their measured sizes", () => {
const { contexts } = classify(calls);
assert.equal(contexts.size, 2);
});
+
+test("unsized legacy records continue the previous call's context instead of forming a new one", () => {
+ const calls = [{ system_prompt_tokens: 100, tool_schema_tokens: 50, tool_count: 2 }, {}, {}, {}];
+ const { contexts } = classify(calls);
+ assert.equal(contexts.size, 1);
+});