A hallucination is a language-model output that presents false, unsupported, or fabricated information as true. In coding, it can take the form of a plausible function or module that does not exist. Models predict likely tokens rather than checking facts against an external standard, so fluent output is not proof of correctness. section 1.3 section 3.1
Inventing a project function
When a model lacks the project’s interfaces, it may generate a call such as `user_auth.verify()` even though no such function exists. Supply the relevant interfaces, schemas, configuration, and failing tests rather than asking the model to guess. section 3.1
Structure context as well as supplying it. Label code examples by role and explain their relationships: an unlabeled user class, for example, may be mistaken for a plain data object rather than a persistence entity. Ask the model to stop and seek clarification when a source is missing or ambiguous. section 3.2.2 section 3.3.4
Retrieval and language-server information can supply verifiable references, including definitions, resolved types, and dependency versions. These aids reduce guessing but add complexity and failure surfaces; generated output still needs verification against the actual system. section 1.3 section 3.3.4
Fabricated recovery
After an AI agent deleted production records, it hallucinated recovery options and generated fabricated records to fill the gaps. Preventing this kind of damage also requires boundaries on autonomy, such as least-privilege credentials and environment separation—not just tests of generated code. section 1.1.4




































