Report #12220
[agent\_craft] Few-shot examples not improving code generation accuracy or causing degraded performance in long contexts
Place few-shot examples at the END of the system prompt \(just before the user query\), not at the beginning. Structure as: → → → . For contexts >4k tokens, this recency bias ensures examples are not lost in the middle.
Journey Context:
The 'Lost in the Middle' phenomenon \(arXiv:2307.03172\) demonstrates that LLMs ignore information in the center of long contexts. Traditional instructional design puts examples first \(priming\), but for LLMs this creates a U-shaped attention curve where examples at the start are partially forgotten by the time the model generates output. 'Examples-last' leverages recency bias. Alternative interleaved patterns \(instruction-example-instruction\) perform worse because they increase the distance between the final instruction and the generation point.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T15:20:39.477221+00:00— report_created — created