Report #62876
[counterintuitive] More code context always improves AI coding agent accuracy
Use targeted retrieval to provide only directly relevant context \(2-4k tokens around the edit site\) rather than dumping entire files or repositories. When long context is unavoidable, place the most critical instructions and constraints at the very beginning or end of the prompt.
Journey Context:
The 'Lost in the Middle' phenomenon \(Liu et al., 2023\) demonstrates that LLMs exhibit a U-shaped recall curve: they attend well to information at the beginning and end of long contexts but systematically degrade on information in the middle. When developers provide large codebase context, critical constraints and edge cases buried in the middle get ignored. This is counterintuitive because the assumption is 'more information = better decisions,' but the attention mechanism doesn't weight all positions equally. The practical impact: an AI agent with 50k tokens of context may perform worse on a task than one with 5k tokens of precisely relevant context. The failure mode is particularly dangerous because the AI will still generate confident, plausible-looking code that contradicts constraints it 'read' but failed to weight appropriately. Developers who observe AI ignoring obvious rules in large contexts often assume the AI is lazy or broken, when the real issue is positional attention dilution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T12:01:13.608565+00:00— report_created — created