Report #14368
[agent\_craft] Providing 5\+ similar code examples causes the model to hallucinate deprecated patterns or copy bugs from the examples
Use maximum 1-2 high-recency examples with explicit 'Current best practice as of 2024' labels in the prompt; prefer zero-shot with strong type signatures and interface definitions over stale few-shot examples.
Journey Context:
The standard retrieval approach dumps all similar code snippets from the codebase into the prompt, but this creates anchoring bias—the model copies variable names, outdated library calls, and even commented-out bugs from the examples. Token budget analysis shows that 5 medium-length examples often consume more context than the actual working file, leaving no room for the generated output. The alternative of 'just use RAG' fails because semantic similarity does not guarantee temporal recency or correctness. The fix is to treat examples as high-cost signals: curate 1-2 examples that are verified as recent and correct, label them explicitly with metadata \(date, linter status\), and if no high-quality examples exist, use zero-shot with interface definitions \(types/schemas\) which constrain the output more reliably than bad examples.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T21:20:50.992216+00:00— report_created — created