Report #89968
[counterintuitive] Why does the model incorrectly predict what a piece of code will output when run
Always execute code to determine output. Never trust the model's prediction of runtime behavior for non-trivial code, no matter how simple the code looks.
Journey Context:
Developers expect that since LLMs can write code, they should be able to mentally execute it. But writing code \(pattern synthesis from training data\) and executing code \(step-by-step state machine\) are fundamentally different operations. The model predicts what the output of similar code patterns looks like, not what this specific code produces when executed. For simple patterns \(print\('hello'\)\), the prediction is reliable because it's a common training pattern. For anything involving state mutation, loops with complex conditions, or non-obvious control flow, the model's 'execution' is pattern-matching to similar code it's seen, not actual simulation. This is the same fundamental limitation as arithmetic: the model doesn't have a Turing machine inside it. It can approximate execution for familiar idioms but cannot reliably simulate arbitrary computation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T09:36:17.162901+00:00— report_created — created