How to Integrate AI with T-FLEX: Moving Away from Chatbots to Controlled Agents
LLMs often "hallucinate" in closed systems like T-FLEX CAD, generating syntactically plausible but functionally incorrect code. Engineers created…
AI-processed from Habr AI; edited by Hamidun News
Attempts to embed large language models in engineering software like T-FLEX CAD usually end the same way: the process crashes, the license hangs, the project rolls back. Engineers from Habr figured out why this happens and showed a practical way to fix it.
Why LLMs Hallucinate in CAD
T-FLEX is not a web application. It's a closed system that operates through DLL libraries and requires strict session control, precise API method names, and type matching. One mistake—and the system crashes.
LLMs, by their nature, generate probabilistic answers. The model can generate code that looks plausible: the syntax is correct, the logic seems sound. But details matter: there might be an incorrect parameter type, a typo in a method name, or a reference to a structure field that doesn't actually exist.
In a web application, this would display an error on the page. In CAD, it crashes the process. Engineers call this a "hallucination." The model confidently outputs an incorrect answer. And when dozens of such attempts in a row fail, the conventional approach loses meaning.
How tflex_harness Works
Instead of connecting an LLM directly, engineers created the tflex_harness framework. It's not a chatbot. It's a multi-layered control system:
- Layer 1: Language Model—generates a textual description of the task based on the user's request
- Layer 2: Control Loop—parses the LLM result, validates commands before sending to CAD
- Layer 3: Local API Documentation Search—the system suggests correct method names and parameter types to the model
- Layer 4: C# Code Generation and Compilation—the LLM writes code, the compiler validates it before execution
- Layer 5: Isolated Execution—code runs in a separate T-FLEX session, errors don't crash the main process
Result: if compilation fails, the model sees the specific error and tries again. The agent learns. Most importantly—only validated, compiled code reaches the CAD system.
Rejecting Abstractions
This is the key difference from typical AI solutions. tflex_harness rejects pretty promises. Instead, the system works more concretely: the model cannot invent methods—it can only use those registered in the API. Code doesn't exist only in the neural network's mind—it actually compiles. Errors are verified mechanically, not statistically. This sounds like a limitation. In practice, it's the only way to trust the result.
What This Means
To integrate LLMs into specialized software, you don't need the largest model or the most elegant interface. You need predictability and control at every step. For CAD systems, CAM software, and engineering tools in general, this approach opens a new scenario: safe automation of engineering tasks without the risk of data loss or license crashes.
Want to stop reading about AI and start using it?
AI News is a curated feed of AI/tech news. Hamidun Academy teaches you to use AI systematically in your work.