AI
LLM-Generated Code for Construction Safety Poses Critical Silent Failure Risk
An empirical study of AI-generated safety code reveals that while modern language models produce syntactically correct scripts, nearly half contain hidden logic errors that could endanger construction sites.
Researchers have flagged a troubling gap between what appears to work and what actually works when non-technical construction managers and safety personnel use large language models to write code. A new study from arXiv (cs.SE) examines this trend—called "vibe coding"—where workers generate executable software through natural language instructions to AI systems.
The Appeal and the Risk#
The promise is clear: empowering site foremen and safety managers to build their own tools without needing a software engineer. But the reality is messier. Large language models are probabilistic systems that sometimes produce code that compiles and runs without error messages yet contains flawed mathematical logic underneath. These "silent failures" can be especially dangerous in construction safety applications.
What the Study Found#
The researchers tested 450 Python scripts generated by three leading frontier models—Claude 3.5 Haiku, GPT-4o-Mini, and Gemini 2.5 Flash—using a dataset of 150 prompts that simulated different user personas. They ran the scripts through isolated testing environments and had AI systems evaluate the results:
- ~85% of generated code executed without crashing
- ~45% of that successfully executed code contained serious logic errors
- GPT-4o-Mini specifically produced mathematically incorrect outputs in roughly 56% of its working scripts
- Less formal prompts led to higher rates of data hallucination, where the AI invented safety variables rather than requesting them
Why This Matters for Safety-Critical Systems#
The study makes a stark observation: current language models lack the deterministic rigor required for standalone safety engineering. Construction sites depend on precise calculations for load capacity, fall protection, and equipment operation—domains where a silent failure could injure or kill someone. The syntactic reliability that makes code "look good" actively masks the underlying mathematical mistakes.
The Path Forward#
Rather than avoiding AI-generated code entirely, the researchers recommend adopting before deploying vibe-coded systems on cyber-physical construction environments. The challenge is building safeguards that catch these hidden failures without eliminating the efficiency gains that AI offers.

