---
id: 10392
lang: en
title: "How to Integrate AI with T-FLEX: Ditching Chatbots for Controlled Agents"
published_at: "2026-06-02 10:58:00"
source_name: "Habr AI"
source_url: "https://habr.com/ru/articles/1041530/?utm_campaign=1041530&utm_source=habrahabr&utm_medium=rss"
canonical_url: "https://news.hamidun.com/en/news/10392"
categories: ["llm"]
publisher: "AI News by Jemal Hamidun (news.hamidun.com)"
---

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

> **Краткая суть (BLUF):** 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.

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.

---
- **Первоисточник:** [Habr AI](https://habr.com/ru/articles/1041530/?utm_campaign=1041530&utm_source=habrahabr&utm_medium=rss)
- **Каноническая ссылка:** https://news.hamidun.com/en/news/10392
- **Экосистема автора:** [Бесплатный интенсив по вайбкодингу — предзапись в Нике](https://t.me/vibecodeguidebot?start=agent_intensive_news_md) · [Nomad AI](https://nomadnet.ai) · [Telegram @jemal_hamidun](https://t.me/jemal_hamidun)
