Architecture and design¶
The README shows the deployed components; this page covers the request lifecycle, design decisions, and prompt engineering.
Request lifecycle¶
Request lifecycle. Seven stages across three lanes; the model call dominates latency, and confirmation is the last gate before COM.
- Request. The add-in sends
{ "prompt": "..." }to the Flask server. When a document is open, it also sends a read-onlycontextsnapshot: units, bounding box, existing feature names, and the current selection. - Prompt assembly. The server prepends the versioned SolidWorks domain prompt to the user text.
- Model call. Any OpenAI-compatible endpoint returns a JSON feature tree. The default request uses
temperature 0.05,top_p 0.95,max_tokens 2048, and a 30-second timeout. The client uses the SSE endpoint and shows streamed progress; if streaming fails, it retries the non-streaming endpoint. The Anthropic adapter sends onlymax_tokens, because current Claude models rejecttemperatureandtop_p. - Recovery. The server strips markdown code fences, then extracts the first
{through the last}before parsing. - Validation. Flask checks the envelope and validates feature parameters. If validation fails, the server retries once with the errors and the previous output fed back to the model (
MAX_REPAIR_ATTEMPTS). The C# client deserializes the envelope into typed model classes, then reads parameters from a dictionary and applies modeler defaults. - Preview, edit, and refine. The add-in opens the feature tree in an editable JSON window; nothing is written until you confirm. A follow-up instruction in the same window sends
current_treeand replaces the preview with the complete revised tree. - Execution.
SwModelerdraws the sketch, selects it, and calls the native feature APIs, includingFeatureExtrusion3,FeatureCut4,FeatureRevolve,FeatureFillet3, andInsertFeatureChamfer. Extrusion and through-cut failures use a keyboard-driven fallback to the native SolidWorks feature panel. A blind cut that fails at the API stops the run instead of falling back, because a simulated cut could go through the part.
The model call dominates latency. Everything else is local and usually measured in milliseconds.
Design decisions¶
Design evolution. Beta executed generated code; Rebuild executes validated data.
JSON parameters instead of generated code¶
The Beta track let the LLM emit Python code that the client ran with exec(). It was flexible and impressive in a demo, but fragile in practice: a hallucinated API call could crash SolidWorks, error recovery was nearly impossible, and debugging meant reading code nobody wrote.
The Rebuild track treats the LLM as a schema-driven parameterizer. The model fills a small, typed template. The C# client owns execution. If the JSON is valid and the parameters pass validation, the feature calls are well-formed. Otherwise, the server rejects the response before SolidWorks is touched. There is no exec() and no code-injection surface in the release client.
A thin client and a portable server¶
- Keys stay server-side by default. Embedding an LLM API key in a client-side macro is not acceptable. When a user chooses to bring their own key, the add-in stores it locally with Windows DPAPI and forwards it to their Vulcan server only for the duration of a request.
- Prompts iterate quickly. Updating a server prompt takes seconds; shipping a new add-in requires a rebuild and reinstall.
- The server can run headless. That keeps the door open for batch processing, CI checks, and a future web front end.
One workflow, thin hosts¶
ModelingWorkflow owns the whole loop: request, validation, preview, COM execution, history, and rollback. The task pane and the modal fallback are thin hosts that inject preview, confirmation, status, and busy callbacks. IGenerationClient, IModelingBackend, and IRunHistory are the seams used by the dependency-free client tests. On the server, app.py is only access control, routes, and SSE framing; request parsing and generation/repair live in services/request_parser.py and services/generation.py.
A domain prompt, not a generic one¶
General models fail at CAD not because they lack intelligence, but because they lack context. They do not know the difference between a front plane and a top plane, or that a cut's Z coordinate must fall inside the base thickness.
Vulcan supplies that context through system_prompt.py: plane-to-axis mappings, feature schemas, shape-specific fields, output discipline, and an anti-overlap rule for multi-feature models.
API first, UI fallback second¶
SolidWorks interop is version-sensitive. The modeler calls the native feature APIs directly, including FeatureExtrusion3, FeatureCut4, FeatureRevolve, FeatureFillet3, and InsertFeatureChamfer. If an extrusion or through-cut call fails, the fallback activates RunCommand and fills the native feature panel with simulated keystrokes. Blind cuts deliberately do not fall back: the run stops with the sketch in place, so a simulated depth cannot cut through the part.
The fallback is pragmatic, not elegant. Keep SolidWorks focused while a model is generated, and treat a fallback that runs often as a signal to update the interop parameters.
Prompt engineering¶
The prompts live in server/prompts/ and are versioned with PROMPT_VERSION = "3.7.0". Chinese, English, and French prompts are native, not translations at runtime; the server selects one from an optional language field (zh, en, or fr) or detects it from the request text. Each prompt encodes five things:
- Output discipline. JSON only — no markdown, no prose, no code fences.
- Coordinate rules. Per-plane axis mappings, with a worked example for a 200 × 100 × 20 base and four holes.
- Feature schema. Required and optional fields for every supported feature type, plus shape-specific parameters.
- Anti-overlap constraint. Multiple identical features must use distinct coordinates; never stack them at the origin.
- Plane vocabulary. Each prompt emits the plane names its language resolves on any SolidWorks UI: Chinese
前视基准面/上视基准面/右视基准面, Englishfront/top/right, and Frenchfront/dessus/droite.
The prompt is deliberately separate from business logic so it can be iterated without touching the server. The model call uses a low temperature because the task rewards consistency, not creativity.