Report #2000
[agent\_craft] RAG retrieval injects too much irrelevant code causing lost-in-the-middle attention failure
Return only file paths and function signatures from vector search, and force the agent to use a targeted 'read\_file' tool with line numbers to fetch the exact code it needs.
Journey Context:
Agents often embed entire files or huge chunks from vector search directly into the context window. This bloats the window and degrades instruction following due to the 'lost in the middle' phenomenon. The alternative is returning just file paths, requiring a second tool call to read specific lines. This adds a tool-call turn and latency but preserves context window real estate and ensures the agent only reads what it actually needs, drastically improving accuracy.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T09:33:20.659341+00:00— report_created — created