How to Integrate AI with T-FLEX: Ditching Chatbots for Controlled Agents

LLMs often "hallucinate" in closed systems such as T-FLEX CAD, producing code that looks syntactically plausible but is functionally wrong. The engineers built tflex_harness, a framework that drops chatbot abstractions in favor of strict control: local API search, C# code generation, compilation before launch, and controlled execution inside the CAD system. The result: the agent runs more reliably and makes fewer mistakes.

AI-processed from Habr AI; edited by Hamidun News
How to Integrate AI with T-FLEX: Ditching Chatbots for Controlled Agents
Source: Habr AI. Collage: Hamidun News.
Listen to article
Article Fact Sheet & Key Figures
ParameterDetails
Primary sourceHabr AI ↗
Editor-in-Chief
Layer 1language model — generates a text description of the task based on the user's request
Layer 2control loop — parses the LLM output and checks commands before they are sent to the CAD system
Layer 3local search over API documentation — the system suggests correct method names and parameter types to the model

Attempts to embed large language models in engineering software such as T-FLEX CAD usually end the same way: the process crashes, the license hangs, the project gets rolled back. Engineers on Habr worked 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 is a closed system that works through DLL libraries and demands tight session control, exact API method names and matching data types. One error, and the system crashes.

LLMs, by their nature, give probabilistic answers. A model can generate code that looks plausible: the syntax is correct and the logic seems reasonable. But the details matter: a parameter may have the wrong type, a method name may contain a typo, or the code may reference a structure field that does not actually exist. In a web application, this puts an error on the page. In CAD, it crashes the process.

Engineers call this "hallucination": the model confidently gives a wrong answer. And when dozens of such attempts in a row fail, the usual approach stops making sense.

How tflex_harness works

Instead of connecting an LLM directly, the engineers built the tflex_harness framework. It is not a chatbot. It is a multilayer control system:

  • Layer 1: language model — generates a text description of the task based on the user's request
  • Layer 2: control loop — parses the LLM output and checks commands before they are sent to the CAD system
  • Layer 3: local search over API documentation — the system suggests correct method names and parameter types to the model
  • Layer 4: C# code generation and compilation — the LLM writes code, and the compiler checks it before any attempt to run it
  • Layer 5: isolated execution — the code runs in a separate T-FLEX session, so errors do not crash the main process

The result: if compilation fails, the model sees the specific error and tries again. The agent learns. Most importantly, only verified, compiled code reaches the CAD system.

Dropping abstractions

Here is the key difference from typical AI solutions. tflex_harness rejects grand promises. Instead, the system works in concrete terms: the model cannot invent methods, and is forced to use only those registered in the API. The code does not exist only in the neural network's head; it is actually compiled. Errors are checked mechanically, not statistically.

This sounds like a limitation. In practice, it is the only way to trust the result.

What this means

Integrating LLMs into specialized software does not require the biggest model or the slickest interface. It requires predictability and control at every step. For CAD, CAM systems and engineering software in general, this approach opens up a new scenario: safe automation of engineering tasks without the risk of data loss or a license crash.

Story

Key Questions Answered

Why LLMs hallucinate in CAD?

T-FLEX is not a web application. It is a closed system that works through DLL libraries and demands tight session control, exact API method names and matching data types. One error, and the system crashes. LLMs, by their nature, give probabilistic answers. A model can generate code that looks plausible: the syntax is correct and the logic seems reasonable. But the details matter: a parameter may have the wrong type, a method name may contain a typo, or the code may reference a structure field that does not actually exist. In a web application, this puts an error on the page

How tflex_harness works?

Instead of connecting an LLM directly, the engineers built the tflex_harness framework. It is not a chatbot. It is a multilayer control system: Layer 1: language model — generates a text description of the task based on the user's request Layer 2: control loop — parses the LLM output and checks commands before they are sent to the CAD system Layer 3: local search over API documentation — the system suggests correct method names and parameter types to the model Layer 4: C# code generation and compilation — the LLM writes code, and the compiler checks it before any attempt to

What are the key details on Dropping abstractions?

Here is the key difference from typical AI solutions. tflex_harness rejects grand promises. Instead, the system works in concrete terms: the model cannot invent methods, and is forced to use only those registered in the API. The code does not exist only in the neural network's head; it is actually compiled. Errors are checked mechanically, not statistically. This sounds like a limitation. In practice, it is the only way to trust the result.

ZK
Zhemal Khamidun — CPO at Alpina Digital, product manager of AlpinaGPT. Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Unified AI Workspace · Nomad

Test Frontier LLMs & Autonomous Agents in One Workspace

Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.

Try Nomad AI →Launch Nomad Agent
What do you think?
Loading comments…