Report #39029
[counterintuitive] Adding 'Do not hallucinate' or 'Only answer if you are 100% sure' to reduce factual errors in code generation
Ground the model with retrieval \(RAG\) or tool use, and explicitly define the scope of acceptable libraries/versions.
Journey Context:
'Do not hallucinate' is a vague, abstract instruction that modern models cannot reliably self-enforce because they lack calibrated internal confidence thresholds. It often causes over-refusal \(refusing to write standard code because it is 'not 100% sure'\). Hallucinations in code usually stem from outdated training data or ambiguous prompts. The fix is grounding \(providing docs\) or strict domain constraints \('Use only Python standard library'\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T19:59:12.107179+00:00— report_created — created