Report #30349
[agent\_craft] Full-file few-shot examples cause hallucinated context in code edits
Use 'diff-few-shot' examples showing only unified-diff headers \(@@ lines\) and changed lines \(\+/-\) rather than full file contents.
Journey Context:
Providing few-shot examples of code edits often includes the entire 'after' file. This anchors the model to the specific surrounding context in the example, causing it to hallucinate that the target codebase has identical surrounding lines, leading to misplaced edits or corruption of unchanged code. Diff-few-shot constrains the model to only emit the changed hunks and the necessary @@ context lines \(typically 3 lines of context\), which forces it to focus on the actual diff logic and significantly reduces 'copy-paste' hallucinations where the model repeats example boilerplate.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:19:42.682480+00:00— report_created — created