~/shanegraffiti.com/research/itercad-agent
Shane Graffiti Inc. Semantic Adversarial Research Division 2026

CLOSING
THE LOOP
ON CAD
GENERATION

Most CAD-generation systems work the way a junior drafter would if forbidden from ever looking back at their own work: one shot, no revision, whatever the model outputs is final. Professional CAD practice runs the opposite loop generate, verify against the drawing, refine, repeat. IterCAD formalizes that loop as a multi-turn agent operating inside an executable CAD sandbox, unifying three tasks: turning a multi-view engineering drawing into parametric CadQuery code, turning a text requirement into code, and editing existing code from natural-language instructions. A two-stage recipe cold-start supervised fine-tuning on expert trajectories, then geometry-aware reinforcement learning with a viable-prefix masking scheme that stops crediting or blaming turns for failures they didn't cause teaches the agent to debug its own runtime errors and correct its own geometry against rendered visual feedback. A new evaluation curve, Chamfer-Distance Tolerance-Recall, closes a long-standing loophole in CAD benchmarking by scoring failed generations as zero recall instead of quietly dropping them from the average.

Division Semantic Adversarial Research
Domain Agentic AI / Computer-Aided Design
Published arXiv 2606.13368 2026
Key Result 0.30% invalid ratio, AUC-TR 0.61, closed loop
Drawing-to-Code Text-to-Code Interactive Editing Closed-Loop Refinement CadQuery GSPO Geometry-Viable Prefix Masking Chamfer Distance Tolerance-Recall AUC-TR Cold-Start SFT Survivor-Bias-Free Evaluation OCCT Kernel Drawing-to-Code Text-to-Code Interactive Editing Closed-Loop Refinement CadQuery GSPO
§ 2.0 Core Concepts

IterCAD is governed by a "Look and Loop" philosophy. Look leverages multi-view engineering drawings with dimensional constraints as a persistent reference to isolate defects. Loop establishes a multi-dimensional refinement mechanism that integrates compiler, execution, and visual feedback rather than blind regeneration.

Multi-Turn Interaction Protocol
At each turn the agent perceives the full interaction history system prompt, reference context, and every prior code/feedback pair then outputs a reasoning trace plus either a fenced CadQuery block or a <DONE> token. Any schema violation immediately invalidates the trajectory.
Three Unified Tasks
Drawing-to-Code reconstructs parametric programs from dimensioned orthographic views. Text-to-Code synthesizes from natural-language requirements. Interactive Editing performs localized modifications on existing source code from incremental instructions one agent, one protocol, three modalities.
Geometric Visual Feedback
Beyond compiler logs, the sandbox uses the OCCT kernel to project the generated solid into standard orthographic views and compute explicit dimensional annotations directly from the geometry feedback that localizes errors rather than just reporting a global shape mismatch.
CD-TR Curve & AUC-TR
Standard mean Chamfer Distance suffers survivor bias failed generations are quietly dropped from the average. The CD-TR curve sweeps a tolerance threshold and counts every failure as zero recall; AUC-TR condenses it to one scalar that rewards both executability and precision.
Geometry-Viable Prefix Masking
Once a trajectory falls into an execution cascade or a geometry stall, every later turn inherits the corrupted context but still shares the same sequence-level advantage. GVPM finds the prefix boundary and masks tokens beyond it so viable early turns are never punished for downstream failures.
Composite Reward
R(y) = R_CD(y) + λf·R_fmt(y) + λp·R_prog(y) a piecewise-linear Chamfer-Distance reward, a binary format-compliance term, and a sparse progress bonus that fires only for genuine, monotonically improving multi-turn refinement.
§ 3.0 The Two-Stage Training Pipeline

A static, open-loop policy can't learn to debug itself from imitation alone. IterCAD bootstraps procedural reasoning first, then hands the policy to closed-loop reinforcement learning to teach genuine self-correction.

Stage 1 Imitation
Progressive
Cold-Start SFT
20K expert trajectories establish the basic mapping from engineering specifications to executable code. A further 8K on-policy trajectories, corrected by a teacher model against the base policy's own execution failures, instill iterative debugging behavior before RL ever begins.
refine
Stage 2 Reinforcement
GSPO +
Geometry Rewards
Sequence-level policy optimization with group-relative advantages and a length-normalized importance ratio, restricted to 2K hard Drawing-to-Code samples the task that most rewards closed-loop geometric feedback over imitation alone.
Reward & advantage GSPO with GVPM R(y) = R_CD(y) + λf · R_fmt(y) + λp · R_prog(y) // λf = 0.5, λp = 0.2 geometric fidelity, format compliance, multi-turn progress Â_g = (r_g − mean({r_g'})) / std({r_g'}) // group size G = 8, length-normalized importance ratio prevents long trajectories from dominating f = min(f_exec, f_stall) // GVPM masks tokens past the viable-prefix boundary; masked trajectories clamp Â_g ≥ 0
§ 4.0 Benchmark Results

