Guarding Against Hallucinated Citations

citation verification

Part of: Codebase Assistant

A citation only means something if it's real. A model can format [src/auth.py:200-210] with full confidence even when no such chunk was ever retrieved, inventing a location that looks as trustworthy as a correct one. This lesson catches that. The failure mode Everything from lesson 5 makes the model format citations correctly. None of it guarantees the citations are true . Two ways this breaks in practice: 1. The model paraphrases from its own training knowledge of common code patterns instead of the retrieved chunk, then attaches a citation that looks plausible but matches nothing you sent it. 2. The model cites a real file in the repo but a line range that was never part of any retrieved chunk, close enough to believe and wrong enough to send someone down the wrong path. Both look identical to a correct citation until you check them against what was actually retrieved. The verification step You already have the ground truth: the exact set of chunk IDs you put in the context block. Verifying a citation is a membership check against that set, nothing more: If fabricated is non-empty, the answer references code that was never shown to the model. That's a strong signal to flag or rej

Challenge: Catch the Hallucinated Citation