AI
LLM-Generated PLC Code Masks Runtime Errors Despite Compilation Success
Researchers show that AI-generated industrial control logic often compiles without errors but fails during execution, with new benchmark and fix method CycleGen improving reliability.
Large language models can now write control programs for industrial automation systems, but a new study reveals a troubling gap: code that compiles cleanly often breaks when actually running. Checking whether a program merely compiles is an insufficient measure of correctness for automated industrial control logic.
The Problem with Undetected Behavioral Failures#
Programmable logic controllers (PLCs) power industrial automation by cycling through repeated scans—each one reads sensor inputs, runs control logic, and updates equipment outputs. Engineers traditionally write this logic in Structured Text (ST), a standardized programming language. While LLMs can generate ST from plain-language specifications, prior validation methods have focused on compilation success or spot-checked a handful of execution scenarios.
Researchers studying eight different LLMs and baseline approaches found that actual execution pass rates trail compilation pass rates by nearly 12 percentage points. This gap exposes failures in output updates, arithmetic operations, and timing—issues that a compiler never caught. Even when programs do run, the timing of when outputs are sampled matters enormously: checking results only every fifth cycle misses more than one-fifth of the failures that per-scan comparison would catch.
CycleBench: A New Benchmark for Real-World Validation#
To quantify the problem, researchers built CycleBench, a benchmark of 301 industrial control tasks with behavioral requirements, public interfaces, reference implementations, and executable test scenarios. Each test runs a generated program alongside its reference version under identical inputs and timing, comparing outputs after every single scan to catch transient discrepancies.
Results show that failure detection is highly sensitive to sampling phase. Depending on when checks occur during an execution cycle, missed-failure rates ranged from 12% to 28%—a dangerous blind spot for systems that must operate reliably in factories.
CycleGen: A Method for Self-Correcting Generation#
Building on these findings, researchers introduced CycleGen, a multi-stage approach to improve LLM-generated PLC code. The method generates multiple candidate programs, uses compiler feedback to fix syntax errors without manual intervention, then selects the best candidate by running automatically generated self-tests in a separate model instance.

