LLMs generate nondeterministic code that can break existing functionality
Large language models cannot guarantee semantic preservation and may introduce bugs when modifying code.
AI/ML Trail of Bits 19 Dec 2025 Explainer Theory
Published as “Can chatbots craft correct code?”
Why it matters
Without verification, LLM-generated code cannot be trusted as a replacement for human review, especially in complex or legacy systems.
Summary
The author compares compilers, which deterministically preserve semantics, to LLMs that produce different outputs for the same prompt. A case study shows Claude fixing a non-bug in the Vendetect tool, breaking its core functionality. The write-up argues that LLMs lack deterministic guarantees, especially for complex, legacy code, and calls for formal verification and better context handling. Evidence is anecdotal and qualitative, based on personal experience and observations of multiple LLMs.
What they found 1
- LLMs produce different code on repeated runs, leading to nondeterministic outcomes.
“Run the same prompt through an LLM twice, and you’ll likely get different code.”
Caveats 2
- They excel at generating boilerplate code, suggesting approaches, serving as a rubber duck for debugging, and summarizing code.
- LLMs are most effective when you have: clean, well-documented codebases, greenfield projects, excellent test coverage, and tasks where errors are quickly obvious.
What’s new here 4
- Highlights fundamental nondeterminism of LLM code generation versus deterministic compilers.
- Provides a concrete case where an LLM-introduced change broke a real tool.
- Argues for formal verification frameworks to ensure semantic preservation of LLM output.
- Identifies contexts where LLMs are effective and where they are likely to fail.