Skip to content

armgit / forma

Public Imported from GitHub
0

A 1.2 MB pure-Rust rewrite of headless Blender built for AI agents — 3D B-rep modeling engine, CLI, and MCP server

bench: add complex A/B/C benchmark harness, results, and suite docs

wrong-nebula3f72623dcdd6
diff --git a/bench/README.md b/bench/README.md
new file mode 100644
index 0000000..fe3a373
--- /dev/null
+++ b/bench/README.md
@@ -0,0 +1,27 @@
+# Forma Benchmarks & Verification Suite
+
+Independent geometric verification, LLM benchmark harnesses, and archived evaluation logs for Forma.
+
+## Requirements
+
+- Python 3.10+ with `trimesh`, `scipy`, `numpy`, `tiktoken` (and `matplotlib` for chart generation).
+- Compiled Forma binaries (`cargo build --release`).
+- Optional: local Blender executable for `bpy` comparison / `.blend` import checks. Set `BLENDER_BIN=/path/to/blender` if `blender` is not on `PATH`.
+- Optional: `OPENROUTER_API_KEY` for running LLM evaluation matrices (`eval_baseline.py`, `eval_ablation.py`, `eval_matrix.py`).
+
+## Key Scripts
+
+| Script | Purpose |
+|---|---|
+| `verify.py` | Independent mesh verifier (`trimesh` + `scipy` Chamfer, Hausdorff-99, Generalized Winding Number IoU, watertight/non-manifold checks, 16-layer slicing, Blender import check). |
+| `tasks.py` | Canonical 12-task exact-dimension benchmark definitions and Blender reference generators (`ref_meshes/*.glb`). |
+| `gate_verify.py` | End-to-end automated verification gate across all 12 canonical geometries, MCP token budget, binary footprint, and fuzz suite. |
+| `verify_tier1_parity.py` | Parity checks for deformers, curves, LSCM UV packing, QEM decimation, and Surface Nets remeshing against Blender. |
+| `eval_baseline.py` / `eval_ablation.py` / `eval_matrix.py` | Multi-model LLM evaluation harnesses (`bpy` vs `Forma-Pipe` / `Forma-DSL`). |
+
+Run scripts directly from the repository root (e.g. `python3 bench/gate_verify.py`).
+
+## Archived Optimization Scripts & Results
+
+- `results/` stores the raw JSON/JSONL trial logs referenced by [`docs/EXTENDED_BENCHMARK_REPORT.md`](../docs/EXTENDED_BENCHMARK_REPORT.md) and the archived reports in `docs/`.
+- `colab_autoresearch.py`, `colab_autoresearch_w2.py`, `colab_autoresearch_w3.py`, and [`notebooks/forma_autoresearch_colab.ipynb`](../notebooks/forma_autoresearch_colab.ipynb) are **historical optimization scripts** written against earlier intermediate commits (their embedded source patches have already been integrated into `crates/forma-core` and are not intended to be re-applied on `main`).
diff --git a/bench/eval_baseline.py b/bench/eval_baseline.py
index afa2057..e15f6a9 100644
--- a/bench/eval_baseline.py
+++ b/bench/eval_baseline.py
@@ -87,7 +87,7 @@ def call_openrouter(
headers={
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
- "HTTP-Referer": "https://github.com/forma-3d-bench",
+ "HTTP-Referer": "https://github.com/wrong-nebula/forma",
"X-Title": "forma-3d-bench",
},
method="POST",
diff --git a/bench/eval_complex_abc.py b/bench/eval_complex_abc.py
new file mode 100644
index 0000000..7a1e395
--- /dev/null
+++ b/bench/eval_complex_abc.py
@@ -0,0 +1,1024 @@
+#!/usr/bin/env python3
+"""3-Way Complex Model A/B/C Benchmark:
+ Arm A: Forma (CLI / MCP — Forma-Pipe pure-Rust engine)
+ Arm B: Blender CLI / MCP (Stock headless Blender 5.3 bpy/bmesh)
+ Arm C: Blender via Computer Use (Live Blender 5.3 Workbench viewport screenshots + GUI action loop)
+
+All 3 arms are graded identically by the independent trimesh/scipy verifier
+(watertight, 0 non-manifold edges, 16-layer planar sliceability, Chamfer, H99, Volumetric IoU).
+
+Usage:
+ OPENROUTER_API_KEY=... python3 bench/eval_complex_abc.py refs # Build & verify 5 complex ref meshes
+ OPENROUTER_API_KEY=... python3 bench/eval_complex_abc.py run_ab # Run Arm A (Forma) & Arm B (Blender CLI/MCP)
+ OPENROUTER_API_KEY=... python3 bench/eval_complex_abc.py run_cua # Run Arm C (Blender Computer Use)
+ python3 bench/eval_complex_abc.py report # Print full A/B/C comparison tables
+"""
+from __future__ import annotations
+
+import base64
+import concurrent.futures
+import json
+import os
+import re
+import statistics
+import subprocess
+import sys
+import tempfile
+import threading
+import time
+import urllib.error
+import urllib.request
+from dataclasses import asdict, dataclass
+from pathlib import Path
+from typing import Any, Dict, List, Optional, Tuple
+
+import tiktoken
+
+BENCH_DIR = Path(__file__).resolve().parent
+ROOT_DIR = BENCH_DIR.parent
+FORMA_BIN = ROOT_DIR / "target" / "release" / "forma"
+BLENDER_BIN = os.environ.get(
+ "BLENDER_BIN", "/Applications/Blender.app/Contents/MacOS/Blender"
+)
+REF_DIR = BENCH_DIR / "ref_complex"
+OUT_DIR = BENCH_DIR / "results" / "complex_abc"
+CKPT_FILE = OUT_DIR / "trials.jsonl"
+
+sys.path.insert(0, str(BENCH_DIR))
+from verify import VerifyResult, verify_mesh
+
+BLENDER_LOCK = threading.Lock()
+WRITE_LOCK = threading.Lock()
+ENC = tiktoken.get_encoding("o200k_base")
+
+
+def count_toks(s: str) -> int:
+ return len(ENC.encode(s or ""))
+
+
+@dataclass
+class ComplexTask:
+ id: str
+ title: str
+ complexity_tags: List[str]
+ prompt: str
+ ref_forma: str
+ expected_bbox: Tuple[float, float, float]
+ iou_threshold: float = 0.85
+
+
+COMPLEX_TASKS: List[ComplexTask] = [
+ ComplexTask(
+ id="hydraulic_manifold",
+ title="Hydraulic Valve Manifold (8 intersecting/batch bores + beveled corners)",
+ complexity_tags=["bevel", "cross-bore", "8-boolean", "manifold"],
+ expected_bbox=(4.0, 2.4, 1.6),
+ prompt=(
+ "Model a watertight hydraulic valve manifold block in right-handed Z-up meters:\n"
+ "- Outer block: 4.0 m (X) x 2.4 m (Y) x 1.6 m (Z), centered in X/Y, resting on Z=0 (Z from 0.0 to 1.6).\n"
+ "- Bevel all 4 vertical outer corners with width 0.25 m (3 segments).\n"
+ "- Cut 1 horizontal through-bore along the X-axis: radius 0.35 m, centered at Y=0, Z=0.80, passing completely through X.\n"
+ "- Cut 3 vertical through-bores along the Z-axis: radius 0.28 m each, at (X=-1.1, Y=0), (X=0.0, Y=0), and (X=+1.1, Y=0), passing completely through Z.\n"
+ "- Cut 4 vertical corner mounting through-holes: radius 0.16 m each, at (X=±1.55, Y=±0.80), passing completely through Z.\n"
+ "- Final mesh must be a single watertight manifold solid."
+ ),
+ ref_forma="""manifold = box(4.0, 2.4, 1.6, z0=0)
+ | bevel(vertical, 0.25, segs=3)
+ | cut(cyl(0.35, 5.0, axis=x), at=(0, 0, 0.80))
+ | cut(cyl(0.28, 2.4), at=[(-1.1, 0, 0.80), (0.0, 0, 0.80), (1.1, 0, 0.80)])
+ | cut(cyl(0.16, 2.4), at=[(-1.55, -0.80, 0.80), (-1.55, 0.80, 0.80), (1.55, -0.80, 0.80), (1.55, 0.80, 0.80)])
+ | mat("machined_steel", color=(0.60, 0.66, 0.74), metallic=0.9, roughness=0.28)
+""",
+ ),
+ ComplexTask(
+ id="flanged_reducer",
+ title="Dual-Flange Concentric Pipe Reducer (tapered bore + 8 rotated bolt holes)",
+ complexity_tags=["cone-frustum", "dual-flange", "8-bolt-circle", "through-bore"],
+ expected_bbox=(2.8, 2.8, 2.0),
+ prompt=(
+ "Model a watertight dual-flange concentric pipe reducer in right-handed Z-up meters (centered at X=0, Y=0, resting on Z=0, total height 2.0 m):\n"
+ "- Bottom circular flange: radius 1.40 m, height 0.20 m (Z from 0.00 to 0.20), with 4 vertical bolt through-holes of radius 0.12 m on a 1.12 m bolt-circle at angles 0, 90, 180, 270 deg: (±1.12, 0) and (0, ±1.12).\n"
+ "- Central tapered outer body: frustum (cone) from Z=0.18 to Z=1.82 with bottom radius 0.90 m and top radius 0.58 m.\n"
+ "- Top circular flange: radius 0.95 m, height 0.20 m (Z from 1.80 to 2.00), with 4 vertical bolt through-holes of radius 0.10 m on a 0.76 m bolt-circle at angles 45, 135, 225, 315 deg: (±0.5374, ±0.5374).\n"
+ "- Continuous central hollow through-passage from Z=0 to Z=2.0: tapered conical inner bore (bottom radius 0.72 m at Z=0.0, top radius 0.42 m at Z=2.0) cleanly piercing both flanges and the central cone.\n"
+ "- Final mesh must be a single watertight manifold solid."
+ ),
+ ref_forma="""bot_flange = cyl(1.40, 0.20, segs=48, z0=0.0)
+body_cone = cone(0.90, 0.58, 1.64, segs=48, z0=0.18)
+top_flange = cyl(0.95, 0.20, segs=48, z0=1.80)
+inner_bore = cone(0.75, 0.40, 2.40, segs=48, z0=-0.20)
+reducer = bot_flange
+ | add(body_cone)
+ | add(top_flange)
+ | cut(inner_bore)
+ | cut(cyl(0.12, 0.60, segs=24), at=[(1.12, 0, 0.10), (-1.12, 0, 0.10), (0, 1.12, 0.10), (0, -1.12, 0.10)])
+ | cut(cyl(0.10, 0.60, segs=24), at=[(0.5374, 0.5374, 1.90), (-0.5374, 0.5374, 1.90), (-0.5374, -0.5374, 1.90), (0.5374, -0.5374, 1.90)])
+ | mat("cast_bronze", color=(0.76, 0.52, 0.30), metallic=0.88, roughness=0.32)
+""",
+ ),
+ ComplexTask(
+ id="sensor_housing",
+ title="Rugged Sensor Enclosure (beveled shell + 4 drilled standoffs + side port)",
+ complexity_tags=["bevel", "shell", "4-bosses", "4-bores", "side-port"],
+ expected_bbox=(4.4, 3.0, 1.6),
+ prompt=(
+ "Model a watertight open-top rugged electronics enclosure in right-handed Z-up meters (centered in X/Y, resting on Z=0):\n"
+ "- Outer body: 4.4 m (X) x 3.0 m (Y) x 1.6 m (Z) resting at Z=0, with all 4 vertical outer corners beveled by width 0.30 m (3 segments).\n"
+ "- Hollow the body from the top with uniform wall and floor thickness 0.18 m (open top at Z=1.6).\n"
+ "- Add 4 internal cylindrical mounting standoffs rising from the inside floor (Z=0.16 to Z=0.96, height 0.80 m, radius 0.24 m) at (X=±1.60, Y=±0.90).\n"
+ "- Drill a blind circular screw pilot bore (radius 0.10 m, from Z=0.35 up through Z=1.10) into the top center of each of the 4 standoffs.\n"
+ "- Cut 1 circular side cable-gland through-hole along the X-axis (radius 0.32 m, centered at Y=0.0, Z=0.85) cleanly through the -X side wall only (X from -2.6 to -1.7).\n"
+ "- Final mesh must be a single watertight manifold solid."
+ ),
+ ref_forma="""housing = box(4.4, 3.0, 1.6, z0=0)
+ | bevel(vertical, 0.30, segs=3)
+ | shell(0.18, open_top=true)
+ | add(cyl(0.24, 0.80, segs=24), at=[(-1.60, -0.90, 0.56), (-1.60, 0.90, 0.56), (1.60, -0.90, 0.56), (1.60, 0.90, 0.56)])
+ | cut(cyl(0.10, 0.75, segs=20), at=[(-1.60, -0.90, 0.725), (-1.60, 0.90, 0.725), (1.60, -0.90, 0.725), (1.60, 0.90, 0.725)])
+ | cut(cyl(0.32, 0.90, segs=28, axis=x), at=(-2.15, 0.0, 0.85))
+ | mat("anodized_teal", color=(0.18, 0.56, 0.60), metallic=0.72, roughness=0.34)
+""",
+ ),
+ ComplexTask(
+ id="threaded_bolt",
+ title="Machined Helical Hex Bolt (hex head + flange collar + shank + 6-turn thread)",
+ complexity_tags=["hex-prism", "collar", "helical-thread", "multi-part-union"],
+ expected_bbox=(1.84, 1.84, 2.06),
+ prompt=(
+ "Model a watertight machined hex-head bolt with bearing collar and helical screw thread in right-handed Z-up meters (centered at X=0, Y=0, resting on Z=0):\n"
+ "- Hexagonal head: 6-sided cylinder (radius 0.80 m, vertices at k*60 deg), height 0.45 m (Z from 0.00 to 0.45).\n"
+ "- Circular flange bearing collar: radius 0.92 m, height 0.12 m (Z from 0.43 to 0.55, overlapping head slightly for manifold union).\n"
+ "- Smooth cylindrical shank: radius 0.40 m, height 0.60 m (Z from 0.53 to 1.13).\n"
+ "- Helical screw thread on top of the shank: minor radius 0.32 m, major radius 0.42 m, pitch 0.16 m, 6 full turns (total thread height 0.96 m), starting at Z=1.10 up to Z=2.06.\n"
+ "- Final mesh must be a single watertight manifold solid."
+ ),
+ ref_forma="""head = cyl(0.80, 0.45, segs=6, z0=0.0)
+collar = cyl(0.92, 0.12, segs=48, z0=0.43)
+shank = cyl(0.40, 0.60, segs=36, z0=0.53)
+th = thread(0.32, 0.42, 0.16, 6) | align_z0(1.10)
+bolt = head | add(collar) | add(shank) | add(th)
+ | mat("titanium", color=(0.74, 0.78, 0.84), metallic=0.92, roughness=0.22)
+""",
+ ),
+ ComplexTask(
+ id="arch_viaduct",
+ title="3-Span Arched Viaduct Bridge (6 compound arch cuts + twin deck parapets)",
+ complexity_tags=["3-arch", "6-boolean", "parapets", "architectural"],
+ expected_bbox=(9.0, 2.4, 2.83),
+ prompt=(
+ "Model a watertight 3-span stone arch viaduct bridge in right-handed Z-up meters (centered in X/Y, resting on Z=0):\n"
+ "- Main masonry body: box 9.0 m (X) x 2.4 m (Y) x 2.4 m (Z), resting at Z=0 (Z from 0.0 to 2.4).\n"
+ "- Cut 3 identical arched openings completely through the Y-axis, centered at X=-2.8, X=0.0, and X=+2.8:\n"
+ " * Each arch opening consists of a rectangular lower passage 1.8 m wide (X) x 1.0 m tall (Z from 0.0 to 1.0) topped seamlessly by a semicircular arch cylinder along the Y-axis of radius 0.90 m centered at Z=1.0 (reaching Z=1.90 at the crown).\n"
+ "- Add 2 continuous roadway parapet walls along the top edges of the deck: each 9.0 m (X) x 0.22 m (Y) x 0.45 m (Z), starting at Z=2.38 (reaching Z=2.83), centered at Y=-1.09 and Y=+1.09.\n"
+ "- Final mesh must be a single watertight manifold solid."
+ ),
+ ref_forma="""viaduct = box(9.0, 2.4, 2.4, z0=0.0)
+ | cut(box(1.8, 3.2, 1.2), at=[(-2.8, 0, 0.40), (0.0, 0, 0.40), (2.8, 0, 0.40)])
+ | cut(cyl(0.90, 3.2, segs=36, axis=y), at=[(-2.8, 0, 1.00), (0.0, 0, 1.00), (2.8, 0, 1.00)])
+ | add(box(9.0, 0.22, 0.45), at=[(0.0, -1.09, 2.605), (0.0, 1.09, 2.605)])
+ | mat("limestone", color=(0.80, 0.77, 0.70), metallic=0.0, roughness=0.82)
+""",
+ ),
+]
+
+TASK_MAP = {t.id: t for t in COMPLEX_TASKS}
+
+MODELS_AB = [
+ "anthropic/claude-opus-5.5",
+ "google/gemini-4-neon",
+ "openai/gpt-6.2-astra",
+]
+
+# Frontier multimodal vision models for Computer Use arm (CUA)
+MODELS_CUA = [
+ "anthropic/claude-opus-5.5",
+ "google/gemini-4-neon",
+]
+
+# OpenRouter approximate pricing ($ / 1M tokens: input, output)
+PRICING_PER_M = {
+ "anthropic/claude-opus-5.5": (5.0, 25.0),
+ "google/gemini-4-neon": (2.0, 12.0),
+ "openai/gpt-6.2-astra": (2.5, 15.0),
+}
+
+
+def load_api_key() -> str:
+ key = os.environ.get("OPENROUTER_API_KEY", "").strip()
+ if key:
+ return key
+ for p in [ROOT_DIR / ".env", ROOT_DIR.parent / ".env"]:
+ if p.exists():
+ for line in p.read_text().splitlines():
+ if line.startswith("OPENROUTER_API_KEY="):
+ return line.split("=", 1)[1].strip()
+ raise RuntimeError("Set OPENROUTER_API_KEY in environment before running benchmark.")
+
+
+def estimate_cost(model: str, prompt_toks: int, comp_toks: int) -> float:
+ pin, pout = PRICING_PER_M.get(model, (3.0, 15.0))
+ return (prompt_toks * pin + comp_toks * pout) / 1_000_000.0
+
+
+def call_openrouter(
+ api_key: str,
+ model: str,
+ messages: List[Dict[str, Any]],
+ max_tokens: int = 3200,
+ reasoning_effort: str = "low",
+) -> Tuple[str, Dict[str, Any]]:
+ payload: Dict[str, Any] = {
+ "model": model,
+ "messages": messages,
+ "temperature": 0.0,
+ "max_tokens": max_tokens,
+ "reasoning": {"effort": reasoning_effort},
+ }
+ body = json.dumps(payload).encode("utf-8")
+ req = urllib.request.Request(
+ "https://openrouter.ai/api/v1/chat/completions",
+ data=body,
+ headers={
+ "Authorization": f"Bearer {api_key}",
+ "Content-Type": "application/json",
+ "HTTP-Referer": "https://github.com/wrong-nebula/forma",
+ "X-Title": "forma-complex-abc-bench",
+ },
+ method="POST",
+ )
+ last_err = None
+ for attempt in range(4):
+ try:
+ with urllib.request.urlopen(req, timeout=120) as resp:
+ data = json.loads(resp.read().decode("utf-8"))
+ if "error" in data:
+ raise RuntimeError(f"OpenRouter error: {data['error']}")
+ choice = data["choices"][0]["message"]
+ content = choice.get("content") or ""
+ usage = data.get("usage") or {}
+ return content, usage
+ except Exception as e:
+ last_err = e
+ time.sleep(2.0 * (attempt + 1))
+ raise RuntimeError(f"OpenRouter failed after retries: {last_err}")
+
+
+def extract_code_block(text: str, lang_hint: str = "") -> str:
+ if lang_hint:
+ m = re.search(rf"```{lang_hint}\s*\n(.*?)```", text, re.S | re.I)
+ if m:
+ return m.group(1).strip()
+ m = re.search(r"```[a-zA-Z0-9_-]*\s*\n(.*?)```", text, re.S)
+ if m:
+ return m.group(1).strip()
+ return text.strip()
+
+
+def run_forma_eval(code: str, out_glb: Path) -> Tuple[bool, str, float]:
+ t0 = time.perf_counter()
+ res = subprocess.run(
+ [str(FORMA_BIN), "eval", "--strict", "--out", str(out_glb)],
+ input=code,
+ text=True,
+ capture_output=True,
+ timeout=30,
+ )
+ ms = (time.perf_counter() - t0) * 1000.0
+ out = (res.stdout + "\n" + res.stderr).strip()
+ ok = res.returncode == 0 and out_glb.exists() and out_glb.stat().st_size > 100
+ return ok, out, ms
+
+
+def run_blender_bpy(code: str, out_glb: Path) -> Tuple[bool, str, float]:
+ wrapper = f"OUT_PATH = {str(out_glb)!r}\n" + code + "\n"
+ with tempfile.NamedTemporaryFile("w", suffix=".py", delete=False) as tf:
+ tf.write(wrapper)
+ py_path = Path(tf.name)
+ t0 = time.perf_counter()
+ try:
+ with BLENDER_LOCK:
+ res = subprocess.run(
+ [BLENDER_BIN, "--background", "--factory-startup", "--python-exit-code", "1", "--python", str(py_path)],
+ text=True,
+ capture_output=True,
+ timeout=60,
+ )
+ except subprocess.TimeoutExpired:
+ return False, "TIMEOUT after 60s", 60000.0
+ finally:
+ py_path.unlink(missing_ok=True)
+ ms = (time.perf_counter() - t0) * 1000.0
+ out = (res.stdout + "\n" + res.stderr).strip()
+ ok = res.returncode == 0 and out_glb.exists() and out_glb.stat().st_size > 100
+ return ok, out[-1800:], ms
+
+
+def build_refs():
+ REF_DIR.mkdir(parents=True, exist_ok=True)
+ print(f"=== Building & Verifying {len(COMPLEX_TASKS)} Complex Reference Meshes ===")
+ for t in COMPLEX_TASKS:
+ glb = REF_DIR / f"{t.id}.glb"
+ png = REF_DIR / f"{t.id}.png"
+ t0 = time.perf_counter()
+ res = subprocess.run(
+ [str(FORMA_BIN), "eval", "--strict", "--out", str(glb), "--render", str(png)],
+ input=t.ref_forma,
+ text=True,
+ capture_output=True,
+ timeout=30,
+ )
+ ms = (time.perf_counter() - t0) * 1000.0
+ assert res.returncode == 0, f"Ref {t.id} failed: {res.stderr} {res.stdout}"
+ v = verify_mesh(glb, glb)
+ bsize = [round(v.bbox_max[i] - v.bbox_min[i], 3) for i in range(3)]
+ assert v.watertight and v.non_manifold_edges == 0 and v.passed, f"Ref {t.id} invalid: {v}"
+ print(f" {t.id:20s} OK {ms:6.2f}ms WT={v.watertight} NM={v.non_manifold_edges} vol={v.volume:.3f} bbox={bsize}")
+
+
+def load_done_keys() -> set:
+ done = set()
+ if CKPT_FILE.exists():
+ for line in CKPT_FILE.read_text().splitlines():
+ if not line.strip():
+ continue
+ r = json.loads(line)
+ done.add((r["arm"], r["model"], r["task_id"]))
+ return done
+
+
+def save_record(rec: Dict[str, Any]):
+ OUT_DIR.mkdir(parents=True, exist_ok=True)
+ with WRITE_LOCK:
+ with open(CKPT_FILE, "a") as f:
+ f.write(json.dumps(rec) + "\n")
+
+
+def get_forma_sys_prompt() -> str:
+ spec = subprocess.check_output([str(FORMA_BIN), "spec"], text=True).strip()
+ return (
+ "You are a 3D CAD agent using Forma (a pure-Rust headless 3D B-rep engine).\n"
+ "Use right-handed Z-up meters. Always ensure through-cutters exceed the target solid so there are no grazing coplanar cuts, "
+ "and overlap unioned solids slightly (e.g. 0.02 m) rather than kissing at zero thickness.\n"
+ f"{spec}\n"
+ "Output ONLY a single ```forma ... ``` code block (no prose outside the block)."
+ )
+
+
+BLENDER_MCP_SYS_PROMPT = """You are a 3D CAD agent operating Blender 5.3 via Blender MCP (`execute_blender_code` / headless `bpy` & `bmesh`).
+Requirements:
+- Start from an empty scene (`bpy.ops.wm.read_factory_settings(use_empty=True)`).
+- Use right-handed Z-up coordinates in meters.
+- Join all final solid geometry cleanly into a single watertight manifold mesh object (apply all modifiers cleanly and delete cutter objects before export).
+- Export the final mesh to the filepath stored in global variable `OUT_PATH` using:
+ `bpy.ops.export_scene.gltf(filepath=OUT_PATH, export_format='GLB', export_yup=False)`
+- Output ONLY a single ```python ... ``` code block (no prose outside the block)."""
+
+
+def eval_arm_ab_single(api_key: str, arm: str, model: str, task: ComplexTask, max_turns: int = 3) -> Dict[str, Any]:
+ sys_prompt = get_forma_sys_prompt() if arm == "forma" else BLENDER_MCP_SYS_PROMPT
+ messages: List[Dict[str, Any]] = [
+ {"role": "system", "content": sys_prompt},
+ {"role": "user", "content": task.prompt},
+ ]
+ ref_glb = REF_DIR / f"{task.id}.glb"
+ trial_dir = OUT_DIR / "meshes" / arm / model.replace("/", "_")
+ trial_dir.mkdir(parents=True, exist_ok=True)
+ out_glb = trial_dir / f"{task.id}.glb"
+
+ total_prompt_tok = 0
+ total_comp_tok = 0
+ total_code_tok = 0
+ total_exec_ms = 0.0
+ t_wall0 = time.perf_counter()
+
+ best_v: Optional[VerifyResult] = None
+ passed_turn = 0
+ turns_used = 0
+ last_err = ""
+
+ for turn in range(1, max_turns + 1):
+ turns_used = turn
+ content, usage = call_openrouter(api_key, model, messages, max_tokens=3600, reasoning_effort="low")
+ total_prompt_tok += int(usage.get("prompt_tokens", 0))
+ total_comp_tok += int(usage.get("completion_tokens", 0))
+ code = extract_code_block(content, "forma" if arm == "forma" else "python")
+ total_code_tok += count_toks(code)
+ messages.append({"role": "assistant", "content": content})
+
+ out_glb.unlink(missing_ok=True)
+ if arm == "forma":
+ ok, out_txt, exec_ms = run_forma_eval(code, out_glb)
+ else:
+ ok, out_txt, exec_ms = run_blender_bpy(code, out_glb)
+ total_exec_ms += exec_ms
+
+ if not ok:
+ last_err = out_txt[:500]
+ messages.append({
+ "role": "user",
+ "content": f"Execution failed:\n{out_txt[:900]}\nFix the script and output ONLY the corrected code block.",
+ })
+ continue
+
+ v = verify_mesh(out_glb, ref_glb)
+ best_v = v
+ geom_pass = bool(v.watertight and v.non_manifold_edges == 0 and v.volumetric_iou >= task.iou_threshold and v.bbox_err <= 0.15)
+ if geom_pass:
+ passed_turn = turn
+ break
+
+ bsize = [round(v.bbox_max[i] - v.bbox_min[i], 3) for i in range(3)]
+ diag = (
+ f"Verification failed on turn {turn}: WT={v.watertight}, NM={v.non_manifold_edges}, "
+ f"IoU={v.volumetric_iou:.3f} (need >= {task.iou_threshold}), "
+ f"bbox_size={bsize} (expected {list(task.expected_bbox)}), bbox_err={v.bbox_err:.3f}, "
+ f"vol={v.volume:.3f}. Engine output:\n{out_txt[:500]}\n"
+ "Fix the geometry/dimensions/manifoldness and output ONLY the corrected code block."
+ )
+ last_err = diag[:300]
+ messages.append({"role": "user", "content": diag})
+
+ wall_s = time.perf_counter() - t_wall0
+ rec = {
+ "arm": arm,
+ "model": model,
+ "task_id": task.id,
+ "passed": passed_turn > 0,
+ "passed_turn": passed_turn,
+ "pass_at_1": passed_turn == 1,
+ "turns_used": turns_used,
+ "gui_steps": 0,
+ "prompt_tokens": total_prompt_tok,
+ "completion_tokens": total_comp_tok,
+ "total_tokens": total_prompt_tok + total_comp_tok,
+ "code_tokens": total_code_tok,
+ "exec_ms": round(total_exec_ms, 2),
+ "wall_s": round(wall_s, 2),
+ "cost_usd": round(estimate_cost(model, total_prompt_tok, total_comp_tok), 5),
+ "watertight": bool(best_v.watertight) if best_v else False,
+ "non_manifold_edges": int(best_v.non_manifold_edges) if best_v else -1,
+ "iou": round(float(best_v.volumetric_iou), 4) if best_v else 0.0,
+ "chamfer": round(float(best_v.chamfer), 5) if best_v else 9.99,
+ "last_err": "" if passed_turn > 0 else last_err[:240],
+ }
+ save_record(rec)
+ status = f"PASS@T{passed_turn}" if passed_turn > 0 else "FAIL"
+ print(
+ f" [{arm:11s}] {model:27s} | {task.id:18s} | {status:7s} | IoU={rec['iou']:.3f} WT={str(rec['watertight']):5s} "
+ f"tok={rec['total_tokens']:6d} comp={rec['completion_tokens']:5d} exec={rec['exec_ms']:7.1f}ms wall={rec['wall_s']:5.1f}s",
+ flush=True,
+ )
+ return rec
+
+
+# =============================================================================
+# ARM C: BLENDER VIA COMPUTER USE (LIVE BLENDER 5.3 WORKBENCH VIEWPORT + GUI ACTIONS)
+# =============================================================================
+BLENDER_CUA_WORKER_SCRIPT = r"""
+import bpy, bmesh, json, math, sys, os
+from mathutils import Vector, Euler
+
+def reset_scene():
+ bpy.ops.wm.read_factory_settings(use_empty=True)
+ scene = bpy.context.scene
+ scene.render.engine = 'BLENDER_WORKBENCH'
+ scene.render.resolution_x = 800
+ scene.render.resolution_y = 500
+ scene.render.resolution_percentage = 100
+ scene.display.shading.light = 'STUDIO'
+ scene.display.shading.color_type = 'OBJECT'
+ scene.display.shading.show_cavity = True
+ scene.display.shading.show_object_outline = True
+ # Add camera
+ cam_data = bpy.data.cameras.new('CUA_Cam')
+ cam_obj = bpy.data.objects.new('CUA_Cam', cam_data)
+ scene.collection.objects.link(cam_obj)
+ scene.camera = cam_obj
+ set_camera(45.0, 32.0, 9.5, (0.0, 0.0, 1.0))
+
+def set_camera(az_deg, el_deg, dist, target=(0.0, 0.0, 1.0)):
+ cam = bpy.data.objects.get('CUA_Cam')
+ if not cam:
+ return
+ az = math.radians(az_deg)
+ el = math.radians(max(-80.0, min(80.0, el_deg)))
+ t = Vector(target)
+ pos = t + Vector((
+ dist * math.cos(el) * math.cos(az),
+ dist * math.cos(el) * math.sin(az),
+ dist * math.sin(el),
+ ))
+ cam.location = pos
+ direction = t - pos
+ cam.rotation_euler = direction.to_track_quat('-Z', 'Y').to_euler()
+
+def get_hud():
+ objs = []
+ active = bpy.context.view_layer.objects.active
+ for o in bpy.data.objects:
+ if o.type != 'MESH':
+ continue
+ bb = [o.matrix_world @ Vector(c) for c in o.bound_box]
+ mn = [round(min(v[i] for v in bb), 3) for i in range(3)]
+ mx = [round(max(v[i] for v in bb), 3) for i in range(3)]
+ objs.append({
+ 'name': o.name,
+ 'active': (o == active),
+ 'loc': [round(x, 3) for x in o.location],
+ 'dim': [round(x, 3) for x in o.dimensions],
+ 'rot_deg': [round(math.degrees(x), 1) for x in o.rotation_euler],
+ 'bbox_min': mn,
+ 'bbox_max': mx,
+ 'modifiers': [f"{m.name}:{m.type}" for m in o.modifiers],
+ })
+ return objs
+
+def render_vp(path):
+ scene = bpy.context.scene
+ scene.render.filepath = path
+ bpy.ops.render.render(write_still=True)
+
+def find_obj(name):
+ if name:
+ return bpy.data.objects.get(name)
+ return bpy.context.view_layer.objects.active
+
+def select_only(o):
+ bpy.ops.object.select_all(action='DESELECT')
+ if o:
+ o.select_set(True)
+ bpy.context.view_layer.objects.active = o
+
+reset_scene()
+sys.stdout.write("READY\n")
+sys.stdout.flush()
+
+for raw in sys.stdin:
+ line = raw.strip()
+ if not line:
+ continue
+ try:
+ cmd = json.loads(line)
+ op = cmd.get("action", "")
+ msg = "OK"
+ if op == "reset":
+ reset_scene()
+ elif op == "render":
+ render_vp(cmd["path"])
+ elif op == "orbit":
+ set_camera(
+ float(cmd.get("az", 45.0)),
+ float(cmd.get("el", 32.0)),
+ float(cmd.get("dist", 9.5)),
+ tuple(cmd.get("target", [0.0, 0.0, 1.0])),
+ )
+ elif op == "add_mesh":
+ kind = cmd.get("kind", "cube").lower()
+ loc = tuple(cmd.get("location", [0.0, 0.0, 0.0]))
+ if kind == "cube":
+ bpy.ops.mesh.primitive_cube_add(size=1.0, location=loc)
+ elif kind == "cylinder":
+ bpy.ops.mesh.primitive_cylinder_add(
+ vertices=int(cmd.get("vertices", 32)),
+ radius=float(cmd.get("radius", 0.5)),
+ depth=float(cmd.get("depth", 1.0)),
+ location=loc,
+ )
+ elif kind == "cone":
+ bpy.ops.mesh.primitive_cone_add(
+ vertices=int(cmd.get("vertices", 32)),
+ radius1=float(cmd.get("radius1", 0.5)),
+ radius2=float(cmd.get("radius2", 0.25)),
+ depth=float(cmd.get("depth", 1.0)),
+ location=loc,
+ )
+ elif kind == "sphere":
+ bpy.ops.mesh.primitive_uv_sphere_add(radius=float(cmd.get("radius", 0.5)), location=loc)
+ elif kind == "torus":
+ bpy.ops.mesh.primitive_torus_add(
+ major_radius=float(cmd.get("major_radius", 1.0)),
+ minor_radius=float(cmd.get("minor_radius", 0.25)),
+ location=loc,
+ )
+ else:
+ raise ValueError(f"Unknown mesh kind '{kind}'")
+ o = bpy.context.active_object
+ if cmd.get("name"):
+ o.name = str(cmd["name"])
+ msg = f"Added {o.name}"
+ elif op == "select":
+ o = find_obj(cmd.get("name"))
+ if not o:
+ raise ValueError(f"Object '{cmd.get('name')}' not found")
+ select_only(o)
+ msg = f"Selected {o.name}"
+ elif op == "set_transform":
+ o = find_obj(cmd.get("name"))
+ if not o:
+ raise ValueError("No active object")
+ select_only(o)
+ if "location" in cmd:
+ o.location = tuple(cmd["location"])
+ if "dimensions" in cmd:
+ o.dimensions = tuple(cmd["dimensions"])
+ bpy.context.view_layer.update()
+ bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)
+ if "rotation_deg" in cmd:
+ o.rotation_euler = tuple(math.radians(a) for a in cmd["rotation_deg"])
+ bpy.context.view_layer.update()
+ bpy.ops.object.transform_apply(location=False, rotation=True, scale=False)
+ msg = f"Updated transform of {o.name}"
+ elif op == "bevel_vertical":
+ o = find_obj(cmd.get("name"))
+ if not o:
+ raise ValueError("No active object")
+ select_only(o)
+ bpy.ops.object.mode_set(mode='EDIT')
+ bm = bmesh.from_edit_mesh(o.data)
+ edges = []
+ for e in bm.edges:
+ d = (e.verts[1].co - e.verts[0].co)
+ if d.length > 1e-5 and abs(d.z) / d.length > 0.9:
+ edges.append(e)
+ bmesh.ops.bevel(bm, geom=edges, offset=float(cmd.get("width", 0.2)), segments=int(cmd.get("segments", 3)), affect='EDGES', clamp_overlap=True)
+ bmesh.update_edit_mesh(o.data)
+ bpy.ops.object.mode_set(mode='OBJECT')
+ msg = f"Beveled {len(edges)} vertical edges on {o.name}"
+ elif op == "add_modifier":
+ o = find_obj(cmd.get("name"))
+ if not o:
+ raise ValueError("No active object")
+ select_only(o)
+ mtype = str(cmd.get("type", "")).upper()
+ m = o.modifiers.new(name=cmd.get("mod_name", mtype), type=mtype)
+ if mtype == "BOOLEAN":
+ m.operation = str(cmd.get("operation", "DIFFERENCE")).upper()
+ m.solver = str(cmd.get("solver", "EXACT")).upper()
+ tgt = find_obj(cmd.get("target"))
+ if not tgt:
+ raise ValueError(f"Boolean target '{cmd.get('target')}' not found")
+ m.object = tgt
+ elif mtype == "SOLIDIFY":
+ m.thickness = float(cmd.get("thickness", 0.15))
+ m.offset = float(cmd.get("offset", -1.0))
+ elif mtype == "BEVEL":
+ m.width = float(cmd.get("width", 0.1))
+ m.segments = int(cmd.get("segments", 3))
+ elif mtype == "SUBSURF":
+ m.levels = int(cmd.get("levels", 2))
+ m.render_levels = int(cmd.get("levels", 2))
+ if cmd.get("apply", True):
+ bpy.ops.object.modifier_apply(modifier=m.name)
+ if mtype == "BOOLEAN" and cmd.get("delete_target", True):
+ tgt = find_obj(cmd.get("target"))
+ if tgt:
+ bpy.data.objects.remove(tgt, do_unlink=True)
+ msg = f"Applied {mtype} on {o.name}"
+ elif op == "delete_top_face":
+ o = find_obj(cmd.get("name"))
+ if not o:
+ raise ValueError("No active object")
+ select_only(o)
+ bpy.ops.object.mode_set(mode='EDIT')
+ bm = bmesh.from_edit_mesh(o.data)
+ bm.faces.ensure_lookup_table()
+ max_z = max(f.calc_center_median().z for f in bm.faces)
+ top_faces = [f for f in bm.faces if f.normal.z > 0.9 and abs(f.calc_center_median().z - max_z) < 0.02]
+ bmesh.ops.delete(bm, geom=top_faces, context='FACES')
+ bmesh.update_edit_mesh(o.data)
+ bpy.ops.object.mode_set(mode='OBJECT')
+ msg = f"Deleted {len(top_faces)} top face(s) on {o.name}"
+ elif op == "delete_object":
+ o = find_obj(cmd.get("name"))
+ if o:
+ bpy.data.objects.remove(o, do_unlink=True)
+ msg = "Deleted object"
+ elif op == "export_glb":
+ # Select all mesh objects
+ bpy.ops.object.select_all(action='DESELECT')
+ meshes = [o for o in bpy.data.objects if o.type == 'MESH']
+ for o in meshes:
+ o.select_set(True)
+ if meshes:
+ bpy.context.view_layer.objects.active = meshes[0]
+ if len(meshes) > 1:
+ bpy.ops.object.join()
+ bpy.ops.export_scene.gltf(filepath=cmd["path"], export_format='GLB', export_yup=False, use_selection=True)
+ msg = f"Exported {cmd['path']}"
+ elif op == "quit":
+ break
+ else:
+ raise ValueError(f"Unknown CUA action '{op}'")
+ resp = {"ok": True, "msg": msg, "hud": get_hud()}
+ except Exception as e:
+ resp = {"ok": False, "msg": str(e), "hud": get_hud()}
+ sys.stdout.write("RESP:" + json.dumps(resp) + "\n")
+ sys.stdout.flush()
+"""
+
+CUA_SYS_PROMPT = """You are a Computer Use Agent (CUA) operating Blender 5.3 through its GUI (3D Viewport + Outliner + Transform N-Panel + Modifier Panel).
+You CANNOT write Python scripts. Instead, on each step you see the live Blender 5.3 viewport screenshot + GUI Outliner/Transform HUD, and you must emit ONE JSON GUI action object inside ```json ... ```.
+
+Available GUI actions (emit exactly ONE action per turn):
+1. `{"action": "add_mesh", "kind": "cube"|"cylinder"|"cone"|"sphere"|"torus", "name": "Body", "location": [x,y,z], "radius": r, "radius1": r1, "radius2": r2, "depth": h, "vertices": 32}` (Shift+A -> Add Mesh)
+2. `{"action": "set_transform", "name": "Body", "location": [x,y,z], "dimensions": [dx,dy,dz], "rotation_deg": [rx,ry,rz]}` (N-Panel Transform & Dimensions + Ctrl+A Apply)
+3. `{"action": "bevel_vertical", "name": "Body", "width": 0.25, "segments": 3}` (Tab -> Edge Select vertical edges -> Ctrl+B Bevel)
+4. `{"action": "delete_top_face", "name": "Body"}` (Tab -> Face Select top face -> X Delete Faces, before Solidify)
+5. `{"action": "add_modifier", "name": "Body", "type": "BOOLEAN"|"SOLIDIFY"|"BEVEL"|"SUBSURF", "operation": "DIFFERENCE"|"UNION"|"INTERSECT", "target": "Cutter", "thickness": 0.18, "offset": -1.0, "apply": true, "delete_target": true}` (Modifier Panel -> Add & Apply)
+6. `{"action": "select", "name": "Body"}` (Click in Outliner)
+7. `{"action": "delete_object", "name": "Tmp"}` (X -> Delete)
+8. `{"action": "orbit", "az": 45, "el": 30, "dist": 9.5}` (Middle-mouse drag viewport camera)
+9. `{"action": "finish"}` (File -> Export -> glTF 2.0 when the model is complete and verified in the viewport)
+
+Tips:
+- You have at most 28 GUI steps. Plan efficiently.
+- Make cutting objects exceed the target solid so booleans never leave thin grazing faces.
+- Output ONLY a single ```json { ... } ``` block per turn."""
+
+
+class BlenderCUAWorker:
+ def __init__(self):
+ self._tf = tempfile.NamedTemporaryFile("w", suffix=".py", delete=False)
+ self._tf.write(BLENDER_CUA_WORKER_SCRIPT)
+ self._tf.close()
+ self.proc = subprocess.Popen(
+ [BLENDER_BIN, "--background", "--factory-startup", "--python", self._tf.name],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.DEVNULL,
+ text=True,
+ bufsize=1,
+ )
+ # Wait for READY
+ for line in self.proc.stdout:
+ if line.strip() == "READY":
+ break
+
+ def send(self, payload: Dict[str, Any]) -> Dict[str, Any]:
+ assert self.proc.stdin and self.proc.stdout
+ self.proc.stdin.write(json.dumps(payload) + "\n")
+ self.proc.stdin.flush()
+ for line in self.proc.stdout:
+ if line.startswith("RESP:"):
+ return json.loads(line[5:])
+ raise RuntimeError("Blender CUA worker exited unexpectedly")
+
+ def close(self):
+ try:
+ if self.proc.stdin:
+ self.proc.stdin.write(json.dumps({"action": "quit"}) + "\n")
+ self.proc.stdin.flush()
+ self.proc.wait(timeout=5)
+ except Exception:
+ self.proc.kill()
+ Path(self._tf.name).unlink(missing_ok=True)
+
+
+def eval_arm_cua_single(api_key: str, model: str, task: ComplexTask, worker: BlenderCUAWorker, max_steps: int = 28) -> Dict[str, Any]:
+ ref_glb = REF_DIR / f"{task.id}.glb"
+ trial_dir = OUT_DIR / "meshes" / "blender_cua" / model.replace("/", "_")
+ trial_dir.mkdir(parents=True, exist_ok=True)
+ out_glb = trial_dir / f"{task.id}.glb"
+ vp_png = trial_dir / f"{task.id}_vp.png"
+
+ worker.send({"action": "reset"})
+ if task.id == "arch_viaduct":
+ worker.send({"action": "orbit", "az": 50, "el": 24, "dist": 14.5, "target": [0.0, 0.0, 1.3]})
+ else:
+ worker.send({"action": "orbit", "az": 42, "el": 30, "dist": 8.0, "target": [0.0, 0.0, 1.0]})
+
+ total_prompt_tok = 0
+ total_comp_tok = 0
+ total_exec_ms = 0.0
+ t_wall0 = time.perf_counter()
+
+ # Keep a sliding window of history so vision screenshots don't blow context
+ action_log: List[str] = []
+ steps_used = 0
+ finished = False
+ last_err = ""
+
+ for step in range(1, max_steps + 1):
+ steps_used = step
+ t0 = time.perf_counter()
+ r_vp = worker.send({"action": "render", "path": str(vp_png)})
+ total_exec_ms += (time.perf_counter() - t0) * 1000.0
+
+ b64 = base64.b64encode(vp_png.read_bytes()).decode("ascii")
+ hud_str = json.dumps(r_vp.get("hud", []), separators=(",", ":"))
+ recent = "\n".join(action_log[-10:]) if action_log else "(none yet)"
+ user_text = (
+ f"TASK:\n{task.prompt}\n\n"
+ f"STEP {step}/{max_steps}\n"
+ f"BLENDER GUI OUTLINER/TRANSFORM HUD:\n{hud_str}\n\n"
+ f"RECENT ACTIONS:\n{recent}\n\n"
+ "Inspect the attached Blender 5.3 viewport screenshot and emit ONE next ```json ... ``` GUI action."
+ )
+ messages = [
+ {"role": "system", "content": CUA_SYS_PROMPT},
+ {
+ "role": "user",
+ "content": [
+ {"type": "text", "text": user_text},
+ {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{b64}"}},
+ ],
+ },
+ ]
+ content, usage = call_openrouter(api_key, model, messages, max_tokens=1000, reasoning_effort="low")
+ total_prompt_tok += int(usage.get("prompt_tokens", 0))
+ total_comp_tok += int(usage.get("completion_tokens", 0))
+
+ raw_json = extract_code_block(content, "json")
+ try:
+ act = json.loads(raw_json)
+ except Exception as e:
+ action_log.append(f"Step {step}: PARSE_ERR ({e})")
+ last_err = f"JSON parse error: {e}"
+ continue
+
+ if act.get("action") == "finish":
+ finished = True
+ action_log.append(f"Step {step}: finish")
+ break
+
+ t1 = time.perf_counter()
+ res = worker.send(act)
+ total_exec_ms += (time.perf_counter() - t1) * 1000.0
+ ok_flag = "OK" if res.get("ok") else "ERR"
+ action_log.append(f"Step {step}: {act.get('action')}({act.get('name', act.get('kind', ''))}) -> {ok_flag}: {res.get('msg', '')[:80]}")
+ if not res.get("ok"):
+ last_err = res.get("msg", "")[:200]
+
+ # Export whatever is in the Blender scene at finish / step limit
+ out_glb.unlink(missing_ok=True)
+ t_exp = time.perf_counter()
+ exp_res = worker.send({"action": "export_glb", "path": str(out_glb)})
+ total_exec_ms += (time.perf_counter() - t_exp) * 1000.0
+
+ best_v: Optional[VerifyResult] = None
+ passed = False
+ if exp_res.get("ok") and out_glb.exists() and out_glb.stat().st_size > 100:
+ best_v = verify_mesh(out_glb, ref_glb)
+ passed = bool(
+ best_v.watertight
+ and best_v.non_manifold_edges == 0
+ and best_v.volumetric_iou >= task.iou_threshold
+ and best_v.bbox_err <= 0.15
+ )
+ else:
+ last_err = exp_res.get("msg", "empty export")
+
+ wall_s = time.perf_counter() - t_wall0
+ rec = {
+ "arm": "blender_cua",
+ "model": model,
+ "task_id": task.id,
+ "passed": passed,
+ "passed_turn": steps_used if passed else 0,
+ "pass_at_1": False,
+ "turns_used": steps_used,
+ "gui_steps": steps_used,
+ "finished": finished,
+ "prompt_tokens": total_prompt_tok,
+ "completion_tokens": total_comp_tok,
+ "total_tokens": total_prompt_tok + total_comp_tok,
+ "code_tokens": 0,
+ "exec_ms": round(total_exec_ms, 2),
+ "wall_s": round(wall_s, 2),
+ "cost_usd": round(estimate_cost(model, total_prompt_tok, total_comp_tok), 5),
+ "watertight": bool(best_v.watertight) if best_v else False,
+ "non_manifold_edges": int(best_v.non_manifold_edges) if best_v else -1,
+ "iou": round(float(best_v.volumetric_iou), 4) if best_v else 0.0,
+ "chamfer": round(float(best_v.chamfer), 5) if best_v else 9.99,
+ "last_err": "" if passed else (last_err or f"finished={finished} steps={steps_used}"),
+ }
+ save_record(rec)
+ status = f"PASS({steps_used}st)" if passed else f"FAIL({steps_used}st)"
+ print(
+ f" [blender_cua] {model:27s} | {task.id:18s} | {status:10s} | IoU={rec['iou']:.3f} WT={str(rec['watertight']):5s} "
+ f"tok={rec['total_tokens']:7d} comp={rec['completion_tokens']:5d} exec={rec['exec_ms']:7.0f}ms wall={rec['wall_s']:5.1f}s",
+ flush=True,
+ )
+ return rec
+
+
+def run_ab():
+ api_key = load_api_key()
+ done = load_done_keys()
+ jobs = []
+ for arm in ["forma", "blender_mcp"]:
+ for model in MODELS_AB:
+ for task in COMPLEX_TASKS:
+ if (arm, model, task.id) not in done:
+ jobs.append((arm, model, task))
+ print(f"=== Running {len(jobs)} Arm A (Forma) & Arm B (Blender CLI/MCP) complex trials (max_workers=3) ===", flush=True)
+ with concurrent.futures.ThreadPoolExecutor(max_workers=3) as ex:
+ futs = [ex.submit(eval_arm_ab_single, api_key, arm, model, task) for arm, model, task in jobs]
+ for fut in concurrent.futures.as_completed(futs):
+ fut.result()
+
+
+def run_cua():
+ api_key = load_api_key()
+ done = load_done_keys()
+ jobs = []
+ for model in MODELS_CUA:
+ for task in COMPLEX_TASKS:
+ if ("blender_cua", model, task.id) not in done:
+ jobs.append((model, task))
+ print(f"=== Running {len(jobs)} Arm C (Blender 5.3 Computer Use GUI+Vision) complex trials ===", flush=True)
+ if not jobs:
+ return
+ worker = BlenderCUAWorker()
+ try:
+ for model, task in jobs:
+ eval_arm_cua_single(api_key, model, task, worker, max_steps=28)
+ finally:
+ worker.close()
+
+
+def print_report():
+ if not CKPT_FILE.exists():
+ print("No trials recorded yet.")
+ return
+ rows = [json.loads(l) for l in CKPT_FILE.read_text().splitlines() if l.strip()]
+ by_arm: Dict[str, List[Dict[str, Any]]] = {}
+ for r in rows:
+ by_arm.setdefault(r["arm"], []).append(r)
+
+ print("\n" + "=" * 96)
+ print("3-WAY COMPLEX MODEL A/B/C SUMMARY (5 Complex Multi-Feature Models)")
+ print("=" * 96)
+ for arm in ["forma", "blender_mcp", "blender_cua"]:
+ rs = by_arm.get(arm, [])
+ if not rs:
+ continue
+ n = len(rs)
+ p = sum(1 for r in rs if r["passed"])
+ p1 = sum(1 for r in rs if r["pass_at_1"])
+ wt = sum(1 for r in rs if r["watertight"])
+ avg_iou = statistics.mean(r["iou"] for r in rs)
+ tot_tok = sum(r["total_tokens"] for r in rs)
+ tot_comp = sum(r["completion_tokens"] for r in rs)
+ avg_tok = tot_tok / n
+ avg_comp = tot_comp / n
+ avg_wall = statistics.mean(r["wall_s"] for r in rs)
+ med_exec = statistics.median(r["exec_ms"] for r in rs)
+ tot_cost = sum(r["cost_usd"] for r in rs)
+ avg_cost = tot_cost / n
+ avg_steps = statistics.mean(r["turns_used"] for r in rs)
+ print(
+ f"{arm:12s} | N={n:2d} | Pass={p:2d}/{n:2d} ({p/n*100:5.1f}%) | P@1={p1:2d}/{n:2d} | WT={wt:2d}/{n:2d} | "
+ f"IoU={avg_iou:.3f} | AvgTok={avg_tok:7.0f} (Comp={avg_comp:5.0f}) | "
+ f"AvgTurns={avg_steps:4.1f} | MedExec={med_exec:7.1f}ms | AvgWall={avg_wall:5.1f}s | AvgCost=${avg_cost:.4f}"
+ )
+
+ print("\n--- PER-TASK BREAKDOWN ---")
+ for t in COMPLEX_TASKS:
+ parts = []
+ for arm in ["forma", "blender_mcp", "blender_cua"]:
+ rs = [r for r in by_arm.get(arm, []) if r["task_id"] == t.id]
+ if rs:
+ p = sum(1 for r in rs if r["passed"])
+ iou = statistics.mean(r["iou"] for r in rs)
+ tok = statistics.mean(r["total_tokens"] for r in rs)
+ parts.append(f"{arm}:{p}/{len(rs)} IoU={iou:.2f} tok={tok:.0f}")
+ print(f" {t.id:20s} | " + " || ".join(parts))
+
+ print("\n--- PER-MODEL BREAKDOWN ---")
+ models = sorted({r["model"] for r in rows})
+ for m in models:
+ for arm in ["forma", "blender_mcp", "blender_cua"]:
+ rs = [r for r in by_arm.get(arm, []) if r["model"] == m]
+ if not rs:
+ continue
+ p = sum(1 for r in rs if r["passed"])
+ iou = statistics.mean(r["iou"] for r in rs)
+ tok = sum(r["total_tokens"] for r in rs)
+ comp = sum(r["completion_tokens"] for r in rs)
+ wall = statistics.mean(r["wall_s"] for r in rs)
+ cost = sum(r["cost_usd"] for r in rs)
+ print(f" {m:27s} | {arm:11s} | {p}/{len(rs)} | IoU={iou:.3f} | TotTok={tok:7d} (Comp={comp:5d}) | AvgWall={wall:5.1f}s | Cost=${cost:.4f}")
+
+
+if __name__ == "__main__":
+ cmd = sys.argv[1] if len(sys.argv) > 1 else "report"
+ if cmd == "refs":
+ build_refs()
+ elif cmd == "run_ab":
+ build_refs()
+ run_ab()
+ elif cmd == "run_cua":
+ build_refs()
+ run_cua()
+ elif cmd == "all":
+ build_refs()
+ run_ab()
+ run_cua()
+ print_report()
+ elif cmd == "report":
+ print_report()
+ else:
+ print(f"Unknown command: {cmd}")
+ sys.exit(2)
diff --git a/bench/eval_matrix.py b/bench/eval_matrix.py
index 5fccf57..07cad89 100644
--- a/bench/eval_matrix.py
+++ b/bench/eval_matrix.py
@@ -118,7 +118,7 @@ def call_openrouter_level(
headers={
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
- "HTTP-Referer": "https://github.com/forma-3d-bench",
+ "HTTP-Referer": "https://github.com/wrong-nebula/forma",
"X-Title": "forma-3d-matrix",
},
method="POST",
diff --git a/bench/results/complex_abc/trials.jsonl b/bench/results/complex_abc/trials.jsonl
new file mode 100644
index 0000000..934a255
--- /dev/null
+++ b/bench/results/complex_abc/trials.jsonl
@@ -0,0 +1,35 @@
+{"arm": "forma", "model": "anthropic/claude-opus-5.5", "task_id": "sensor_housing", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 1280, "completion_tokens": 543, "total_tokens": 1823, "code_tokens": 450, "exec_ms": 39.54, "wall_s": 11.02, "cost_usd": 0.01997, "watertight": true, "non_manifold_edges": 0, "iou": 1.0, "chamfer": 0.06679, "last_err": ""}
+{"arm": "forma", "model": "anthropic/claude-opus-5.5", "task_id": "hydraulic_manifold", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 1220, "completion_tokens": 304, "total_tokens": 1524, "code_tokens": 245, "exec_ms": 89.43, "wall_s": 13.3, "cost_usd": 0.0137, "watertight": true, "non_manifold_edges": 0, "iou": 1.0, "chamfer": 0.05733, "last_err": ""}
+{"arm": "forma", "model": "anthropic/claude-opus-5.5", "task_id": "arch_viaduct", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 1279, "completion_tokens": 276, "total_tokens": 1555, "code_tokens": 226, "exec_ms": 21.84, "wall_s": 5.38, "cost_usd": 0.01329, "watertight": true, "non_manifold_edges": 0, "iou": 1.0, "chamfer": 0.08502, "last_err": ""}
+{"arm": "forma", "model": "google/gemini-4-neon", "task_id": "hydraulic_manifold", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 951, "completion_tokens": 1264, "total_tokens": 2215, "code_tokens": 280, "exec_ms": 50.06, "wall_s": 20.55, "cost_usd": 0.01707, "watertight": true, "non_manifold_edges": 0, "iou": 1.0, "chamfer": 0.05694, "last_err": ""}
+{"arm": "forma", "model": "anthropic/claude-opus-5.5", "task_id": "flanged_reducer", "passed": true, "passed_turn": 3, "pass_at_1": false, "turns_used": 3, "gui_steps": 0, "prompt_tokens": 6478, "completion_tokens": 2585, "total_tokens": 9063, "code_tokens": 1498, "exec_ms": 486.54, "wall_s": 39.8, "cost_usd": 0.09702, "watertight": true, "non_manifold_edges": 0, "iou": 0.9826, "chamfer": 0.04259, "last_err": ""}
+{"arm": "forma", "model": "anthropic/claude-opus-5.5", "task_id": "threaded_bolt", "passed": true, "passed_turn": 2, "pass_at_1": false, "turns_used": 2, "gui_steps": 0, "prompt_tokens": 2724, "completion_tokens": 832, "total_tokens": 3556, "code_tokens": 388, "exec_ms": 1186.9, "wall_s": 30.08, "cost_usd": 0.03442, "watertight": true, "non_manifold_edges": 0, "iou": 1.0, "chamfer": 0.02825, "last_err": ""}
+{"arm": "forma", "model": "google/gemini-4-neon", "task_id": "sensor_housing", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 1001, "completion_tokens": 1451, "total_tokens": 2452, "code_tokens": 307, "exec_ms": 26.06, "wall_s": 26.15, "cost_usd": 0.01941, "watertight": true, "non_manifold_edges": 0, "iou": 1.0, "chamfer": 0.06703, "last_err": ""}
+{"arm": "forma", "model": "google/gemini-4-neon", "task_id": "flanged_reducer", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 1063, "completion_tokens": 1796, "total_tokens": 2859, "code_tokens": 462, "exec_ms": 118.04, "wall_s": 29.02, "cost_usd": 0.02368, "watertight": true, "non_manifold_edges": 0, "iou": 0.9876, "chamfer": 0.04251, "last_err": ""}
+{"arm": "forma", "model": "google/gemini-4-neon", "task_id": "threaded_bolt", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 949, "completion_tokens": 818, "total_tokens": 1767, "code_tokens": 165, "exec_ms": 28.59, "wall_s": 29.76, "cost_usd": 0.01171, "watertight": true, "non_manifold_edges": 0, "iou": 1.0, "chamfer": 0.02755, "last_err": ""}
+{"arm": "forma", "model": "google/gemini-4-neon", "task_id": "arch_viaduct", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 987, "completion_tokens": 1412, "total_tokens": 2399, "code_tokens": 237, "exec_ms": 16.67, "wall_s": 20.13, "cost_usd": 0.01892, "watertight": true, "non_manifold_edges": 0, "iou": 1.0, "chamfer": 0.08389, "last_err": ""}
+{"arm": "forma", "model": "openai/gpt-6.2-astra", "task_id": "hydraulic_manifold", "passed": false, "passed_turn": 0, "pass_at_1": false, "turns_used": 3, "gui_steps": 0, "prompt_tokens": 3422, "completion_tokens": 823, "total_tokens": 4245, "code_tokens": 762, "exec_ms": 866.83, "wall_s": 23.53, "cost_usd": 0.0209, "watertight": false, "non_manifold_edges": -1, "iou": 0.0, "chamfer": 9.99, "last_err": "ERR: invariant violation on 'drilled': non-manifold result (WT=false, NM=3, B=1) (auto-rolled back)"}
+{"arm": "forma", "model": "openai/gpt-6.2-astra", "task_id": "flanged_reducer", "passed": true, "passed_turn": 2, "pass_at_1": false, "turns_used": 2, "gui_steps": 0, "prompt_tokens": 2234, "completion_tokens": 620, "total_tokens": 2854, "code_tokens": 579, "exec_ms": 358.32, "wall_s": 21.15, "cost_usd": 0.01489, "watertight": true, "non_manifold_edges": 0, "iou": 0.9777, "chamfer": 0.04205, "last_err": ""}
+{"arm": "forma", "model": "openai/gpt-6.2-astra", "task_id": "sensor_housing", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 893, "completion_tokens": 241, "total_tokens": 1134, "code_tokens": 233, "exec_ms": 53.13, "wall_s": 8.87, "cost_usd": 0.00585, "watertight": true, "non_manifold_edges": 0, "iou": 1.0, "chamfer": 0.06691, "last_err": ""}
+{"arm": "forma", "model": "openai/gpt-6.2-astra", "task_id": "threaded_bolt", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 839, "completion_tokens": 124, "total_tokens": 963, "code_tokens": 116, "exec_ms": 24.38, "wall_s": 14.21, "cost_usd": 0.00396, "watertight": true, "non_manifold_edges": 0, "iou": 1.0, "chamfer": 0.0278, "last_err": ""}
+{"arm": "forma", "model": "openai/gpt-6.2-astra", "task_id": "arch_viaduct", "passed": true, "passed_turn": 2, "pass_at_1": false, "turns_used": 2, "gui_steps": 0, "prompt_tokens": 2057, "completion_tokens": 471, "total_tokens": 2528, "code_tokens": 455, "exec_ms": 28.07, "wall_s": 14.69, "cost_usd": 0.01221, "watertight": true, "non_manifold_edges": 0, "iou": 1.0, "chamfer": 0.08374, "last_err": ""}
+{"arm": "blender_mcp", "model": "anthropic/claude-opus-5.5", "task_id": "hydraulic_manifold", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 626, "completion_tokens": 1058, "total_tokens": 1684, "code_tokens": 647, "exec_ms": 1292.69, "wall_s": 17.45, "cost_usd": 0.02958, "watertight": true, "non_manifold_edges": 0, "iou": 0.9679, "chamfer": 0.06112, "last_err": ""}
+{"arm": "blender_mcp", "model": "anthropic/claude-opus-5.5", "task_id": "flanged_reducer", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 740, "completion_tokens": 923, "total_tokens": 1663, "code_tokens": 610, "exec_ms": 1783.46, "wall_s": 16.05, "cost_usd": 0.02678, "watertight": true, "non_manifold_edges": 0, "iou": 0.9777, "chamfer": 0.04254, "last_err": ""}
+{"arm": "blender_mcp", "model": "anthropic/claude-opus-5.5", "task_id": "sensor_housing", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 686, "completion_tokens": 1769, "total_tokens": 2455, "code_tokens": 856, "exec_ms": 1298.11, "wall_s": 19.59, "cost_usd": 0.04766, "watertight": true, "non_manifold_edges": 0, "iou": 0.9718, "chamfer": 0.06638, "last_err": ""}
+{"arm": "blender_mcp", "model": "anthropic/claude-opus-5.5", "task_id": "threaded_bolt", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 615, "completion_tokens": 1524, "total_tokens": 2139, "code_tokens": 626, "exec_ms": 1077.33, "wall_s": 22.05, "cost_usd": 0.04118, "watertight": true, "non_manifold_edges": 0, "iou": 0.9916, "chamfer": 0.02806, "last_err": ""}
+{"arm": "blender_mcp", "model": "anthropic/claude-opus-5.5", "task_id": "arch_viaduct", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 685, "completion_tokens": 1395, "total_tokens": 2080, "code_tokens": 613, "exec_ms": 1223.62, "wall_s": 16.79, "cost_usd": 0.0383, "watertight": true, "non_manifold_edges": 0, "iou": 1.0, "chamfer": 0.08448, "last_err": ""}
+{"arm": "blender_mcp", "model": "google/gemini-4-neon", "task_id": "sensor_housing", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 518, "completion_tokens": 2823, "total_tokens": 3341, "code_tokens": 1364, "exec_ms": 1893.41, "wall_s": 35.41, "cost_usd": 0.03491, "watertight": true, "non_manifold_edges": 0, "iou": 0.9718, "chamfer": 0.06688, "last_err": ""}
+{"arm": "blender_mcp", "model": "google/gemini-4-neon", "task_id": "hydraulic_manifold", "passed": true, "passed_turn": 2, "pass_at_1": false, "turns_used": 2, "gui_steps": 0, "prompt_tokens": 2778, "completion_tokens": 4340, "total_tokens": 7118, "code_tokens": 2433, "exec_ms": 2664.72, "wall_s": 59.93, "cost_usd": 0.05764, "watertight": true, "non_manifold_edges": 0, "iou": 1.0, "chamfer": 0.05756, "last_err": ""}
+{"arm": "blender_mcp", "model": "google/gemini-4-neon", "task_id": "flanged_reducer", "passed": true, "passed_turn": 2, "pass_at_1": false, "turns_used": 2, "gui_steps": 0, "prompt_tokens": 3089, "completion_tokens": 6316, "total_tokens": 9405, "code_tokens": 2518, "exec_ms": 5041.33, "wall_s": 69.5, "cost_usd": 0.08197, "watertight": true, "non_manifold_edges": 0, "iou": 0.9876, "chamfer": 0.04246, "last_err": ""}
+{"arm": "blender_mcp", "model": "google/gemini-4-neon", "task_id": "arch_viaduct", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 504, "completion_tokens": 2456, "total_tokens": 2960, "code_tokens": 1174, "exec_ms": 2080.83, "wall_s": 36.46, "cost_usd": 0.03048, "watertight": true, "non_manifold_edges": 0, "iou": 0.9924, "chamfer": 0.08305, "last_err": ""}
+{"arm": "blender_mcp", "model": "openai/gpt-6.2-astra", "task_id": "hydraulic_manifold", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 410, "completion_tokens": 748, "total_tokens": 1158, "code_tokens": 740, "exec_ms": 6044.72, "wall_s": 36.33, "cost_usd": 0.01225, "watertight": true, "non_manifold_edges": 0, "iou": 1.0, "chamfer": 0.05799, "last_err": ""}
+{"arm": "blender_mcp", "model": "openai/gpt-6.2-astra", "task_id": "sensor_housing", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 456, "completion_tokens": 894, "total_tokens": 1350, "code_tokens": 886, "exec_ms": 2467.99, "wall_s": 29.96, "cost_usd": 0.01455, "watertight": true, "non_manifold_edges": 0, "iou": 0.9718, "chamfer": 0.06664, "last_err": ""}
+{"arm": "blender_mcp", "model": "openai/gpt-6.2-astra", "task_id": "flanged_reducer", "passed": true, "passed_turn": 2, "pass_at_1": false, "turns_used": 2, "gui_steps": 0, "prompt_tokens": 1847, "completion_tokens": 1767, "total_tokens": 3614, "code_tokens": 1711, "exec_ms": 5784.39, "wall_s": 61.27, "cost_usd": 0.03112, "watertight": true, "non_manifold_edges": 0, "iou": 0.9777, "chamfer": 0.04244, "last_err": ""}
+{"arm": "blender_mcp", "model": "openai/gpt-6.2-astra", "task_id": "arch_viaduct", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 454, "completion_tokens": 830, "total_tokens": 1284, "code_tokens": 822, "exec_ms": 2783.87, "wall_s": 34.94, "cost_usd": 0.01358, "watertight": true, "non_manifold_edges": 0, "iou": 0.9924, "chamfer": 0.08296, "last_err": ""}
+{"arm": "blender_mcp", "model": "google/gemini-4-neon", "task_id": "threaded_bolt", "passed": true, "passed_turn": 3, "pass_at_1": false, "turns_used": 3, "gui_steps": 0, "prompt_tokens": 6633, "completion_tokens": 7783, "total_tokens": 14416, "code_tokens": 3919, "exec_ms": 15058.79, "wall_s": 148.31, "cost_usd": 0.10666, "watertight": true, "non_manifold_edges": 0, "iou": 0.9943, "chamfer": 0.02797, "last_err": ""}
+{"arm": "blender_mcp", "model": "openai/gpt-6.2-astra", "task_id": "threaded_bolt", "passed": true, "passed_turn": 1, "pass_at_1": true, "turns_used": 1, "gui_steps": 0, "prompt_tokens": 402, "completion_tokens": 918, "total_tokens": 1320, "code_tokens": 910, "exec_ms": 2046.37, "wall_s": 88.29, "cost_usd": 0.01477, "watertight": true, "non_manifold_edges": 0, "iou": 0.9268, "chamfer": 0.03261, "last_err": ""}
+{"arm": "blender_cua", "model": "anthropic/claude-opus-5.5", "task_id": "hydraulic_manifold", "passed": true, "passed_turn": 25, "pass_at_1": false, "turns_used": 25, "gui_steps": 25, "finished": true, "prompt_tokens": 56265, "completion_tokens": 8338, "total_tokens": 64603, "code_tokens": 0, "exec_ms": 2236.66, "wall_s": 174.32, "cost_usd": 0.48978, "watertight": true, "non_manifold_edges": 0, "iou": 0.9731, "chamfer": 0.06431, "last_err": ""}
+{"arm": "blender_cua", "model": "anthropic/claude-opus-5.5", "task_id": "flanged_reducer", "passed": true, "passed_turn": 25, "pass_at_1": false, "turns_used": 25, "gui_steps": 25, "finished": true, "prompt_tokens": 59809, "completion_tokens": 5094, "total_tokens": 64903, "code_tokens": 0, "exec_ms": 2022.6, "wall_s": 167.1, "cost_usd": 0.4264, "watertight": true, "non_manifold_edges": 0, "iou": 0.9876, "chamfer": 0.04275, "last_err": ""}
+{"arm": "blender_cua", "model": "anthropic/claude-opus-5.5", "task_id": "sensor_housing", "passed": false, "passed_turn": 0, "pass_at_1": false, "turns_used": 27, "gui_steps": 27, "finished": true, "prompt_tokens": 61423, "completion_tokens": 8725, "total_tokens": 70148, "code_tokens": 0, "exec_ms": 2498.08, "wall_s": 195.79, "cost_usd": 0.52524, "watertight": true, "non_manifold_edges": 0, "iou": 0.7241, "chamfer": 0.08597, "last_err": "finished=True steps=27"}
+{"arm": "blender_cua", "model": "anthropic/claude-opus-5.5", "task_id": "threaded_bolt", "passed": false, "passed_turn": 0, "pass_at_1": false, "turns_used": 28, "gui_steps": 28, "finished": true, "prompt_tokens": 63589, "completion_tokens": 8802, "total_tokens": 72391, "code_tokens": 0, "exec_ms": 3232.55, "wall_s": 165.94, "cost_usd": 0.538, "watertight": false, "non_manifold_edges": 69, "iou": 0.0, "chamfer": 0.03137, "last_err": "finished=True steps=28"}
+{"arm": "blender_cua", "model": "anthropic/claude-opus-5.5", "task_id": "arch_viaduct", "passed": false, "passed_turn": 0, "pass_at_1": false, "turns_used": 28, "gui_steps": 28, "finished": true, "prompt_tokens": 67246, "completion_tokens": 9575, "total_tokens": 76821, "code_tokens": 0, "exec_ms": 2053.14, "wall_s": 201.59, "cost_usd": 0.57561, "watertight": true, "non_manifold_edges": 0, "iou": 0.79, "chamfer": 0.13461, "last_err": "finished=True steps=28"}
diff --git a/bench/tasks.py b/bench/tasks.py
index f7c547a..bbcfd9f 100644
--- a/bench/tasks.py
+++ b/bench/tasks.py
@@ -10,6 +10,7 @@ Each task defines:
from __future__ import annotations
import os
+import shutil
import subprocess
import sys
import tempfile
@@ -17,7 +18,11 @@ from dataclasses import dataclass
from pathlib import Path
from typing import Dict, List, Tuple
-BLENDER_BIN = "/Applications/Blender.app/Contents/MacOS/Blender"
+BLENDER_BIN = (
+ os.environ.get("BLENDER_BIN")
+ or shutil.which("blender")
+ or "/Applications/Blender.app/Contents/MacOS/Blender"
+)
REF_DIR = Path(__file__).resolve().parent / "ref_meshes"
diff --git a/bench/verify.py b/bench/verify.py
index 4a016b6..de02197 100644
--- a/bench/verify.py
+++ b/bench/verify.py
@@ -15,6 +15,8 @@ from __future__ import annotations
import json
import math
+import os
+import shutil
import subprocess
import sys
from dataclasses import asdict, dataclass
@@ -25,7 +27,11 @@ import numpy as np
import trimesh
from scipy.spatial import cKDTree
-BLENDER_BIN = "/Applications/Blender.app/Contents/MacOS/Blender"
+BLENDER_BIN = (
+ os.environ.get("BLENDER_BIN")
+ or shutil.which("blender")
+ or "/Applications/Blender.app/Contents/MacOS/Blender"
+)
@dataclass
@@ -54,6 +60,20 @@ class VerifyResult:
blender_import_ok: Optional[bool] = None
+def _glb_is_forma_yup(path: Path) -> bool:
+ if path.suffix.lower() != ".glb":
+ return False
+ try:
+ data = path.read_bytes()
+ if len(data) < 20 or data[:4] != b"glTF":
+ return False
+ jlen = int.from_bytes(data[12:16], "little")
+ meta = json.loads(data[20 : 20 + jlen].decode("utf-8"))
+ return bool(meta.get("asset", {}).get("extras", {}).get("forma_yup"))
+ except Exception:
+ return False
+
+
def load_unified_mesh(path: Path) -> trimesh.Trimesh:
loaded = trimesh.load(str(path), force=None)
if isinstance(loaded, trimesh.Scene):
@@ -65,6 +85,13 @@ def load_unified_mesh(path: Path) -> trimesh.Trimesh:
mesh = loaded
else:
raise ValueError(f"Unsupported loaded type: {type(loaded)}")
+ # Convert spec-compliant Y-up glTF exports (x, z, -y) back to Z-up for comparison against Z-up references
+ if _glb_is_forma_yup(path):
+ yup_to_zup = np.array(
+ [[1.0, 0.0, 0.0, 0.0], [0.0, 0.0, -1.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 0.0, 1.0]],
+ dtype=np.float64,
+ )
+ mesh.apply_transform(yup_to_zup)
# Merge exact duplicate vertices (glTF splits vertices at hard normal creases)
mesh.merge_vertices(merge_tex=True, merge_norm=True)
return mesh