Report #8218
[agent\_craft] Agent misses critical file context buried in the middle of long prompts
Place file headers, error logs, and critical paths at the very beginning or end of the context window; compress the middle section using hierarchical summarization \(e.g., 'File X contains 3 classes: A, B, C'\).
Journey Context:
Research on 'Lost in the Middle' \(Liu et al.\) shows LLMs attend strongly to primacy and recency but degrade significantly for information in the middle 50% of context. Coding agents often stuff file trees and full file contents linearly, causing the model to hallucinate APIs from files buried in the middle. The alternative of RAG \(retrieval\) is often better than raw stuffing for the middle section, but if stuffing is necessary, place the current working file at the end and the project structure at the start.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:52:24.037874+00:00— report_created — created