Disclaimer; Before you reach for your machine guns, proclaiming me to be crazy, hear me out about how my system works.
First of all, my LLM (fine-tuned GPT-4.1-mini) doesn’t emit code, it generates ASTs, as in abstract syntax trees. It’s also a functional PL, where each individual function invocation goes indirectly through the execution layer - Which can be restricted, sandboxed, and 100% perfectly controlled deterministically, allowing the agent to be “creative in composition, not in vocabulary” - Effectively eliminating an entire axiom of security related RCE issues for obvious reasons.
However, when my LLM is told to generate code, the code is checked statically towards its internal meta data, 100% transparently (O(n) process, zero AI), a handful of milliseconds CPU time. This check occurs before the API endpoint returns the code, and if the code contains hallucinated “slots” or functions, not available to it in its current execution context, it will try again twice (1.5 to 5 seconds per invocation) up to a maximum of 3 times, increasing creativity as it goes, before it returns; “Sorry dude, I can’t do this for you!”
I realise that doesn’t eliminate all hallucinations, since these are based upon intent - But it eliminates one very specific axiom of hallucinations, which from a purely practical point of view happens to be the most frequent one - Which is “answers to capabilities in negative space”. Technically, the ability I just described 100% perfectly does just that, as in “100% coverage of negative space”, simply because hallucinated functions refuses to leave the API endpoint, to the point where it would rather accept it doesn’t know how to solve some particular task, than to return hallucinated code …
I’ve been accused of being very smart. I personally find it a little bit surprising I’m apparently the only guy on earth having played with these ideas, especially considering most of it originates from the late 1950s, and should be fairly obvious for anyone with a CS degree - But OK … ![]()
Anyways, read more here, and fork the open source code to verify my claims if you wish too …
And yes, my LLM API endpoint will never return code referencing non-existing functions - It cannot. And it’s not a probabilistic game, it’s a CANNOT! PERIOD! game …