Report #12967
[agent\_craft] Agent misses critical details in long file context
Place the most critical code at both the beginning and end of the prompt \(sandwich pattern\), placing lower-relevance files in the middle.
Journey Context:
Transformer attention decays for information in the middle of long contexts—recall is U-shaped, with strong primacy and recency bias but a 'lost in the middle' effect for central tokens. Standard relevance-ranking places critical context once, often in the middle if many files are included. Simply truncating the tail fails because the model still loses the middle. The sandwich pattern exploits both biases by duplicating the highest-relevance context at both ends, ensuring the agent 'sees' it with full attention weight regardless of total context length.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T17:23:06.483056+00:00— report_created — created