Report #55154
[agent\_craft] Agent fails to edit the correct function despite it being present in the context window
When providing file context for targeted edits, place the target function/code block in the MIDDLE of the context window \(not at start or end\) to mitigate 'lost in the middle' attention bias
Journey Context:
LLM attention is U-shaped: strong at the beginning \(primacy\) and end \(recency\) of the context, but degraded in the middle. If the target function for an edit is placed at the very start of a long file context, or buried at the end, the model may miss it or conflate it with surrounding code. Research shows that placing critical information slightly off-center towards the middle actually improves retrieval accuracy for long-context models. For coding agents, this means surrounding the target function with a small amount of preceding and following context, but not putting it at the absolute boundaries of the prompt.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T23:04:08.872271+00:00— report_created — created