Agentic Workflow on IterCAD-Draw closed-loop sandbox feedback, up to 5 turns. IterCAD (built on a 4B backbone) converts the multi-turn budget into accuracy that an order-of-magnitude-larger competitor can't match.

0.30%
IterCAD invalid ratio vs 62.30% backbone baseline
0.61
AUC-TR best of all evaluated models
5.09
Mean Chamfer Distance ×10³ lowest in field
2.48
Average turns most parts solved in a single pass
IterCAD-Draw Agentic Workflow (closed-loop sandbox)
ModelIR%AUC-TRMean CDMed. CDAvg Turn
GPT-54.700.5012.181.072.44
Gemini-3-flash-lite12.700.565.790.093.12
GLM-4.6v9.700.4313.723.272.59
Qwen3.5-35B-A3B37.500.3612.510.103.50
Qwen3.5-4B (backbone)62.300.2113.040.094.39
IterCAD (ours)0.300.615.090.352.48
IterCAD-Edit instruction-based local editing
ModelIR%AUC-TRMean CDMed. CDAvg Turn
GPT-50.500.792.140.052.31
Gemini-3-flash-lite11.000.514.270.064.23
Qwen3.5-35B-A3B11.000.557.490.143.84
Qwen3.5-4B (backbone)63.000.189.961.254.49
IterCAD (ours)1.000.547.520.772.34
§ 5.0 What Each Stage Buys

Starting from the bare Qwen3.5-4B backbone, every added component compounds. The full recipe SFT, on-policy refinement, GSPO, and GVPM is what closes the gap from a 62.30% invalid ratio to 0.30%.

01
Cold-Start SFT on Expert Trajectories
The first imitation pass alone drops invalid ratio from 62.30% to 7.50% and lifts AUC-TR from 0.21 to 0.52 establishing the basic specification-to-program mapping before any closed-loop signal is introduced.
02
On-Policy Refinement Data
Adding teacher-corrected trajectories that target the base policy's own execution failures pushes invalid ratio down to 0.80% proof that imitation alone, without geometry-aware RL, still leaves Mean CD high at 12.44.
03
GSPO Reinforcement Learning
Closed-loop reward optimization lowers Mean CD to 8.00 and lifts AUC-TR to 0.58 but without further correction, average turns collapse to 2.18 as the policy learns premature termination is locally rewarding.
04
Geometry-Viable Prefix Masking
Masking gradient contributions from stalled or error-cascading suffixes fixes the credit-assignment problem directly: invalid ratio falls to 0.30%, AUC-TR reaches 0.61, Mean CD drops sharply to 5.09 and the agent persists through productive multi-turn correction instead of bailing early.
§ 6.0 What IterCAD Unlocks

Open-loop, one-shot CAD generation can't recover from its own mistakes by definition. IterCAD's closed-loop architecture generalizes well beyond its own benchmark confirming the gains aren't an artifact of one evaluation protocol.

01
Drawings as Spatial Anchors
Multi-view engineering drawings with dimensional constraints persist across every turn as a physical reference, letting the agent isolate which specific feature is wrong rather than regenerating the whole part from scratch.
02
One Agent, Three Modalities
A single unified session reconstructs a base plate from a drawing, then applies sequential natural-language edits increase thickness, add fillets, undo an operation, add a chamfered boss while preserving unaffected geometry throughout.
03
Generalizes Beyond Its Own Benchmark
On the external Text2CAD benchmark, IterCAD posts a 0.64% invalid ratio against general-purpose models exceeding 50%. On CADPrompt, it beats the domain-specific CAD-Judge baseline by an order of magnitude in median Chamfer Distance.
~/conclusion
$ query: what does IterCAD change // CAD generation stops being open-loop and one-shot. // the drawing becomes a persistent reference the agent checks itself against. $ query: what does this cost // two training stages instead of one, plus a sandbox the agent can fail inside safely. // GVPM exists specifically so failure in turn 4 doesn't punish a correct turn 1. $ query: what is the actual result // 0.30% invalid ratio, AUC-TR 0.61, 2.48 average turns. // a 4B-parameter model out-debugging baselines an order of magnitude larger.

CAD GENERATION
ISN'T
ONE-SHOT.
IT'S A
LOOP.