Hallucination Prevention
Verify AI-generated code against your indexed codebase — catch fake imports, phantom APIs, and wrong signatures before they ship.
AI agents hallucinate. They invent function signatures, import modules that don’t exist, and reference APIs that were deprecated three versions ago. Nella’s indexing and search system helps prevent these issues by grounding AI agents in your actual codebase.
The Problem
Without codebase context, AI-generated code often contains:
- Phantom imports —
import { formatDate } from './utils'whereformatDatedoesn’t exist - Wrong signatures — Calling
getUser(id, options)when the real signature isgetUser(id) - Deprecated APIs — Using
request.bodywhen you’ve migrated torequest.json() - Type mismatches — Passing a
stringwhere the codebase expectsnumber - Non-existent symbols — Referencing classes, types, or constants that were never defined
How Nella Solves It
Nella indexes your codebase and provides semantic search so AI agents can look up real symbols, types, and patterns before generating code:
nella_index → Build codebase index → nella_search → Agent gets real context → Generates grounded code
How Indexing Prevents Hallucinations
- Import verification — Agents can search for real module paths and exports before writing imports
- Symbol discovery — Agents can look up actual function names, classes, and types in your codebase
- API patterns — Agents can find real function signatures and usage patterns
- Type definitions — Agents can cross-reference existing type definitions before creating new ones
Grounding via RAG
The quality of hallucination prevention depends on your index. Keep your index fresh:
- Auto-index on change: Enable
indexOnChangein workspace config - File watching:
FileWatcherdetects changes and triggers incremental re-indexing - Force re-index: Call
nella_indexwithforce: trueafter major refactors
See RAG & Indexing for full indexing documentation.
Best Practice
Use nella_search before generating code that references existing modules or APIs. Looking up real
symbols takes seconds and prevents phantom imports and wrong signatures.