
How AST Made AI-Generated Functions Actually Reliable
When I stopped asking the AI to write code and started asking it to describe logic, everything changed — security, predictability, even multi-language support. I needed AI to generate small, dynamic pieces of logic inside a running system. Nothing exotic — simple calculations, input validations, conditional rules, data transformations. The kind of thing you'd normally write a quick function for, except the rules kept changing and I wanted users to define them without deploying new code. The obvious approach was to let the model generate a function and execute it. And at first, it worked: function calculateTotal ( price , quantity ) { return price * quantity ; } Clean. Correct. Exactly what was needed. So I kept going. And that's when the cracks started to show. Sometimes the syntax was slightly wrong. Sometimes two runs of the same prompt produced wildly different implementations. Sometimes the model referenced globals it assumed would exist. And occasionally — the part that should mak
Continue reading on Dev.to Webdev
Opens in a new tab




