3D engine that AI agents drive
Add six long agent suite tasks, repeated runs and per-model totals
Nguyen Xuan An4d2d636e9093
diff --git a/bench/agent-modeling/README.md b/bench/agent-modeling/README.mdindex 636aaec5..5f713d66 100644--- a/bench/agent-modeling/README.md+++ b/bench/agent-modeling/README.md@@ -39,6 +39,12 @@ own mesh report:| dice | Rounded edges plus 21 recessed pips, in one piece (harder) || flange | A hollow pipe with flanges and 12 bolt holes, in one piece (harder) || chair | Many exact parts, with open gaps between back slats (harder) |+| chamfer-plate | Long: a plate with a chamfered top rim and six blind pockets, in one piece (chamfer edit, six cuts) |+| slotted-rail | Long: a bar with every edge chamfered and five through slots, in one piece |+| crate-revision | Long: starts from the crate recipe in the prompt; raise the lid, then drill a blind hole into the body |+| bracket-revision | Long: starts from the L bracket recipe in the prompt; lengthen the base, recentre it, move to three holes |+| workshop | Long: a whole scene, a floor slab with a table, a chair and a mug, 12 parts that rest on each other |+| robot-shot | Long: the robot with both hands placed by IK, then a side-on camera, checked from the exported recipe |`references.mjs` holds one hand-built solution per task. `tests/agent-modeling-suite.test.js` checks that everyreference passes and that broken variants fail. That keeps a wrong checker from costing an agent run.@@ -61,6 +67,27 @@ the session, goes to `results/<run>.json`. Grade one recipe by hand withCompare runs only when they use the same model and suite version. A single run per task is noisy, so read differencesof one or two tasks as noise.+### Several runs and several models++`--runs 3` repeats every task three times, each in a fresh session. Raw files are named `<task>-<attempt>`, each record+has an `attempt`, and the summary adds `byModel`: runs, passes, success rate, tool calls, tool errors, input and output+tokens and cost for the model and for each of its tasks. `--resume <run name> --runs 3` skips the attempts already+recorded and continues. One run file holds one model, so a second model is a second run:++```sh+node bench/agent-modeling/run.mjs --claude <path to claude> --model sonnet --runs 3 --label long+node bench/agent-modeling/run.mjs --claude <path to claude> --model haiku --runs 3 --label long+node bench/agent-modeling/aggregate.mjs bench/agent-modeling/results/<sonnet run>.json bench/agent-modeling/results/<haiku run>.json+```++`aggregate.mjs` prints one row per model and one per task. Recorded failure details have local paths replaced by+`<local path>`, and `tests/agent-suite-aggregate.test.js` fails if a results file holds one.++The six long tasks (from `chamfer-plate` on) are meant to be hard for a single `scene_create`: they need sub-element+edits (chamfers, cuts), changes to a given scene, many parts or a posed character with a camera. Their references pass+and each plausible wrong variant fails the right check (`tests/agent-modeling-suite.test.js`), but no model has run+them yet, so how hard they are is not measured.+## Look scoreThe checks read the exported recipe, so a task can pass and still look wrong. The look score measures what a persondiff --git a/bench/agent-modeling/aggregate.mjs b/bench/agent-modeling/aggregate.mjsnew file mode 100644index 00000000..64df4bca--- /dev/null+++ b/bench/agent-modeling/aggregate.mjs@@ -0,0 +1,52 @@+// Totals for the suite's records, kept apart from run.mjs so tests can read them without starting a model.+// CLI: node bench/agent-modeling/aggregate.mjs <results file>... prints one table row per model.+import { readFile } from 'node:fs/promises';+import { fileURLToPath } from 'node:url';++const LOCAL_PATH_PATTERN = /(?:[A-Za-z]:)?[\\/](?:Users|home)[\\/][^\s'"`)\]]*/g;++/** Replace anything that looks like a path under a user's home folder, so results never carry a local path. */+export function removeLocalPaths(text) {+ return String(text).replace(LOCAL_PATH_PATTERN, '<local path>');+}++const sum = (records, field) => records.reduce((total, record) => total + (record[field] ?? 0), 0);++/** Success rate, tool calls, tool errors, tokens and cost for one group of records. */+export function totalsOf(records) {+ const passed = records.filter(record => record.pass).length;+ return {+ runs: records.length,+ passed,+ successRate: records.length ? Number((passed / records.length).toFixed(3)) : null,+ toolCalls: sum(records, 'toolCalls'),+ toolErrors: sum(records, 'toolErrors'),+ inputTokens: sum(records, 'inputTokens'),+ outputTokens: sum(records, 'outputTokens'),+ costUsd: Number(sum(records, 'costUsd').toFixed(2)),+ };+}++/** Totals for each model, then for each task within that model, so a task's spread over its runs stays visible. */+export function totalsByModel(records) {+ const models = [...new Set(records.map(record => record.model ?? 'unknown'))];+ return Object.fromEntries(models.map(model => {+ const own = records.filter(record => (record.model ?? 'unknown') === model);+ const tasks = [...new Set(own.map(record => record.task))];+ return [model, { ...totalsOf(own), tasks: Object.fromEntries(tasks.map(task => [task, totalsOf(own.filter(record => record.task === task))])) }];+ }));+}++function formatRow(model, totals) {+ const rate = totals.successRate === null ? '?' : `${Math.round(totals.successRate * 100)}%`;+ return `${model.padEnd(24)} ${String(totals.passed).padStart(3)}/${String(totals.runs).padEnd(3)} ${rate.padStart(5)} calls ${totals.toolCalls} errors ${totals.toolErrors} tokens ${totals.inputTokens} in / ${totals.outputTokens} out $${totals.costUsd}`;+}++if (process.argv[1] === fileURLToPath(import.meta.url)) {+ const records = [];+ for (const path of process.argv.slice(2)) records.push(...JSON.parse(await readFile(path, 'utf8')).records);+ for (const [model, totals] of Object.entries(totalsByModel(records))) {+ console.log(formatRow(model, totals));+ for (const [task, taskTotals] of Object.entries(totals.tasks)) console.log(` ${formatRow(task, taskTotals)}`);+ }+}diff --git a/bench/agent-modeling/check.mjs b/bench/agent-modeling/check.mjsindex 9f2bfa59..9e631046 100644--- a/bench/agent-modeling/check.mjs+++ b/bench/agent-modeling/check.mjs@@ -16,7 +16,7 @@ function checkOne(check, measures) {case 'lint':return { pass: measures.lintProblems === 0 && measures.closedParts === measures.parts, detail: measures.lintProblems ? measures.problemKinds.join(', ') : `${measures.closedParts}/${measures.parts} parts closed` };case 'parts':- return { pass: measures.parts <= check.max, detail: `${measures.parts} parts` };+ return { pass: measures.parts <= (check.max ?? Infinity) && measures.parts >= (check.min ?? 0), detail: `${measures.parts} parts` };case 'size': {const failures = [];check.expected.forEach((expected, axis) => {@@ -79,6 +79,15 @@ function checkOne(check, measures) {const onPath = close(solver.firstTarget, check.from) && close(solver.lastTarget, check.to);return { pass: onPath && solver.reached, detail: `targets ${JSON.stringify(solver.firstTarget)} to ${JSON.stringify(solver.lastTarget)}, reached ${solver.reached}, worst ${solver.worstError}` };}+ case 'shot': {+ const { camera } = measures;+ if (!camera) return { pass: false, detail: 'no camera in the recipe' };+ const offset = camera.eye.map((value, axis) => value - camera.target[axis]);+ const distance = Math.hypot(...offset);+ const sideOn = offset[0] >= check.minSideOffset && Math.abs(offset[2]) <= check.maxDepthOffset;+ const framed = camera.target[1] >= check.targetHeight[0] && camera.target[1] <= check.targetHeight[1] && distance >= check.distance[0] && distance <= check.distance[1];+ return { pass: sideOn && framed, detail: `eye offset ${offset.map(round).join(', ')}, target height ${round(camera.target[1])}` };+ }case 'tips':return { pass: measures.tips === check.equals, detail: `${measures.tips} tips` };case 'triangles':diff --git a/bench/agent-modeling/measure.mjs b/bench/agent-modeling/measure.mjsindex af190bed..56bdf9b8 100644--- a/bench/agent-modeling/measure.mjs+++ b/bench/agent-modeling/measure.mjs@@ -205,6 +205,7 @@ export async function measureAssetRecipe(recipe) {};return {clipName: recipe.animation ? asset.animations[recipe.animation.clip]?.name : null,+ camera: recipe.camera ?? null,reachSolvers: solvers.filter(solver => solver.type === 'two-bone').map(solver => {const [firstTarget, lastTarget] = endpoints(solver.target);const report = reports[solvers.indexOf(solver)];diff --git a/bench/agent-modeling/references.mjs b/bench/agent-modeling/references.mjsindex f92f3ac8..26b0e383 100644--- a/bench/agent-modeling/references.mjs+++ b/bench/agent-modeling/references.mjs@@ -103,7 +103,108 @@ function boltHoleEdits() {return edits;}+/** Resize the unit box to half extents by moving each tagged face, the way the crate and soap references do. */+function boxFaceEdits([halfX, halfY, halfZ]) {+ return [+ { op: 'translate', select: { tag: 'right' }, offset: [halfX - 0.5, 0, 0] },+ { op: 'translate', select: { tag: 'left' }, offset: [0.5 - halfX, 0, 0] },+ { op: 'translate', select: { tag: 'top' }, offset: [0, halfY - 0.5, 0] },+ { op: 'translate', select: { tag: 'bottom' }, offset: [0, 0.5 - halfY, 0] },+ { op: 'translate', select: { tag: 'front' }, offset: [0, 0, halfZ - 0.5] },+ { op: 'translate', select: { tag: 'back' }, offset: [0, 0, 0.5 - halfZ] },+ ];+}++function boxCut(name, center, size) {+ return { op: 'boolean', operation: 'difference', name, cutter: { type: 'box', bevel: 0 }, translation: center, scale: size };+}++function pocketEdits() {+ const edits = [];+ for (const x of [-0.055, 0, 0.055]) {+ for (const z of [-0.0275, 0.0275]) edits.push(boxCut(`pocket-${edits.length}`, [x, 0.015, z], [0.04, 0.02, 0.04]));+ }+ return edits;+}++function slotEdits() {+ return [-0.16, -0.08, 0, 0.08, 0.16].map((x, index) => boxCut(`slot-${index}`, [x, 0, 0], [0.05, 0.1, 0.02]));+}++const revisedCrateEdits = [+ ...crateEdits.map(edit => (edit.op === 'extrude_face_region' ? { ...edit, offset: 0.06 } : edit)),+ { op: 'boolean', operation: 'difference', name: 'drill', cutter: { type: 'cylinder', segments: 32, bevel: 0 }, translation: [0, 0.3, 0], scale: [0.03, 0.2, 0.03] },+];++function workshopNodes() {+ const legs = (prefix, centerZ, halfSpanX, halfSpanZ, size, height, centerY) => [[-1, -1], [-1, 1], [1, -1], [1, 1]].map(([signX, signZ], index) => ({+ id: `${prefix}-leg-${index}`, geometry: 'block', translation: [signX * halfSpanX, centerY, centerZ + signZ * halfSpanZ], scale: [size, height, size],+ }));+ return [+ { id: 'floor', geometry: 'block', translation: [0, 0.025, 0], scale: [3, 0.05, 3] },+ { id: 'table-top', geometry: 'block', translation: [0, 0.78, 0], scale: [1.2, 0.04, 0.6] },+ ...legs('table', 0, 0.525, 0.225, 0.05, 0.71, 0.405),+ { id: 'seat', geometry: 'block', translation: [0, 0.485, 0.8], scale: [0.4, 0.03, 0.4] },+ ...legs('chair', 0.8, 0.18, 0.18, 0.04, 0.42, 0.26),+ { id: 'mug', geometry: 'cup', translation: [0.3, 0.85, -0.05], scale: [0.04, 0.1, 0.04] },+ ];+}++function robotArmSolver(root, middle, end, target) {+ return { type: 'two-bone', root, middle, end, keepEndRotation: false, target };+}+export const REFERENCES = {+ 'chamfer-plate': scene(+ [{+ id: 'plate', type: 'mesh', base: { type: 'box', bevel: 0 }, edits: [+ ...boxFaceEdits([0.1, 0.015, 0.06]),+ { op: 'bevel', edges: { between: [{ tag: 'top' }, { tag: 'side' }] }, width: 0.005, segments: 1 },+ ...pocketEdits(),+ ],+ }],+ [{ id: 'plate', geometry: 'plate', translation: [0, 0.015, 0] }],+ ),+ 'slotted-rail': scene(+ [{+ id: 'rail', type: 'mesh', base: { type: 'box', bevel: 0 }, edits: [+ ...boxFaceEdits([0.2, 0.015, 0.03]),+ { op: 'bevel', edges: { all: true }, width: 0.004, segments: 1 },+ ...slotEdits(),+ ],+ }],+ [{ id: 'rail', geometry: 'rail', translation: [0, 0.015, 0] }],+ ),+ 'crate-revision': scene(+ [{ id: 'crate', type: 'mesh', base: { type: 'box', bevel: 0 }, edits: revisedCrateEdits }],+ [{ id: 'crate', geometry: 'crate', translation: [0, 0.3, 0] }],+ ),+ 'bracket-revision': scene(+ [+ { id: 'base', type: 'extrude', depth: 0.02, contour: rectangle(-0.15, -0.05, 0.15, 0.05), holes: [-0.05, 0.03, 0.11].map(x => circle(0.01, 32, x, 0, true)) },+ { id: 'block', type: 'box', bevel: 0 },+ ],+ [+ { id: 'base', geometry: 'base', rotation: axisRotation('x', -Math.PI / 2) },+ { id: 'upright', geometry: 'block', translation: [-0.14, 0.095, 0], scale: [0.02, 0.15, 0.1] },+ ],+ ),+ workshop: scene(+ [{ id: 'block', type: 'box', bevel: 0 }, { id: 'cup', type: 'cylinder', segments: 32, bevel: 0 }],+ workshopNodes(),+ ),+ 'robot-shot': {+ format: '67js.asset', schemaVersion: 1, assetId: 'ab'.repeat(32),+ animation: { clip: 2, time: 0 },+ camera: { target: [0, 2, 0], eye: [7, 2.5, 0.5], up: [0, 1, 0], fov: 45, near: 0.1, far: 100 },+ motion: {+ duration: 1, tracks: [],+ ik: [+ robotArmSolver('node-37', 'node-39', 'node-40', [-1.3, 2.6, 0.8]),+ robotArmSolver('node-17', 'node-19', 'node-20', [1.3, 2.4, 0.8]),+ ],+ },+ },'robot-reach': {format: '67js.asset', schemaVersion: 1, assetId: 'ab'.repeat(32),animation: { clip: 2, time: 0 },diff --git a/bench/agent-modeling/run.mjs b/bench/agent-modeling/run.mjsindex c5cfee39..a886679f 100644--- a/bench/agent-modeling/run.mjs+++ b/bench/agent-modeling/run.mjs@@ -2,9 +2,11 @@// server, then grades the recipe the agent exported.//// node bench/agent-modeling/run.mjs --claude <claude executable> [--model sonnet] [--tasks crate,bolt]-// [--budget 3] [--timeout 1200] [--label baseline] [--skill] [--resume <run name>]+// [--runs 3] [--budget 3] [--timeout 1200] [--label baseline] [--skill] [--resume <run name>]//-// --resume continues a run that stopped early and skips the tasks it already recorded.+// --runs repeats every task that many times, each in a fresh session; the summary reports success rate, tool calls,+// tool errors, tokens and cost for the model and for each task.+// --resume continues a run that stopped early and skips the task attempts it already recorded. Pass the same --runs.// --skill puts the build-67js-scene entry point and its mesh reference in the system prompt. That measures what the// skill's knowledge is worth, not whether an agent would load the skill on its own.//@@ -15,9 +17,10 @@ import { copyFile, mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promiimport { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import { parseArgs } from 'node:util';+import { removeLocalPaths, totalsByModel, totalsOf } from './aggregate.mjs';import { gradeRecipe, recipeFeatures } from './check.mjs';import { scoreLookSafely } from './look.mjs';-import { PROMPT_PREAMBLE, TASKS, taskById } from './tasks.mjs';+import { PROMPT_PREAMBLE, TASKS, taskById, taskPrompt } from './tasks.mjs';const repository = resolve(import.meta.dirname, '../..');const MCP_SERVER_NAME = '67js';@@ -29,6 +32,7 @@ const { values: options } = parseArgs({claude: { type: 'string', default: process.env.CLAUDE_EXECUTABLE ?? 'claude' },model: { type: 'string', default: 'sonnet' },tasks: { type: 'string' },+ runs: { type: 'string', default: '1' },budget: { type: 'string', default: '3' },timeout: { type: 'string', default: '1200' },label: { type: 'string', default: 'run' },@@ -143,7 +147,8 @@ async function removeWorkingDirectory(workingDirectory) {}}-async function runTask(task, systemPromptAddition) {+async function runTask(task, attempt, systemPromptAddition) {+ const fileStem = `${task.id}-${attempt}`;const workingDirectory = await mkdtemp(join(tmpdir(), '67js-agent-task-'));try {const configPath = join(workingDirectory, 'mcp.json');@@ -154,29 +159,30 @@ async function runTask(task, systemPromptAddition) {await copyFile(join(repository, 'tests', 'fixtures', 'RobotExpressive.glb'), join(assetDirectory, 'robot.glb'));}await writeFile(configPath, JSON.stringify(mcpConfig(assetDirectory)));- const taskPrompt = task.prompt.replace(/\n/g, ' ');- const prompt = task.ownPreamble ? taskPrompt : `${PROMPT_PREAMBLE}\n\n${taskPrompt}`;+ const text = taskPrompt(task);+ const prompt = task.ownPreamble ? text : `${PROMPT_PREAMBLE}\n\n${text}`;const run = await runClaude(prompt, workingDirectory, configPath, systemPromptAddition);const transcript = readTranscript(run.output);- await writeFile(join(rawDirectory, `${task.id}.jsonl`), run.output);- if (run.errors) await writeFile(join(rawDirectory, `${task.id}.stderr.txt`), run.errors);- if (transcript.recipe) await writeFile(join(rawDirectory, `${task.id}.recipe.json`), JSON.stringify(transcript.recipe, null, 2));+ await writeFile(join(rawDirectory, `${fileStem}.jsonl`), run.output);+ if (run.errors) await writeFile(join(rawDirectory, `${fileStem}.stderr.txt`), run.errors);+ if (transcript.recipe) await writeFile(join(rawDirectory, `${fileStem}.recipe.json`), JSON.stringify(transcript.recipe, null, 2));const grade = transcript.recipe? await gradeRecipe(task, transcript.recipe): { pass: false, passed: 0, total: task.checks.length, results: [{ kind: 'export', pass: false, detail: 'no exported recipe' }] };const usage = transcript.result?.usage ?? {};return {task: task.id,+ attempt,pass: grade.pass,passed: grade.passed,total: grade.total,- failed: grade.results.filter(result => !result.pass).map(result => `${result.label ?? result.kind}: ${result.detail}`),+ failed: grade.results.filter(result => !result.pass).map(result => removeLocalPaths(`${result.label ?? result.kind}: ${result.detail}`)),model: transcript.model,toolCalls: transcript.toolCalls,toolErrors: transcript.toolErrors,toolsByName: transcript.toolsByName,features: transcript.recipe ? recipeFeatures(transcript.recipe) : null,- look: transcript.recipe ? await scoreLookSafely(task.id, transcript.recipe, { imageDirectory: join(rawDirectory, 'look') }) : null,+ look: transcript.recipe ? await scoreLookSafely(task.id, transcript.recipe, { imageDirectory: join(rawDirectory, 'look', String(attempt)) }) : null,turns: transcript.result?.num_turns ?? null,costUsd: transcript.result?.total_cost_usd ?? null,inputTokens: (usage.input_tokens ?? 0) + (usage.cache_read_input_tokens ?? 0) + (usage.cache_creation_input_tokens ?? 0),@@ -196,7 +202,10 @@ await mkdir(resultsDirectory, { recursive: true });const systemPromptAddition = options.skill ? await skillPrompt() : null;const summaryPath = join(resultsDirectory, `${runName}.json`);const records = options.resume ? JSON.parse(await readFile(summaryPath, 'utf8')).records : [];-const recordedTasks = new Set(records.map(record => record.task));+const attempts = Number(options.runs);+if (!Number.isInteger(attempts) || attempts < 1) throw new RangeError('--runs must be a whole number from 1');+// Records from before --runs existed have no attempt number: they are the first attempt.+const recordedAttempts = new Set(records.map(record => `${record.task}#${record.attempt ?? 1}`));function summarize() {return {@@ -204,20 +213,29 @@ function summarize() {model: records.find(record => record.model)?.model ?? options.model,date: new Date().toISOString(),skill: options.skill,+ runsPerTask: attempts,passed: records.filter(record => record.pass).length,tasks: records.length,toolCalls: records.reduce((sum, record) => sum + record.toolCalls, 0),costUsd: Number(records.reduce((sum, record) => sum + (record.costUsd ?? 0), 0).toFixed(2)),+ byModel: totalsByModel(records),records,};}-for (const task of tasks.filter(candidate => !recordedTasks.has(candidate.id))) {- const record = await runTask(task, systemPromptAddition);+const pending = [];+for (let attempt = 1; attempt <= attempts; attempt++) {+ for (const task of tasks) {+ if (!recordedAttempts.has(`${task.id}#${attempt}`)) pending.push({ task, attempt });+ }+}++for (const { task, attempt } of pending) {+ const record = await runTask(task, attempt, systemPromptAddition);records.push(record);- console.log(`${record.task.padEnd(9)} ${record.pass ? 'PASS' : 'FAIL'} ${record.passed}/${record.total} calls ${record.toolCalls} (errors ${record.toolErrors}) $${record.costUsd ?? '?'} ${record.wallSeconds}s${record.failed.length ? ` ${record.failed.join(' | ')}` : ''}`);+ console.log(`${record.task.padEnd(16)} #${attempt} ${record.pass ? 'PASS' : 'FAIL'} ${record.passed}/${record.total} calls ${record.toolCalls} (errors ${record.toolErrors}) $${record.costUsd ?? '?'} ${record.wallSeconds}s${record.failed.length ? ` ${record.failed.join(' | ')}` : ''}`);// Saved after every task, so a run that gets killed keeps what it already paid for.await writeFile(summaryPath, `${JSON.stringify(summarize(), null, 2)}\n`);}const summary = summarize();-console.log(`${summary.passed}/${summary.tasks} passed, ${summary.toolCalls} tool calls, $${summary.costUsd}. Summary: bench/agent-modeling/results/${runName}.json`);+console.log(`${summary.passed}/${summary.tasks} passed (${Math.round(totalsOf(records).successRate * 100)}%), ${summary.toolCalls} tool calls, $${summary.costUsd}. Summary: bench/agent-modeling/results/${runName}.json`);diff --git a/bench/agent-modeling/tasks.mjs b/bench/agent-modeling/tasks.mjsindex 83862405..5745a925 100644--- a/bench/agent-modeling/tasks.mjs+++ b/bench/agent-modeling/tasks.mjs@@ -1,6 +1,8 @@// The agent modeling tasks. Each prompt gives sizes in metres, so every check is objective. Checks run on the recipe// the agent exports (see measure.mjs and check.mjs); none of them looks at how the object was built.+import { REFERENCES } from './references.mjs';+export const PROMPT_PREAMBLE = `You are modeling with the 67.js MCP tools. Build the object described below as a procedural recipe scene:start it with scene_create, refine it with mesh_edit, mesh_stack and scene_apply, and look at it with scene_look whenthat helps. Units are metres and Y is up. Rest the object on the ground (lowest point at Y = 0), centred on X = 0 and@@ -18,6 +20,142 @@ const crateChecks = [{ kind: 'section', axis: 'y', at: 0.615, equals: 1, label: 'raised lid' },];+// The long tasks need sub-element edits, several steps or a whole scene. Two of them start from a recipe given in the+// prompt, which the agent has to change instead of rebuilding from nothing.+const START_INSTRUCTION = 'Start by calling scene_create with exactly this recipe, then change that scene (do not start over):';+const compactRecipe = recipe => JSON.stringify(recipe);++const LONG_TASKS = [+ {+ id: 'chamfer-plate',+ prompt: `A hard-surface plate lying on the ground, one solid piece: 0.2 m long (X), 0.03 m thick (Y) and 0.12 m deep+(Z). The four edges around its top face are chamfered 0.005 m. The top face carries six rectangular pockets sunk 0.01 m,+each 0.04 m by 0.04 m, in three columns along X (centres at X = -0.055, 0 and 0.055) and two rows along Z (centres at+Z = -0.0275 and 0.0275). The pockets leave a solid rim around the plate and walls between them.`,+ checks: [+ { kind: 'lint' },+ { kind: 'parts', max: 1 },+ { kind: 'size', expected: [0.2, 0.03, 0.12] },+ { kind: 'ground' },+ { kind: 'holes', equals: 0 },+ { kind: 'volume', min: 5.9e-4, max: 6.4e-4 },+ { kind: 'section', axis: 'y', at: 0.025, equals: 7, label: 'plate outline and six pockets' },+ { kind: 'section', axis: 'y', at: 0.005, equals: 1, label: 'pockets are blind' },+ {+ kind: 'through', axis: 'z', label: 'chamfered top edge',+ open: [[0.0995, 0.0295], [-0.0995, 0.0295]],+ solid: [[0.0995, 0.0155], [0, 0.0295]],+ },+ ],+ },+ {+ id: 'slotted-rail',+ prompt: `A slotted rail lying on the ground, one solid piece: a bar 0.4 m long (X), 0.03 m tall (Y) and 0.06 m deep (Z),+with every outer edge chamfered 0.004 m. Five rectangular slots go straight down through it, each 0.05 m along X and+0.02 m along Z, centred in Z, at X = -0.16, -0.08, 0, 0.08 and 0.16.`,+ checks: [+ { kind: 'lint' },+ { kind: 'parts', max: 1 },+ { kind: 'size', expected: [0.4, 0.03, 0.06] },+ { kind: 'ground' },+ { kind: 'holes', equals: 5 },+ { kind: 'volume', min: 5.0e-4, max: 5.7e-4 },+ { kind: 'section', axis: 'y', at: 0.015, equals: 6, label: 'bar outline and five slots' },+ {+ kind: 'through', axis: 'y', label: 'slots open, bars between them solid',+ open: [[-0.16, 0], [-0.08, 0], [0, 0], [0.08, 0], [0.16, 0]],+ solid: [[-0.12, 0], [-0.04, 0], [0.04, 0], [0.12, 0], [0, 0.025]],+ },+ {+ kind: 'through', axis: 'z', label: 'chamfered end edges',+ open: [[0.1995, 0.0295], [-0.1995, 0.0005]],+ solid: [[0.1995, 0.015], [0, 0.0295]],+ },+ ],+ },+ {+ id: 'crate-revision',+ startRecipe: REFERENCES.crate,+ prompt: `A wooden crate scene is already designed as the recipe below: a 0.6 m cube with recessed side panels and a raised+lid 0.03 m tall. Make two changes. Raise the lid to 0.06 m tall. Then drill a round blind hole of 0.06 m diameter straight+down from the top of the lid, centred on the crate, ending 0.5 m above the ground. Keep everything else as it is.`,+ checks: [+ { kind: 'lint' },+ { kind: 'parts', max: 1 },+ { kind: 'size', expected: [0.6, 0.66, 0.6] },+ { kind: 'ground' },+ { kind: 'holes', equals: 0 },+ { kind: 'volume', min: 0.2, max: 0.218 },+ { kind: 'section', axis: 'y', at: 0.645, equals: 2, label: 'raised lid with the hole' },+ { kind: 'section', axis: 'y', at: 0.55, equals: 2, label: 'body with the hole' },+ { kind: 'section', axis: 'y', at: 0.45, equals: 1, label: 'hole stops at 0.5 m' },+ { kind: 'section', axis: 'x', at: 0.29, equals: 2, label: 'recessed panel on +X kept' },+ ],+ },+ {+ id: 'bracket-revision',+ startRecipe: REFERENCES.bracket,+ prompt: `An L bracket is already designed as the recipe below. Change it: lengthen the base plate to 0.3 m along X and+keep the whole bracket centred on X = 0, with the upright still flush with the base's -X end, the same height and the same+thickness. Replace the two holes by three round holes, 0.02 m in diameter, going straight down through the base at X = -0.05,+0.03 and 0.11, centred in Z. The bracket is 0.17 m tall overall, as before.`,+ checks: [+ { kind: 'lint' },+ { kind: 'size', expected: [0.3, 0.17, 0.1] },+ { kind: 'ground' },+ { kind: 'holes', equals: 3 },+ { kind: 'volume', min: 8.2e-4, max: 9.4e-4 },+ { kind: 'section', axis: 'y', at: 0.01, equals: 4, label: 'base with three holes' },+ {+ kind: 'through', axis: 'y', label: 'holes at the new positions',+ open: [[-0.05, 0], [0.03, 0], [0.11, 0]],+ solid: [[0.06, 0], [0.14, 0], [-0.1, 0]],+ },+ ],+ },+ {+ id: 'workshop',+ prompt: `A small workshop scene on a square floor slab 3 m by 3 m and 0.05 m thick, with its top face 0.05 m above the+ground (Y = 0). The scene is centred on X = 0 and Z = 0. On the slab stand a table and a chair, plus a mug. The table top is 1.2 m+long (X), 0.6 m deep (Z) and 0.04 m thick, with its upper surface 0.75 m above the slab; four square legs, 0.05 m on a+side, run from the slab to the underside of the top, their outer faces 0.05 m in from the top's edges. The table is centred+on the slab. The chair sits 0.8 m toward +Z from the table's centre: its seat is 0.4 m square and 0.03 m thick, with the+upper surface 0.45 m above the slab, on four square legs 0.04 m on a side in the seat's corners, flush with its edges+and stopping at the underside of the seat. The mug is a closed solid cylinder 0.08 m in diameter and 0.1 m tall, standing+on the table top at X = 0.3, Z = -0.05. Every object rests on what is below it, and the objects do not overlap.`,+ checks: [+ { kind: 'lint' },+ { kind: 'parts', min: 12 },+ { kind: 'size', expected: [3, 0.9, 3] },+ { kind: 'ground' },+ { kind: 'section', axis: 'y', at: 0.02, equals: 1, label: 'floor slab' },+ { kind: 'section', axis: 'y', at: 0.3, equals: 8, label: 'four table legs and four chair legs' },+ { kind: 'section', axis: 'y', at: 0.49, equals: 5, label: 'chair seat and four table legs' },+ { kind: 'section', axis: 'y', at: 0.78, equals: 1, label: 'table top' },+ { kind: 'section', axis: 'y', at: 0.85, equals: 1, label: 'mug on the table' },+ { kind: 'volume', min: 0.47, max: 0.52 },+ ],+ },+ {+ id: 'robot-shot',+ assets: true,+ prompt: `The asset catalog holds an imported robot character. Create a scene from it with its Idle clip selected at+time 0, and make a still shot of it with both hands raised. Add IK so that the palm joint of the right arm (Palm2.R) is at+world position [-1.3, 2.6, 0.8] and the palm joint of the left arm (Palm2.L) is at [1.3, 2.4, 0.8], with the rest of the+body on the clip. Then set the camera for a side-on shot: from the +X side of the robot, looking at it, with the eye 3 to+12 m from the look-at target, at most 2 m off the robot's front-to-back axis (Z), and the look-at target between 0.5 m+and 4 m above the ground. Look at the result with scene_look to confirm both hands are in the picture. When it is+finished, call scene_export_recipe once: the exported recipe is what gets graded.`,+ ownPreamble: true,+ checks: [+ { kind: 'assetClip', name: 'Idle' },+ { kind: 'assetReach', endLabel: 'Palm2.R', from: [-1.3, 2.6, 0.8], to: [-1.3, 2.6, 0.8] },+ { kind: 'assetReach', endLabel: 'Palm2.L', from: [1.3, 2.4, 0.8], to: [1.3, 2.4, 0.8] },+ { kind: 'shot', minSideOffset: 2, maxDepthOffset: 2, targetHeight: [0.5, 4], distance: [3, 12] },+ ],+ },+];+export const TASKS = [{id: 'crate',@@ -245,8 +383,15 @@ recipe is what gets graded.`,{ kind: 'assetReach', endLabel: 'Palm2.R', from: [-1.3, 2.6, 0.8], to: [-1, 1.7, 1.1] },],},+ ...LONG_TASKS,];+/** The task text an agent receives, with the starting recipe appended when the task changes an existing scene. */+export function taskPrompt(task) {+ const text = task.prompt.replace(/\n/g, ' ');+ return task.startRecipe ? `${text} ${START_INSTRUCTION} ${compactRecipe(task.startRecipe)}` : text;+}+export function taskById(id) {const task = TASKS.find(candidate => candidate.id === id);if (!task) throw new RangeError(`Unknown task ${id}. Tasks: ${TASKS.map(candidate => candidate.id).join(', ')}.`);diff --git a/tests/agent-look-score.test.js b/tests/agent-look-score.test.jsindex 48d662da..ea5975b8 100644--- a/tests/agent-look-score.test.js+++ b/tests/agent-look-score.test.js@@ -40,7 +40,7 @@ test('intersection over union is 1 for equal masks, 0 for disjoint masks and a ftest('every scene reference scores 1 against itself', async () => {for (const task of TASKS) {const silhouette = await scoreSilhouette(task.id, REFERENCES[task.id]);- if (task.id === 'robot-reach') {+ if (task.assets) {assert.equal(silhouette, null);} else {assert.equal(silhouette.mean, 1, task.id);diff --git a/tests/agent-modeling-suite.test.js b/tests/agent-modeling-suite.test.jsindex b4b4a3ae..d718d272 100644--- a/tests/agent-modeling-suite.test.js+++ b/tests/agent-modeling-suite.test.js@@ -1,7 +1,7 @@import assert from 'node:assert/strict';import test from 'node:test';import { gradeRecipe } from '../bench/agent-modeling/check.mjs';-import { TASKS, taskById } from '../bench/agent-modeling/tasks.mjs';+import { TASKS, taskById, taskPrompt } from '../bench/agent-modeling/tasks.mjs';import { REFERENCES } from '../bench/agent-modeling/references.mjs';const failedKinds = grade => grade.results.filter(result => !result.pass).map(result => result.label ?? result.kind);@@ -36,6 +36,70 @@ test('checks reject objects that miss the asked-for features', async () => {assert.ok(failedKinds(await gradeRecipe(taskById('gear'), elevenTeeth)).includes('tips'));});+function movedAlong(node, axis, amount) {+ const translation = [...node.translation];+ translation[axis] += amount;+ return { ...node, translation };+}++test('long tasks reject plausible wrong variants', async () => {+ const smoothPlate = structuredClone(REFERENCES['chamfer-plate']);+ smoothPlate.geometries[0].edits = smoothPlate.geometries[0].edits.filter(edit => edit.op !== 'bevel');+ assert.deepEqual(failedKinds(await gradeRecipe(taskById('chamfer-plate'), smoothPlate)), ['chamfered top edge']);++ const fivePockets = structuredClone(REFERENCES['chamfer-plate']);+ fivePockets.geometries[0].edits.pop();+ assert.ok(failedKinds(await gradeRecipe(taskById('chamfer-plate'), fivePockets)).includes('plate outline and six pockets'));++ const squareRail = structuredClone(REFERENCES['slotted-rail']);+ squareRail.geometries[0].edits = squareRail.geometries[0].edits.filter(edit => edit.op !== 'bevel');+ assert.deepEqual(failedKinds(await gradeRecipe(taskById('slotted-rail'), squareRail)), ['chamfered end edges']);++ const fourSlots = structuredClone(REFERENCES['slotted-rail']);+ fourSlots.geometries[0].edits.pop();+ const fourSlotFailures = failedKinds(await gradeRecipe(taskById('slotted-rail'), fourSlots));+ assert.ok(fourSlotFailures.includes('holes') && fourSlotFailures.includes('bar outline and five slots'));++ const unchangedCrate = failedKinds(await gradeRecipe(taskById('crate-revision'), REFERENCES.crate));+ assert.ok(unchangedCrate.includes('size') && unchangedCrate.includes('raised lid with the hole'));++ const throughHoleCrate = structuredClone(REFERENCES['crate-revision']);+ throughHoleCrate.geometries[0].edits.at(-1).scale = [0.03, 0.6, 0.03];+ assert.ok(failedKinds(await gradeRecipe(taskById('crate-revision'), throughHoleCrate)).includes('hole stops at 0.5 m'));++ const oldBracket = failedKinds(await gradeRecipe(taskById('bracket-revision'), REFERENCES.bracket));+ assert.ok(oldBracket.includes('size') && oldBracket.includes('holes'));++ const lopsidedWorkshop = structuredClone(REFERENCES.workshop);+ lopsidedWorkshop.nodes = lopsidedWorkshop.nodes.filter(node => node.id !== 'chair-leg-3').map(node => (node.id === 'mug' ? movedAlong(node, 1, 0.2) : node));+ const workshopFailures = failedKinds(await gradeRecipe(taskById('workshop'), lopsidedWorkshop));+ assert.ok(workshopFailures.includes('four table legs and four chair legs') && workshopFailures.includes('mug on the table'));+});++test('the robot shot needs both hands on target and a side-on camera', async () => {+ const task = taskById('robot-shot');+ const oneHand = structuredClone(REFERENCES['robot-shot']);+ oneHand.motion.ik.pop();+ assert.deepEqual(failedKinds(await gradeRecipe(task, oneHand)), ['assetReach']);++ const defaultFraming = structuredClone(REFERENCES['robot-shot']);+ defaultFraming.camera.eye = [4, 5, 6];+ assert.deepEqual(failedKinds(await gradeRecipe(task, defaultFraming)), ['shot']);++ const noCamera = structuredClone(REFERENCES['robot-shot']);+ delete noCamera.camera;+ assert.deepEqual(failedKinds(await gradeRecipe(task, noCamera)), ['shot']);+});++test('tasks that change an existing scene carry their starting recipe in the prompt', () => {+ for (const id of ['crate-revision', 'bracket-revision']) {+ const task = taskById(id);+ assert.ok(taskPrompt(task).includes(JSON.stringify(task.startRecipe)), id);+ assert.doesNotMatch(taskPrompt(task), /\n/);+ }+ assert.equal(taskPrompt(taskById('bolt')).includes('scene_create with exactly'), false);+});+test('an invalid recipe fails every check with the reason', async () => {const grade = await gradeRecipe(taskById('bolt'), { format: '67js.scene', schemaVersion: 1, geometries: [], materials: [], nodes: [{ id: 'x', geometry: 'missing' }] });assert.equal(grade.passed, 0);diff --git a/tests/agent-suite-aggregate.test.js b/tests/agent-suite-aggregate.test.jsnew file mode 100644index 00000000..7a38f290--- /dev/null+++ b/tests/agent-suite-aggregate.test.js@@ -0,0 +1,36 @@+import assert from 'node:assert/strict';+import { readdir, readFile } from 'node:fs/promises';+import test from 'node:test';+import { removeLocalPaths, totalsByModel, totalsOf } from '../bench/agent-modeling/aggregate.mjs';++const record = (task, model, pass, extra = {}) => ({ task, model, pass, toolCalls: 3, toolErrors: 1, inputTokens: 100, outputTokens: 10, costUsd: 0.25, ...extra });++test('totals count success rate, calls, errors, tokens and cost for each model and task', () => {+ const records = [+ record('crate', 'sonnet', true), record('crate', 'sonnet', false), record('bolt', 'sonnet', true),+ record('crate', 'haiku', false, { costUsd: 0.05 }),+ ];+ const byModel = totalsByModel(records);+ assert.deepEqual(Object.keys(byModel), ['sonnet', 'haiku']);+ assert.equal(byModel.sonnet.runs, 3);+ assert.equal(byModel.sonnet.successRate, 0.667);+ assert.equal(byModel.sonnet.toolCalls, 9);+ assert.equal(byModel.sonnet.costUsd, 0.75);+ assert.equal(byModel.sonnet.tasks.crate.passed, 1);+ assert.equal(byModel.haiku.successRate, 0);+ assert.equal(totalsOf([]).successRate, null);+});++test('local paths are removed from recorded text', () => {+ assert.equal(removeLocalPaths('imported from C:\\Users\\someone\\code\\src\\file.js (x)'), 'imported from <local path> (x)');+ assert.equal(removeLocalPaths('see /home/someone/code/file.js'), 'see <local path>');+ assert.equal(removeLocalPaths('no path here'), 'no path here');+});++test('no recorded result holds a local path', async () => {+ const directory = new URL('../bench/agent-modeling/results/', import.meta.url);+ for (const name of await readdir(directory)) {+ const text = await readFile(new URL(name, directory), 'utf8');+ assert.equal(removeLocalPaths(text), text, `${name} holds a local path`);+ }+});