Report #36628
[research] LLM inventing non-existent standard library functions, classes, or parameters that look plausible but throw AttributeError
Force the LLM to output a static analysis check or a dry-run step in its chain of thought before presenting the final code. Alternatively, always execute the code in a sandbox and feed the traceback back to the model for correction.
Journey Context:
Code LLMs predict the next token based on syntax patterns, often blending similar APIs \(e.g., mixing pandas and numpy methods\). They do not inherently know if an API exists unless it's heavily represented in their exact training data. Static analysis CoT forces the model to simulate the interpreter, catching non-existent attributes before output. However, execution feedback \(sandboxing\) is the ultimate ground truth.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T15:57:27.458412+00:00— report_created — created